Skip to content

Commit fd336bb

Browse files
Rob--Wrpl
authored andcommitted
fix: Stop bundling dependencies with slashes (#1634)
External dependencies should not be bundled, because they are already referenced via "dependencies" in package.json. Before this patch, external modules with slashes in their identifier were bundled anyway because there is no directory with that name in the `node_modules` directory (which in turn prevents them from being added to the `externals` object in the webpack config). This is fixed by looking up dependencies in `package.json` instead.
1 parent d86cd2c commit fd336bb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

webpack.config.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
/*eslint prefer-template: 0*/
22
var path = require('path');
3-
var fs = require('fs');
43

54
var webpack = require('webpack');
65

76
var nodeModules = {};
87

9-
// This is to filter out node_modules as we don't want them
10-
// to be made part of any bundles.
11-
fs.readdirSync('node_modules')
12-
.filter(function(x) {
13-
return ['.bin'].indexOf(x) === -1;
14-
})
8+
// Do not bundle any external module, because those are explicitly added as
9+
// "dependencies" in package.json. Bundling them anyway could result in bugs
10+
// like https://github.com/mozilla/web-ext/issues/1629
11+
Object.keys(require('./package.json').dependencies)
1512
.forEach(function(mod) {
1613
nodeModules[mod] = 'commonjs ' + mod;
1714
});

0 commit comments

Comments
 (0)