diff --git a/lib/pipeline/webpackProcess.js b/lib/pipeline/webpackProcess.js index b06460e9c..e6b45f290 100644 --- a/lib/pipeline/webpackProcess.js +++ b/lib/pipeline/webpackProcess.js @@ -36,13 +36,20 @@ class WebpackProcess extends ProcessWrapper { } webpackRun(filename, options, includeModules, importsList, detectErrors, realCwd, callback) { + const self = this; let defaultOptions = { + mode: self.env === 'development' ? 'none' : 'production', entry: fs.dappPath(filename), output: { + globalObject: 'typeof self !== \'undefined\' ? self : this', + libraryExport: 'default', libraryTarget: 'umd', path: fs.dappPath('.embark'), - filename: filename + filename: filename, + umdNamedDefine: true }, + profile: true, + stats: 'verbose', resolve: { alias: importsList, modules: [ @@ -86,17 +93,40 @@ class WebpackProcess extends ProcessWrapper { loader: "babel-loader", exclude: /(node_modules|bower_components)/, options: { - extends: path.join(realCwd, '.babelrc'), - presets: ['babel-preset-es2016', 'babel-preset-es2017', 'babel-preset-react'].map(require.resolve), - plugins: ["babel-plugin-webpack-aliases"].map(require.resolve), + presets: [ + [ + "@babel/preset-env", { + modules: false, + targets: { + browsers: ["last 1 version", "not dead", "> 0.2%"] + } + } + ], + "@babel/preset-react" + ].map(pkg => { + if (Array.isArray(pkg)) { + let _pkg = pkg[0]; + pkg[0] = require.resolve(_pkg); + return pkg; + } else { + return require.resolve(pkg); + } + }), + plugins: [ + "@babel/plugin-transform-runtime", + "babel-plugin-webpack-aliases" + ].map(require.resolve), compact: false } } ] }; - } + let dappBabelrc = path.join(realCwd, '.babelrc'); + if (fs.existsSync(dappBabelrc)) { + webpackOptions.module.rules[3].options.extends = dappBabelrc; } + } webpack(webpackOptions).run((err, stats) => { async.waterfall([