You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since 10.1.1, b.add() will not resolve to a node module.
For example:
Before 10.1.1:
I can b.add('superagent') to bundle a node module in a project.
After 10.1.1:
I will get "Cannot find module"
To reproduce it.
npm init test // init a project
npm install superagent --save // simply add a node module
npm install browserify // install browserify
Set up a ./test.js in the project:
var browserify = require('browserify');
var b = browserify();
b.add('superagent');
b.bundle(function(err, buf) {
if (err) return console.log(err):
console.log(buf.toStrinig())
});
In command line, node ./test.js will callback error 'Cannot find module'.
But, if we change to browserify@10.1.0
npm install browserify@10.1.0
We'll get a bundled code.
The text was updated successfully, but these errors were encountered:
@benpptung The behavior did change, yes. See #1248 and #1268. Did the API change? Not really? In my opinion b.add() is too vaguely specified, so who can say how it's intended to work? Although maybe something is implied by contrasting it with b.require()'s documentation:
The file param is anything that can be resolved by require.resolve().
For the moment you should be able to work around the issue by doing:
b.add(require.resolve('superagent'))
I don't want to be the one to close and bury this issue because I don't think the situation has been properly dealt with yet (see my comments in the other issues).
@jmm Thank you for update.
I was asking because I wrote a package http://github.com/benpptung/appstackr, which depends on browserify a lot, so this was a little shock to me when I saw it didn't work.
Sorry for my words, I agree it is a behavior change, not API change. Yes, I was misguided by the b.require()'s documentation. I'll close this issue, because I think this is just not properly addressed in the b.add() documentation. Thank you for your clarification. :)
Since
10.1.1
, b.add() will not resolve to a node module.For example:
Before 10.1.1:
I can b.add('superagent') to bundle a node module in a project.
After 10.1.1:
I will get "Cannot find module"
To reproduce it.
npm init test // init a project
npm install superagent --save // simply add a node module
npm install browserify // install browserify
Set up a
./test.js
in the project:In command line,
node ./test.js
will callback error 'Cannot find module'.But, if we change to browserify@10.1.0
npm install browserify@10.1.0
We'll get a bundled code.
The text was updated successfully, but these errors were encountered: