From 37e0febde9a61a065154535a82cddd2ed46af113 Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Fri, 27 Oct 2017 16:16:23 +0200 Subject: [PATCH] fix(build-config): inline core-js polyfills in bundled Node.js code --- packages/build-config/configs/node.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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')