From 51e5f8d8b2371f79a99a4eab9e5236fe6ba3aff0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 30 Jul 2018 12:57:58 -0400 Subject: [PATCH] Revert ".embark/versions modules" --- lib/pipeline/webpackProcess.js | 123 +++++++++++++++++---------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/lib/pipeline/webpackProcess.js b/lib/pipeline/webpackProcess.js index 32e579fb..30c7ddc2 100644 --- a/lib/pipeline/webpackProcess.js +++ b/lib/pipeline/webpackProcess.js @@ -6,7 +6,6 @@ const constants = require('../constants'); const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const ProcessWrapper = require('../core/processes/processWrapper'); const path = require('path'); -const glob = require('glob'); let webpackProcess; @@ -88,9 +87,22 @@ class WebpackProcess extends ProcessWrapper { [{test: /app[\\/]|contracts[\\/]/}] ) ] - }; + }, + plugins: [ + new HardSourceWebpackPlugin({ + cacheDirectory: fs.dappPath('node_modules/.cache/hard-source'), + // ufglify (wp mode: production) will still save its cache in embark's node_modules/.cache/ + environmentHash: { + root: fs.dappPath() + } + }), + new HardSourceWebpackPlugin.ExcludeModulePlugin( + [{test: /app[\\/]|contracts[\\/]/}] + ) + ] + }; - let webpackOptions = utils.recursiveMerge(defaultOptions, options); + let webpackOptions = utils.recursiveMerge(defaultOptions, options); if (includeModules) { webpackOptions.module = { @@ -120,15 +132,6 @@ class WebpackProcess extends ProcessWrapper { 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: [ @@ -151,57 +154,57 @@ class WebpackProcess extends ProcessWrapper { compact: false } } - ] - }; + } + ] + }; - let dappBabelrc = path.join(realCwd, '.babelrc'); - if (fs.existsSync(dappBabelrc)) { - webpackOptions.module.rules[3].options.extends = dappBabelrc; - } + let dappBabelrc = path.join(realCwd, '.babelrc'); + if (fs.existsSync(dappBabelrc)) { + webpackOptions.module.rules[3].options.extends = dappBabelrc; } + } - webpack(webpackOptions).run((err, stats) => { - async.waterfall([ - function checkStatsError(next) { - if (err) { - console.error(err); - return next(err); - } - if (!detectErrors) { - return next(); - } - if (stats.hasErrors()) { - return next( - stats.toJson(webpackOptions.stats).errors.join("\n") - ); - } - next(); - }//, - // function writeStatsReport(next) { - // if (detectErrors) { - // self._log('info', 'writing file '+ ('.embark/stats.report').bold.dim); - // } - // fs.writeFile( - // path.join(fs.dappPath('.embark'), 'stats.report'), - // stats.toString(webpackOptions.stats), - // next - // ); - // }, - // function writeStatsJSON(next) { - // if (detectErrors) { - // self._log('info','writing file '+ ('.embark/stats.json').bold.dim); - // } - // fs.writeFile( - // path.join(fs.dappPath('.embark'), 'stats.json'), - // JSON.stringify(stats.toJson(webpackOptions.stats)), - // next - // ); - // } - // note: to visualize the stats info in a browser, do... - // `npx webpack-bundle-analyzer /.embark/stats.json` - ], (err) => { - callback(err); - }); + webpack(webpackOptions).run((err, stats) => { + async.waterfall([ + function checkStatsError(next) { + if (err) { + console.error(err); + return next(err); + } + if (!detectErrors) { + return next(); + } + if (stats.hasErrors()) { + return next( + stats.toJson(webpackOptions.stats).errors.join("\n") + ); + } + next(); + }//, + // function writeStatsReport(next) { + // if (detectErrors) { + // self._log('info', 'writing file '+ ('.embark/stats.report').bold.dim); + // } + // fs.writeFile( + // path.join(fs.dappPath('.embark'), 'stats.report'), + // stats.toString(webpackOptions.stats), + // next + // ); + // }, + // function writeStatsJSON(next) { + // if (detectErrors) { + // self._log('info','writing file '+ ('.embark/stats.json').bold.dim); + // } + // fs.writeFile( + // path.join(fs.dappPath('.embark'), 'stats.json'), + // JSON.stringify(stats.toJson(webpackOptions.stats)), + // next + // ); + // } + // note: to visualize the stats info in a browser, do... + // `npx webpack-bundle-analyzer /.embark/stats.json` + ], (err) => { + callback(err); }); }); }