Open michaelBenin opened 9 years ago
I'm having an almost identical problem but with trying to use Exoskeleton
with backbone.nativeview
. My problem is the same as yours though; Aliasify will cycle through my SOURCE FILES, but ignores looking in the dependencies that I have in my node_modules
folder.
[10:07:42] Starting 'scripts'...
aliasify - /var/www/planner/app/static/js/src/main.js: replacing backbone with exoskeleton
Browserify Failed: Cannot find module 'backbone' from '/var/www/planner/app/static/node_modules/backbone.nativeview'
[10:07:42] 'scripts' errored after 854 ms
How do we make Aliasify cycle not just our source files, but the dependencies loaded from node_modules
?
This is not an aliasify issue, but a browserify one.
A transform is only applied to source files, not node_modules If you wish to apply aliasify to all files, you should run it as a "global transform"
(I had the same problem, and found this out via https://github.com/substack/node-browserify/issues/501)
Yes you seem to be correct. Whenever specifying the transform, we seem to need to set global
i.e.
bundle.transform('aliasify', {
aliases: {
'backbone': 'exoskeleton'
},
verbose: true,
global: true
})
Apologies for the confusion, I guess that's down to me being unclear as to how transforms work. There's a lot of the Browserify documents to digest!
Seems to not work for me, I have:
"browserify": {
"transform": [
["aliasify", {
"global": true,
"debug": true,
"aliases": {
"react": "preact-compat",
"react-dom": "preact-compat"
}
}]
]
},
and still get plenty of:
Error: Cannot find module 'react' from '/Users/tj/dev/src/github.com/tj/vitals/client/node_modules/react-router/lib'
Error: Cannot find module 'react' from '/Users/tj/dev/src/github.com/tj/vitals/client/node_modules/react-router/lib'
I tried adding the package.json config as mentioned in the readme, but that seems to have no effect. Any suggestions?
This might help with defining global transforms in the package.json:
Breaks on const
's, seems like it's working now otherwise!
I've been doing some testing on using aliasify to replace requires of underscore for lodash. I've enabled verbose to be true. I've ran into an issue where in Backbone it still requires underscore instead of lodash.
See the output below:
Output:
Configuration: