NPM packages with subfolders don't work?
See original GitHub issueTrying to include an NPM package with a vendor subfolder, (zipjs-browserify), generates the following error when loading the page in the browser :
Error: Cannot find module ‘zipjs-browserify/vendor/zip’ from ‘zipjs-browserify/index.js’
I’ve create a separate projet without brunch and included zips-browserify manually, it works straight out so I don’t think the issue is with zipjs-browserify.
When looking at the compiled file, I can see code from zipjs-browserify/index.js
but no code from the files that are in zipjs-browserify/vendor
.
If I add node_modules/zipjs-browserify/vendor
to the watched list, the error disappear but I get a new one : ReferenceError: Can't find variable: __dirname
(__dirname is used by zipjs-browserify). I think this one is out of scope.
One more thing that may be important : zipjs-browserify is not called directly from my code but from another library (ip-extract-info).
So, do I need to manually add every subfolder of each NPM modules ?
Environment
- Brunch: clone from master (@89f71d1)
- Node: 7.3.0
- NPM: 3.10.10
- Operating system: Mac 10.12.1
package.json
contents
{
"dependencies": {
"clean-css-brunch": "^2.0.0",
"ipa-extract-info": "^1.2.2",
"javascript-brunch": "^2.0.0",
"sass-brunch": "^2.9.0",
"util": "^0.10.3",
"zipjs-browserify": "^1.0.1"
},
"devDependencies": {
"admin-on-rest": "^0.6.1"
}
}
brunch config contents
exports.config = {
paths: {
'public': 'web',
'watched': ['app/Resources/front']
},
files: {
javascripts: {
joinTo: {
'js/app.js': /^app/,
'js/vendor.js': /^(?!app)/
}
},
stylesheets: {
joinTo: {
'css/vendor.css': /^(?!app)|app\/Resources\/front\/scss\/base/,
'css/admin.css': /^app\/Resources\/front\/scss\/admin/,
'css/download.css': /^app\/Resources\/front\/scss\/download/
}
}
},
conventions: {
ignored: [
/\/_/ // File beginning by "_" like _settings.scss
],
assets: /^app\/Resources\/front\/assets/
},
plugins: {
sass: {
allowCache: true
},
cleancss: {
keepSpecialComments: 0,
removeEmpty: true
}
}
};
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top GitHub Comments
Interesting. I am experiencing the same issue as wassafr
I tried to reproduce this at https://github.com/IvanSanchez/brunch-bug-1618 , with
but Brunch works as expected.