Skip to content

Commit

Permalink
fix: Stop bundling dependencies with slashes (#1634)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Rob--W authored and rpl committed Jun 25, 2019
1 parent d86cd2c commit fd336bb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/*eslint prefer-template: 0*/
var path = require('path');
var fs = require('fs');

var webpack = require('webpack');

var nodeModules = {};

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

0 comments on commit fd336bb

Please sign in to comment.