fix(NA): raw alias config.

This commit is contained in:
Tiago Costa 2018-09-04 18:09:17 +01:00
parent 389715d279
commit ebb245a786
No known key found for this signature in database
GPG key ID: BAECC2D04A04C6EA
4 changed files with 10 additions and 30 deletions

View file

@ -208,7 +208,6 @@ export default class BaseOptimizer {
plugins: [
new DynamicDllPlugin({
uiBundles: this.uiBundles,
log: this.log
}),

View file

@ -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);
}

View file

@ -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,

View file

@ -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(