From ebb245a78662917787e739dce3cc61e0da0971ca Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 4 Sep 2018 18:09:17 +0100 Subject: [PATCH] fix(NA): raw alias config. --- src/optimize/base_optimizer.js | 1 - .../dynamic_dll_plugin/dll_compiler.js | 24 +++---------------- .../dynamic_dll_plugin/dll_config_model.js | 8 +++---- .../dynamic_dll_plugin/dynamic_dll_plugin.js | 7 +++--- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/optimize/base_optimizer.js b/src/optimize/base_optimizer.js index d93c553209a4..2e6d2c246e3f 100644 --- a/src/optimize/base_optimizer.js +++ b/src/optimize/base_optimizer.js @@ -208,7 +208,6 @@ export default class BaseOptimizer { plugins: [ new DynamicDllPlugin({ - uiBundles: this.uiBundles, log: this.log }), diff --git a/src/optimize/dynamic_dll_plugin/dll_compiler.js b/src/optimize/dynamic_dll_plugin/dll_compiler.js index 06df4905743f..8ee280ec5919 100644 --- a/src/optimize/dynamic_dll_plugin/dll_compiler.js +++ b/src/optimize/dynamic_dll_plugin/dll_compiler.js @@ -32,9 +32,8 @@ const existsAsync = promisify(fs.exists); const writeFileAsync = promisify(fs.writeFile); export class DllCompiler { - static getRawDllConfig(alias = []) { + static getRawDllConfig() { return { - alias, context: fromRoot('.'), entryName: 'vendors', dllName: '[name]', @@ -49,11 +48,8 @@ export class DllCompiler { }; } - constructor(uiBundles, log) { - this.uiBundles = uiBundles; - this.rawDllConfig = DllCompiler.getRawDllConfig( - uiBundles.getAliases() - ); + constructor(log) { + this.rawDllConfig = DllCompiler.getRawDllConfig(); this.log = log || (() => null); } @@ -72,12 +68,6 @@ export class DllCompiler { await writeFileAsync(filePath, content, 'utf8'); } - getDllPath() { - return this.resolvePath( - `${this.rawDllConfig.entryName}${this.rawDllConfig.dllExt}` - ); - } - getEntryPath() { return this.resolvePath( `${this.rawDllConfig.entryName}${this.rawDllConfig.entryExt}` @@ -136,14 +126,6 @@ export class DllCompiler { await this.ensurePathExists(this.rawDllConfig.outputPath); } - dllExistsSync() { - return this.existsSync(this.getDllPath()); - } - - existsSync(filePath) { - return fs.existsSync(filePath); - } - resolvePath() { return path.resolve(this.rawDllConfig.outputPath, ...arguments); } diff --git a/src/optimize/dynamic_dll_plugin/dll_config_model.js b/src/optimize/dynamic_dll_plugin/dll_config_model.js index 5e0d2a5e7c58..72de12b84e9d 100644 --- a/src/optimize/dynamic_dll_plugin/dll_config_model.js +++ b/src/optimize/dynamic_dll_plugin/dll_config_model.js @@ -25,7 +25,6 @@ import UglifyJsPlugin from 'uglifyjs-webpack-plugin'; function generateDLL(config) { const { - dllAlias, dllContext, dllEntry, dllOutputPath, @@ -49,7 +48,10 @@ function generateDLL(config) { resolve: { extensions: ['.js', '.json'], mainFields: ['browser', 'browserify', 'main'], - alias: dllAlias + alias: { + moment$: require.resolve(dllContext + '/webpackShims/moment'), + 'moment-timezone$': require.resolve(dllContext + '/webpackShims/moment-timezone') + } }, module: { rules: [ @@ -91,7 +93,6 @@ function generateDLL(config) { function extendRawConfig(rawConfig) { // Build all extended configs from raw config - const dllAlias = rawConfig.alias; const dllContext = rawConfig.context; const dllEntry = {}; const dllEntryName = rawConfig.entryName; @@ -115,7 +116,6 @@ function extendRawConfig(rawConfig) { // Export dll config map return { - dllAlias, dllContext, dllEntry, dllOutputPath, diff --git a/src/optimize/dynamic_dll_plugin/dynamic_dll_plugin.js b/src/optimize/dynamic_dll_plugin/dynamic_dll_plugin.js index 7f7814730652..4dbc8a69ff60 100644 --- a/src/optimize/dynamic_dll_plugin/dynamic_dll_plugin.js +++ b/src/optimize/dynamic_dll_plugin/dynamic_dll_plugin.js @@ -37,9 +37,9 @@ function inPluginNodeModules(checkPath) { } export class DynamicDllPlugin { - constructor({ uiBundles, log }) { + constructor({ log }) { this.log = log || (() => null); - this.dllCompiler = new DllCompiler(uiBundles, log); + this.dllCompiler = new DllCompiler(log); this.entryPaths = ''; this.afterCompilationEntryPaths = ''; } @@ -145,8 +145,7 @@ export class DynamicDllPlugin { } this.afterCompilationEntryPaths = requires.sort().join('\n'); - compilation.needsDLLCompilation = (this.afterCompilationEntryPaths !== this.entryPaths) - || !this.dllCompiler.dllExistsSync(); + compilation.needsDLLCompilation = (this.afterCompilationEntryPaths !== this.entryPaths); this.entryPaths = this.afterCompilationEntryPaths; this.log(