After reading your post again it seems I answered to another question xD
The question I tried to answer: Why do plugins for NodeBB often have a vendor directory instead of using node_modules/?
You shouldn't depend on your package managers internal structure.
Relying on the path node_modules/ being existing and containing the expected is doing so.
For example if you do the following:
npm i emoji-parser
# node_modules contains emoji-parser and wrench (the dependency for emoji-parser)
# node_modules/emoji-parser/node_modules is not existing
npm i email@example.com # any other semver range than emoji-parser uses within dependency definitions
# node_modules contains emoji-parser and wrench (1.5.0)
# node_modules/emoji-parser/node_modules contains wrench (the dependency version for emoji-parser)
So if you're developing
emoji-parser you cannot be sure where your dependency is located at.
And the above is only the structure of the current NPM version. It's not ensured to stay this way.
Since NodeBB requires you to state within plugin.json which files/directories to provide to public and which style-files to use etc. you'd need to know the directory they're located at.
So you have to do so by providing these files directly.
But I see your point and maybe future versions of NodeBB may provide alternative ways of injecting dependencies.
- NodeBB could provide equivalents to
filter:scripts.get for styles and public directories. This would allow dynamically resolving the paths (
- Best would be to use
bower for frontend dependencies.
- Is there a way to reliably trigger
bower install via npm-scripts (e.g.
install)? Would require bower installed (within node_modules dir of plugin or globally, so just stating as npm-dependency wouldn't fit)
- If there is not maybe NodeBB could state bower-dependency and ensure
bower install of plugins that contain a bower.json.
- Or if NodeBB provides the hooks mentioned before plugins could call
bower install within
action:app.load so the files are ensured to exist when those hooks get called (If they're called after the
action:app.load, don't know the code-order). This way only the plugins would state
bower as dependency.