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
I am facing a strange problem running latest browserify (10.2.4) and gulp.
It seems that the same file is being resolved multiple times, and so I don't get the same instance when creating a singleton.
I've put a 'debugger' before module.exports and verified it is called twice.
note #1: I have a guess that says that browserify caches the files based on the string, and so when calling relative paths from different places will not have the same string, even though they point to the same place.
note #2: I was using Browserify 3~ until now, and only when I upgraded it started happening.
Example:
Given:
app.js
/folder1/foo.js
/folder2/bar.js
/folder1/foo.js:
function Foo(){}
module.exports = new Foo(); // Creating a singleton
/folder2/bar.js
var foo = require('../folder1/foo');
function Bar(){
// do something with foo
}
module.exports = Bar;
/app.js
var foo = require('./folder1/foo'),
Bar = require('./folder2/bar');
var bar = new Bar();
// Now 'foo' here and 'foo' inside Bar are not the same instance.
The text was updated successfully, but these errors were encountered:
I have found that browserify-resolutions solves the problem. I had the same problem with jquery plugins, I had one instance for each jquery called by each plugin. browserify-resolutions fixed it.
How do I use browserify-resolutions? I have npm installed it but I don't know where the code should actually go. I'm using the Sails framework and I have a 'browserify.js' file, but I still don't know where to put browserify-resolutions. I'm very new to all of this and I'm getting the same "Invariant..." error. thanks!
I am facing a strange problem running latest browserify (10.2.4) and gulp.
It seems that the same file is being resolved multiple times, and so I don't get the same instance when creating a singleton.
I've put a 'debugger' before module.exports and verified it is called twice.
note #1: I have a guess that says that browserify caches the files based on the string, and so when calling relative paths from different places will not have the same string, even though they point to the same place.
note #2: I was using Browserify 3~ until now, and only when I upgraded it started happening.
Example:
Given:
/folder1/foo.js:
/folder2/bar.js
/app.js
The text was updated successfully, but these errors were encountered: