Configuring transforms via the browserify.transform field in package.json is lovely. It's a great way to configure browserify once regardless where/how browserify is executed (manually or via npm script or other).
It would be even more lovely to support configuring plugins via package.json as well.
Plugins are much trickier since they get the whole browserify instance, not just individual files. That means a plugin deep in your dependency graph could patch features globally or collide with another program, causing all kinds of havoc.
So this is an issue if dependencies specify a browserify plugin in _their_ package.json. Since plugins can only be specified at the command line (or via the API), there is currently no way to have a plugin only apply to a dependency.
So could this feature be implemented by having browserify only respect the browserify.plugin field at the top level? That way specifying a package.json thusly:
"browserify": {
"plugin": [ "my-plugin" ]
}
is identical to browserify -p my-plugin. Any browserify.plugin fields in dependencies are ignored.
(If I understand the issue correctly)
I think it would be very confusing to have something different happen to package.json depending on whether a package was "top-level" or not.
As a module author, though, one would have no need for plugins since there
is currently no way to execute browserify+plugin against a module dep.
So the only time that a browserify-built app needs plugins _and_ is a
dependency, is if browserify is used during publishing. And as such, the
'top-level' app that depends on a such a module wouldn't be consuming the
app's package.json, but rather the already-built bundle.
On Tue, May 12, 2015 at 3:40 PM, James Halliday [email protected]
wrote:
I think it would be very confusing to have something different happen to
package.json depending on whether a package was "top-level" or not.—
Reply to this email directly or view it on GitHub
https://github.com/substack/node-browserify/issues/1261#issuecomment-101396197
.
+1
Most helpful comment
So this is an issue if dependencies specify a browserify plugin in _their_ package.json. Since plugins can only be specified at the command line (or via the API), there is currently no way to have a plugin only apply to a dependency.
So could this feature be implemented by having browserify only respect the
browserify.pluginfield at the top level? That way specifying a package.json thusly:is identical to
browserify -p my-plugin. Anybrowserify.pluginfields in dependencies are ignored.(If I understand the issue correctly)