Hey, all —
This plugin allows shadow tiddlers in a wiki to be patched at boot-time. This makes it possible to change the TiddlyWiki core without creating conflicts or errors when the wiki is upgraded. Almost any code in the core can be patched. † It's also possible to patch other, non-core plugins. If any conflicts do arise, the patch operation is aborted and the wiki will load without modifications.
While it's still in development, the modloader is ready to use. I expect this will be useful for developing plugins that change TiddlyWiki's behavior at deeper levels, including the instrumentation and optimization work we've been discussing here. It should be possible to generate a mod from a git branch and distribute this, making it easier to distribute and test branch functionality. More tools will be necessary to make this practical.
The plugin includes a Patch Maker utility
to generate patch files by comparing a shadow tiddler with a non-shadow tiddler that is overriding it. I'll probably make this a bit more convenient to use in the future.
As a final note, and echoing Jeremy's sentiment, it remains preferable to avoid using mods to create a plugin whenever possible. The modloader is designed to offer a safer alternative to overshadowing core code, when new functionality does require core changes.
The modloader runs as a startup module, before all modules provided by the core. It scans the wiki for patch tiddlers and applies them to the specified "source" tiddlers. The results are generated into a new plugin, $:/temp/mod-plugin
If any conflicts are encountered while applying patches, the modloader aborts completely to preserve the integrity of the wiki and no mods are applied. A visual warning will be generated. Warnings are also generated if a mod attempts to patch an "unpatchable" tiddler †.
† Raw markup tiddlers and bootloader code cannot be patched. Startup modules cannot be patched, because they are loaded before the modloader runs. I'm discussing ways to remove the latter restriction with Jeremy.
The modloader currently overshadows startup.js in order to prevent non-startup modules from being loaded before the modloader runs. This might impact the modloader's compatibility with future versions of the core. This is another restriction that might be lifted in future versions of the core.