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
What I'm trying to do is alias an underscore-extend for all calls to require('underscore') (or import 'underscore' in ES6). The reason for this is I'm mixing in some of my own functions to underscore and I'd like them to be available anywhere underscore is required in my codebase.
Here's my underscore-extend.js:
import _ from 'vendor/underscore'
_.mixin({
...
})
export default _
And my gulpfile:
let b = browserify({
entries: `./app/${app}/index.js`,
debug: true,
detectGlobal: false,
paths: [
'./app/shared/',
'./app/shared/lib/',
'./app/'
]
}).transform(browserifyShim) // config must be in package.json
.transform('babelify', {presets: ['es2015'], compact: false})
.transform('brfs')
.plugin(pathmodify, {mods: [
pathmodify.mod.id('underscore', 'shared/lib/underscore-extend')
]})
I'm wondering if it's just the order of transforms/plugins or if the pathmodify plugin is wrongly parsing the erroring file in ES6 instead of from the stream. Or something else I'm not even thinking of.
The text was updated successfully, but these errors were encountered:
Hello @mnoble01. The error goes away if you just remove Pathmodify and leave everything else as-is? If that's the case, it suggests that Browserify thinks your module is in node_modules/ when using Pathmodify (not sure how that would happen though).
I'm wondering if it's just the order of transforms/plugins
That could be the issue in some cases, because a plugin can add a transform, but Pathmodify doesn't currently.
or if the pathmodify plugin is wrongly parsing the erroring file in ES6 instead of from the stream
It's definitely not that: Pathmodify doesn't parse files it all, it just affects Browserify's module path resolution behavior.
I'm not exactly sure off the top of my head how Pathmodify would interact with the paths config. For an experiment you could try setting your target like this:
FWIW, the way the Node module system works, you should be able to just invoke your script that extends Underscore from your entry point, not have it export anything, and just import Underscore from your other modules since it should be the same object (although it looks like you have Underscore in vendor/underscore and would need to rewrite imports of underscore somehow anyway?).
Can you create a repo with a minimal reproduction?
By the way, I'd like to ask you a question about your usage of Pathmodify off GitHub and I'd appreciate if you would get in touch with me here (please make sure to include contact information).
##I'm getting this error when using pathmodify.
What I'm trying to do is alias an
underscore-extend
for all calls torequire('underscore')
(orimport 'underscore'
in ES6). The reason for this is I'm mixing in some of my own functions to underscore and I'd like them to be available anywhere underscore is required in my codebase.Here's my underscore-extend.js:
And my gulpfile:
I'm wondering if it's just the order of transforms/plugins or if the pathmodify plugin is wrongly parsing the erroring file in ES6 instead of from the stream. Or something else I'm not even thinking of.
The text was updated successfully, but these errors were encountered: