diff --git a/packages/build-config/configs/node.js b/packages/build-config/configs/node.js index ccf3060a6..fda659dfa 100644 --- a/packages/build-config/configs/node.js +++ b/packages/build-config/configs/node.js @@ -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); @@ -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 = { @@ -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')