Skip to content

Commit

Permalink
fix(build-config): inline core-js polyfills in bundled Node.js code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd authored and dmbch committed Nov 22, 2017
1 parent a752635 commit 37e0feb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/build-config/configs/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var findUp = require('find-up');

var hopsConfig = require('hops-config');

var checkEsnext = require('../lib/check-esnext');

function findNodeModules (start) {
var modulesDir = findUp.sync('node_modules', { cwd: start });
var files = fs.readdirSync(modulesDir);
Expand All @@ -19,6 +21,12 @@ function findNodeModules (start) {
return modulesDir;
}

function shouldIncludeExternalModuleInBundle (module) {
return module.indexOf('core-js') === 0 ||
module.indexOf('babel-polyfill') === 0 ||
checkEsnext(module);
}

var modulesDir = findNodeModules(process.cwd());

module.exports = {
Expand All @@ -36,7 +44,7 @@ module.exports = {
resolve: require('../sections/resolve')('node'),
externals: [require('webpack-node-externals')({
modulesDir: modulesDir,
whitelist: require('../lib/check-esnext')
whitelist: shouldIncludeExternalModuleInBundle
})],
module: {
rules: require('../sections/module-rules')('node')
Expand Down

0 comments on commit 37e0feb

Please sign in to comment.