Is it possible to make plugins installable through npm?

Hey all, I’m trying to set up my plugins so they can be installed through npm. For plugins like Uglify, this could be big, since it would allow it to be integrated into the build process of other plugins, and thus replace things like gulp’s minify.

But I can’t figure out how.

The closest I’ve come is to have Uglify prepare its package so it’s installed node_module (in ./node_modules/tw5-uglify/) looks like:

LICENSE
package.json
README.md
flibbles
    uglify
        plugin.info
        ...

Then I’d have the npm scripts of other projects run tiddlywiki like this: TIDDLYWIKI_PLUGIN_PATH=node_modules/tw5-uglify tiddlywiki --build test or whatever, and the other projects’ tiddlywiki.info would include flibbles/uglify in their plugins object.

But this isn’t great. It requires users to modify their TIDDLYWIKI_PLUGIN_PATH to run stuff, which might be different depending on local or global installations of my Uglify package. All the searching I do and LLMs I ask indicate that tiddlywiki will automatically make node modules detectable for plugins, but this doesn’t appear to be the case. Or at least I’m doing it wrong.

Does anyone know what I’m doing wrong?

Flibbles

Edit: I’ve finished looking through the TW source code, particularly in boot.js. There does not seem to be any consideration for the node_modules directory. LLMs are dirty liars.

1 Like