webpack 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +2 -2
- package/lib/AmdMainTemplatePlugin.js +4 -6
- package/lib/AsyncDependencyToInitialChunkError.js +1 -3
- package/lib/Compilation.js +8 -4
- package/lib/Compiler.js +7 -10
- package/lib/ContextModule.js +19 -7
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +53 -52
- package/lib/EnvironmentPlugin.js +1 -3
- package/lib/ExternalModule.js +3 -3
- package/lib/HotUpdateChunkTemplate.js +1 -1
- package/lib/JavascriptGenerator.js +7 -7
- package/lib/JavascriptModulesPlugin.js +6 -6
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +343 -340
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/MultiModule.js +4 -1
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +9 -0
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/Parser.js +7 -3
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RecordIdsPlugin.js +2 -2
- package/lib/RuntimeTemplate.js +15 -45
- package/lib/Stats.js +2 -0
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +1 -3
- package/lib/UmdMainTemplatePlugin.js +41 -45
- package/lib/WebAssemblyParser.js +1 -5
- package/lib/WebpackOptionsApply.js +2 -2
- package/lib/WebpackOptionsDefaulter.js +10 -8
- package/lib/WebpackOptionsValidationError.js +6 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +13 -13
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +5 -11
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -6
- package/lib/dependencies/ImportParserPlugin.js +2 -6
- package/lib/dependencies/RequireIncludeDependency.js +1 -1
- package/lib/dependencies/WebpackMissingModule.js +1 -3
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +1 -3
- package/lib/optimize/ConcatenatedModule.js +19 -20
- package/lib/optimize/SplitChunksPlugin.js +30 -14
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/web/JsonpChunkTemplatePlugin.js +5 -5
- package/lib/web/JsonpMainTemplatePlugin.js +2 -2
- package/package.json +7 -6
- package/schemas/WebpackOptions.json +23 -16
- package/schemas/ajv.absolutePath.js +1 -1
package/bin/webpack.js
CHANGED
@@ -1,21 +1,80 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
+
function runCommand(command, options) {
|
3
|
+
const cp = require("child_process");
|
4
|
+
return new Promise((resolve, reject) => {
|
5
|
+
const executedCommand = cp.spawn(command, options, {
|
6
|
+
stdio: "inherit"
|
7
|
+
});
|
8
|
+
|
9
|
+
executedCommand.on("error", error => {
|
10
|
+
reject(error);
|
11
|
+
});
|
12
|
+
|
13
|
+
executedCommand.on("exit", code => {
|
14
|
+
if (code === 0) {
|
15
|
+
resolve(true);
|
16
|
+
} else {
|
17
|
+
reject();
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
21
|
+
}
|
2
22
|
|
3
23
|
let webpackCliInstalled = false;
|
4
24
|
try {
|
5
25
|
require.resolve("webpack-cli");
|
6
26
|
webpackCliInstalled = true;
|
7
|
-
} catch (
|
27
|
+
} catch (err) {
|
8
28
|
webpackCliInstalled = false;
|
9
29
|
}
|
10
30
|
|
11
|
-
if (webpackCliInstalled) {
|
12
|
-
require("
|
31
|
+
if (!webpackCliInstalled) {
|
32
|
+
const path = require("path");
|
33
|
+
const fs = require("fs");
|
34
|
+
const readLine = require("readline");
|
35
|
+
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
|
36
|
+
|
37
|
+
const packageManager = isYarn ? "yarn" : "npm";
|
38
|
+
const options = ["install", "-D", "webpack-cli"];
|
39
|
+
|
40
|
+
if (isYarn) {
|
41
|
+
options[0] = "add";
|
42
|
+
}
|
43
|
+
|
44
|
+
const commandToBeRun = `${packageManager} ${options.join(" ")}`;
|
45
|
+
|
46
|
+
const question = `Would you like to install webpack-cli? (That will run ${commandToBeRun}) `;
|
47
|
+
|
48
|
+
console.error("The CLI moved into a separate package: webpack-cli");
|
49
|
+
const questionInterface = readLine.createInterface({
|
50
|
+
input: process.stdin,
|
51
|
+
output: process.stdout
|
52
|
+
});
|
53
|
+
questionInterface.question(question, answer => {
|
54
|
+
questionInterface.close();
|
55
|
+
switch (answer.toLowerCase()) {
|
56
|
+
case "y":
|
57
|
+
case "yes":
|
58
|
+
case "1": {
|
59
|
+
runCommand(packageManager, options)
|
60
|
+
.then(result => {
|
61
|
+
return require("webpack-cli"); //eslint-disable-line
|
62
|
+
})
|
63
|
+
.catch(error => {
|
64
|
+
console.error(error);
|
65
|
+
process.exitCode = 1;
|
66
|
+
});
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
default: {
|
70
|
+
console.error(
|
71
|
+
"It needs to be installed alongside webpack to use the CLI"
|
72
|
+
);
|
73
|
+
process.exitCode = 1;
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
});
|
13
78
|
} else {
|
14
|
-
|
15
|
-
console.error(
|
16
|
-
"Please install 'webpack-cli' in addition to webpack itself to use the CLI."
|
17
|
-
);
|
18
|
-
console.error("-> When using npm: npm install webpack-cli -D");
|
19
|
-
console.error("-> When using yarn: yarn add webpack-cli -D");
|
20
|
-
process.exitCode = 1;
|
79
|
+
require("webpack-cli"); // eslint-disable-line
|
21
80
|
}
|
package/lib/APIPlugin.js
CHANGED
@@ -52,11 +52,11 @@ class APIPlugin {
|
|
52
52
|
? ParserHelpers.toConstantDependency(
|
53
53
|
parser,
|
54
54
|
REPLACEMENTS[key]
|
55
|
-
|
55
|
+
)
|
56
56
|
: ParserHelpers.toConstantDependencyWithWebpackRequire(
|
57
57
|
parser,
|
58
58
|
REPLACEMENTS[key]
|
59
|
-
|
59
|
+
)
|
60
60
|
);
|
61
61
|
parser.hooks.evaluateTypeof
|
62
62
|
.for(key)
|
@@ -36,17 +36,15 @@ class AmdMainTemplatePlugin {
|
|
36
36
|
});
|
37
37
|
|
38
38
|
return new ConcatSource(
|
39
|
-
`define(${JSON.stringify(
|
40
|
-
|
41
|
-
}) { return `,
|
39
|
+
`define(${JSON.stringify(
|
40
|
+
name
|
41
|
+
)}, ${externalsDepsArray}, function(${externalsArguments}) { return `,
|
42
42
|
source,
|
43
43
|
"});"
|
44
44
|
);
|
45
45
|
} else if (externalsArguments) {
|
46
46
|
return new ConcatSource(
|
47
|
-
`define(${externalsDepsArray}, function(${
|
48
|
-
externalsArguments
|
49
|
-
}) { return `,
|
47
|
+
`define(${externalsDepsArray}, function(${externalsArguments}) { return `,
|
50
48
|
source,
|
51
49
|
"});"
|
52
50
|
);
|
@@ -11,9 +11,7 @@ module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
|
|
11
11
|
super();
|
12
12
|
|
13
13
|
this.name = "AsyncDependencyToInitialChunkError";
|
14
|
-
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${
|
15
|
-
chunkName
|
16
|
-
}" is already used by an entrypoint.`;
|
14
|
+
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
|
17
15
|
this.module = module;
|
18
16
|
this.origin = module;
|
19
17
|
this.originLoc = loc;
|
package/lib/Compilation.js
CHANGED
@@ -158,8 +158,6 @@ class Compilation extends Tapable {
|
|
158
158
|
beforeChunkAssets: new SyncHook([]),
|
159
159
|
additionalChunkAssets: new SyncHook(["chunks"]),
|
160
160
|
|
161
|
-
records: new SyncHook(["compilation", "records"]),
|
162
|
-
|
163
161
|
additionalAssets: new AsyncSeriesHook([]),
|
164
162
|
optimizeChunkAssets: new AsyncSeriesHook(["chunks"]),
|
165
163
|
afterOptimizeChunkAssets: new SyncHook(["chunks"]),
|
@@ -253,6 +251,9 @@ class Compilation extends Tapable {
|
|
253
251
|
this.childrenCounters = {};
|
254
252
|
this.usedChunkIds = null;
|
255
253
|
this.usedModuleIds = null;
|
254
|
+
this.fileTimestamps = undefined;
|
255
|
+
this.contextTimestamps = undefined;
|
256
|
+
this.compilationDependencies = undefined;
|
256
257
|
|
257
258
|
this._buildingModules = new Map();
|
258
259
|
this._rebuildingModules = new Map();
|
@@ -277,6 +278,9 @@ class Compilation extends Tapable {
|
|
277
278
|
if (this.cache && this.cache[cacheName]) {
|
278
279
|
const cacheModule = this.cache[cacheName];
|
279
280
|
|
281
|
+
if (typeof cacheModule.updateCacheModule === "function")
|
282
|
+
cacheModule.updateCacheModule(module);
|
283
|
+
|
280
284
|
let rebuild = true;
|
281
285
|
if (this.fileTimestamps && this.contextTimestamps) {
|
282
286
|
rebuild = cacheModule.needRebuild(
|
@@ -624,12 +628,12 @@ class Compilation extends Tapable {
|
|
624
628
|
const errorAndCallback = this.bail
|
625
629
|
? err => {
|
626
630
|
callback(err);
|
627
|
-
|
631
|
+
}
|
628
632
|
: err => {
|
629
633
|
err.dependencies = [dependency];
|
630
634
|
this.errors.push(err);
|
631
635
|
callback();
|
632
|
-
|
636
|
+
};
|
633
637
|
|
634
638
|
if (
|
635
639
|
typeof dependency !== "object" ||
|
package/lib/Compiler.js
CHANGED
@@ -94,36 +94,36 @@ class Compiler extends Tapable {
|
|
94
94
|
this.resolverFactory.plugin("resolver normal", resolver => {
|
95
95
|
resolver.plugin(hook, fn);
|
96
96
|
});
|
97
|
-
}, "webpack: Using compiler.resolvers.normal is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver normal", resolver => {\n resolver.plugin(/*
|
97
|
+
}, "webpack: Using compiler.resolvers.normal is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver normal", resolver => {\n resolver.plugin(/* … */);\n}); instead.'),
|
98
98
|
apply: util.deprecate((...args) => {
|
99
99
|
this.resolverFactory.plugin("resolver normal", resolver => {
|
100
100
|
resolver.apply(...args);
|
101
101
|
});
|
102
|
-
}, "webpack: Using compiler.resolvers.normal is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver normal", resolver => {\n resolver.apply(/*
|
102
|
+
}, "webpack: Using compiler.resolvers.normal is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver normal", resolver => {\n resolver.apply(/* … */);\n}); instead.')
|
103
103
|
},
|
104
104
|
loader: {
|
105
105
|
plugins: util.deprecate((hook, fn) => {
|
106
106
|
this.resolverFactory.plugin("resolver loader", resolver => {
|
107
107
|
resolver.plugin(hook, fn);
|
108
108
|
});
|
109
|
-
}, "webpack: Using compiler.resolvers.loader is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver loader", resolver => {\n resolver.plugin(/*
|
109
|
+
}, "webpack: Using compiler.resolvers.loader is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver loader", resolver => {\n resolver.plugin(/* … */);\n}); instead.'),
|
110
110
|
apply: util.deprecate((...args) => {
|
111
111
|
this.resolverFactory.plugin("resolver loader", resolver => {
|
112
112
|
resolver.apply(...args);
|
113
113
|
});
|
114
|
-
}, "webpack: Using compiler.resolvers.loader is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver loader", resolver => {\n resolver.apply(/*
|
114
|
+
}, "webpack: Using compiler.resolvers.loader is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver loader", resolver => {\n resolver.apply(/* … */);\n}); instead.')
|
115
115
|
},
|
116
116
|
context: {
|
117
117
|
plugins: util.deprecate((hook, fn) => {
|
118
118
|
this.resolverFactory.plugin("resolver context", resolver => {
|
119
119
|
resolver.plugin(hook, fn);
|
120
120
|
});
|
121
|
-
}, "webpack: Using compiler.resolvers.context is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver context", resolver => {\n resolver.plugin(/*
|
121
|
+
}, "webpack: Using compiler.resolvers.context is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver context", resolver => {\n resolver.plugin(/* … */);\n}); instead.'),
|
122
122
|
apply: util.deprecate((...args) => {
|
123
123
|
this.resolverFactory.plugin("resolver context", resolver => {
|
124
124
|
resolver.apply(...args);
|
125
125
|
});
|
126
|
-
}, "webpack: Using compiler.resolvers.context is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver context", resolver => {\n resolver.apply(/*
|
126
|
+
}, "webpack: Using compiler.resolvers.context is deprecated.\n" + 'Use compiler.resolverFactory.plugin("resolver context", resolver => {\n resolver.apply(/* … */);\n}); instead.')
|
127
127
|
}
|
128
128
|
};
|
129
129
|
|
@@ -448,10 +448,7 @@ class Compiler extends Tapable {
|
|
448
448
|
}
|
449
449
|
|
450
450
|
createContextModuleFactory() {
|
451
|
-
const contextModuleFactory = new ContextModuleFactory(
|
452
|
-
this.resolverFactory,
|
453
|
-
this.inputFileSystem
|
454
|
-
);
|
451
|
+
const contextModuleFactory = new ContextModuleFactory(this.resolverFactory);
|
455
452
|
this.hooks.contextModuleFactory.call(contextModuleFactory);
|
456
453
|
return contextModuleFactory;
|
457
454
|
}
|
package/lib/ContextModule.js
CHANGED
@@ -43,6 +43,14 @@ class ContextModule extends Module {
|
|
43
43
|
|
44
44
|
if (typeof options.mode !== "string")
|
45
45
|
throw new Error("options.mode is a required option");
|
46
|
+
|
47
|
+
this._identifier = this._createIdentifier();
|
48
|
+
}
|
49
|
+
|
50
|
+
updateCacheModule(module) {
|
51
|
+
this.resolveDependencies = module.resolveDependencies;
|
52
|
+
this.options = module.options;
|
53
|
+
this.resolveOptions = module.resolveOptions;
|
46
54
|
}
|
47
55
|
|
48
56
|
prettyRegExp(regexString) {
|
@@ -63,7 +71,7 @@ class ContextModule extends Module {
|
|
63
71
|
.join("!");
|
64
72
|
}
|
65
73
|
|
66
|
-
|
74
|
+
_createIdentifier() {
|
67
75
|
let identifier = this.context;
|
68
76
|
if (this.options.resourceQuery)
|
69
77
|
identifier += ` ${this.options.resourceQuery}`;
|
@@ -80,6 +88,10 @@ class ContextModule extends Module {
|
|
80
88
|
return identifier;
|
81
89
|
}
|
82
90
|
|
91
|
+
identifier() {
|
92
|
+
return this._identifier;
|
93
|
+
}
|
94
|
+
|
83
95
|
readableIdentifier(requestShortener) {
|
84
96
|
let identifier = requestShortener.shorten(this.context);
|
85
97
|
if (this.options.resourceQuery)
|
@@ -281,9 +293,11 @@ class ContextModule extends Module {
|
|
281
293
|
getReturnModuleObjectSource(fakeMap, fakeMapDataExpression = "fakeMap[id]") {
|
282
294
|
if (typeof fakeMap === "number")
|
283
295
|
return `return ${this.getReturn(fakeMap)};`;
|
284
|
-
return `return ${fakeMapDataExpression} === 1 ? ${this.getReturn(
|
285
|
-
|
286
|
-
} ? ${this.getReturn(2)} : ${this.getReturn(
|
296
|
+
return `return ${fakeMapDataExpression} === 1 ? ${this.getReturn(
|
297
|
+
1
|
298
|
+
)} : ${fakeMapDataExpression} ? ${this.getReturn(2)} : ${this.getReturn(
|
299
|
+
0
|
300
|
+
)};`;
|
287
301
|
}
|
288
302
|
|
289
303
|
getSyncSource(dependencies, id) {
|
@@ -500,9 +514,7 @@ module.exports = webpackAsyncContext;`;
|
|
500
514
|
|
501
515
|
const chunksStartPosition = typeof fakeMap === "object" ? 2 : 1;
|
502
516
|
const requestPrefix = hasMultipleOrNoChunks
|
503
|
-
? `Promise.all(ids.slice(${
|
504
|
-
chunksStartPosition
|
505
|
-
}).map(__webpack_require__.e))`
|
517
|
+
? `Promise.all(ids.slice(${chunksStartPosition}).map(__webpack_require__.e))`
|
506
518
|
: `__webpack_require__.e(ids[${chunksStartPosition}])`;
|
507
519
|
const returnModuleObject = this.getReturnModuleObjectSource(
|
508
520
|
fakeMap,
|
package/lib/DefinePlugin.js
CHANGED
@@ -112,7 +112,7 @@ class DefinePlugin {
|
|
112
112
|
? ParserHelpers.toConstantDependencyWithWebpackRequire(
|
113
113
|
parser,
|
114
114
|
code
|
115
|
-
|
115
|
+
)
|
116
116
|
: ParserHelpers.toConstantDependency(parser, code)
|
117
117
|
);
|
118
118
|
}
|
@@ -164,7 +164,7 @@ class DefinePlugin {
|
|
164
164
|
? ParserHelpers.toConstantDependencyWithWebpackRequire(
|
165
165
|
parser,
|
166
166
|
code
|
167
|
-
|
167
|
+
)
|
168
168
|
: ParserHelpers.toConstantDependency(parser, code)
|
169
169
|
);
|
170
170
|
parser.hooks.typeof
|
package/lib/Dependency.js
CHANGED
@@ -1,52 +1,53 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
const compareLocations = require("./compareLocations");
|
7
|
-
|
8
|
-
class Dependency {
|
9
|
-
constructor() {
|
10
|
-
this.module = null;
|
11
|
-
this.weak = false;
|
12
|
-
this.optional = false;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
return
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
const compareLocations = require("./compareLocations");
|
7
|
+
|
8
|
+
class Dependency {
|
9
|
+
constructor() {
|
10
|
+
this.module = null;
|
11
|
+
this.weak = false;
|
12
|
+
this.optional = false;
|
13
|
+
this.loc = undefined;
|
14
|
+
}
|
15
|
+
|
16
|
+
getResourceIdentifier() {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
// Returns the referenced module and export
|
21
|
+
getReference() {
|
22
|
+
if (!this.module) return null;
|
23
|
+
return {
|
24
|
+
module: this.module,
|
25
|
+
weak: this.weak,
|
26
|
+
importedNames: true // true: full object, false: only sideeffects/no export, array of strings: the exports with this names
|
27
|
+
};
|
28
|
+
}
|
29
|
+
|
30
|
+
// Returns the exported names
|
31
|
+
getExports() {
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
|
35
|
+
getWarnings() {
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
|
39
|
+
getErrors() {
|
40
|
+
return null;
|
41
|
+
}
|
42
|
+
|
43
|
+
updateHash(hash) {
|
44
|
+
hash.update((this.module && this.module.id) + "");
|
45
|
+
}
|
46
|
+
|
47
|
+
disconnect() {
|
48
|
+
this.module = null;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
Dependency.compare = (a, b) => compareLocations(a.loc, b.loc);
|
52
|
+
|
53
|
+
module.exports = Dependency;
|
package/lib/EnvironmentPlugin.js
CHANGED
@@ -42,9 +42,7 @@ class EnvironmentPlugin {
|
|
42
42
|
if (value === undefined) {
|
43
43
|
compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
|
44
44
|
const error = new Error(
|
45
|
-
`EnvironmentPlugin - ${
|
46
|
-
key
|
47
|
-
} environment variable is undefined.\n\n` +
|
45
|
+
`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
|
48
46
|
"You can pass an object with default values to suppress this warning.\n" +
|
49
47
|
"See https://webpack.js.org/plugins/environment-plugin for example."
|
50
48
|
);
|
package/lib/ExternalModule.js
CHANGED
@@ -76,9 +76,9 @@ class ExternalModule extends Module {
|
|
76
76
|
}
|
77
77
|
|
78
78
|
checkExternalVariable(variableToCheck, request) {
|
79
|
-
return `if(typeof ${
|
80
|
-
|
81
|
-
|
79
|
+
return `if(typeof ${variableToCheck} === 'undefined') {${WebpackMissingModule.moduleCode(
|
80
|
+
request
|
81
|
+
)}}\n`;
|
82
82
|
}
|
83
83
|
|
84
84
|
getSourceForAmdOrUmdExternal(id, optional, request) {
|
@@ -47,7 +47,7 @@ module.exports = class HotUpdateChunkTemplate extends Tapable {
|
|
47
47
|
hotUpdateChunk.removedModules = removedModules;
|
48
48
|
const modulesSource = Template.renderChunkModules(
|
49
49
|
hotUpdateChunk,
|
50
|
-
|
50
|
+
m => typeof m.source === "function",
|
51
51
|
moduleTemplate,
|
52
52
|
dependencyTemplates
|
53
53
|
);
|
@@ -83,9 +83,9 @@ class JavascriptGenerator {
|
|
83
83
|
* we can not inject "foo" twice, therefore we just make two IIFEs like so:
|
84
84
|
* (function(foo, bar, baz){
|
85
85
|
* (function(foo, some, more){
|
86
|
-
*
|
87
|
-
* }(
|
88
|
-
* }(
|
86
|
+
* …
|
87
|
+
* }(…));
|
88
|
+
* }(…));
|
89
89
|
*
|
90
90
|
* "splitVariablesInUniqueNamedChunks" splits the variables shown above up to this:
|
91
91
|
* [[foo, bar, baz], [foo, some, more]]
|
@@ -177,8 +177,8 @@ class JavascriptGenerator {
|
|
177
177
|
|
178
178
|
/*
|
179
179
|
* creates the start part of a IIFE around the module to inject a variable name
|
180
|
-
* (function(
|
181
|
-
* }.call(
|
180
|
+
* (function(…){ <- this part
|
181
|
+
* }.call(…))
|
182
182
|
*/
|
183
183
|
variableInjectionFunctionWrapperStartCode(varNames) {
|
184
184
|
const args = varNames.join(", ");
|
@@ -194,8 +194,8 @@ class JavascriptGenerator {
|
|
194
194
|
|
195
195
|
/*
|
196
196
|
* creates the end part of a IIFE around the module to inject a variable name
|
197
|
-
* (function(
|
198
|
-
* }.call(
|
197
|
+
* (function(…){
|
198
|
+
* }.call(…)) <- this part
|
199
199
|
*/
|
200
200
|
variableInjectionFunctionWrapperEndCode(module, varExpressions, block) {
|
201
201
|
const firstParam = this.contextArgument(module, block);
|
@@ -32,18 +32,18 @@ class JavascriptModulesPlugin {
|
|
32
32
|
});
|
33
33
|
normalModuleFactory.hooks.createGenerator
|
34
34
|
.for("javascript/auto")
|
35
|
-
.tap("JavascriptModulesPlugin",
|
36
|
-
return new JavascriptGenerator(
|
35
|
+
.tap("JavascriptModulesPlugin", () => {
|
36
|
+
return new JavascriptGenerator();
|
37
37
|
});
|
38
38
|
normalModuleFactory.hooks.createGenerator
|
39
39
|
.for("javascript/dynamic")
|
40
|
-
.tap("JavascriptModulesPlugin",
|
41
|
-
return new JavascriptGenerator(
|
40
|
+
.tap("JavascriptModulesPlugin", () => {
|
41
|
+
return new JavascriptGenerator();
|
42
42
|
});
|
43
43
|
normalModuleFactory.hooks.createGenerator
|
44
44
|
.for("javascript/esm")
|
45
|
-
.tap("JavascriptModulesPlugin",
|
46
|
-
return new JavascriptGenerator(
|
45
|
+
.tap("JavascriptModulesPlugin", () => {
|
46
|
+
return new JavascriptGenerator();
|
47
47
|
});
|
48
48
|
compilation.mainTemplate.hooks.renderManifest.tap(
|
49
49
|
"JavascriptModulesPlugin",
|
package/lib/MainTemplate.js
CHANGED
@@ -179,7 +179,7 @@ module.exports = class MainTemplate extends Tapable {
|
|
179
179
|
"if(threw) delete installedModules[moduleId];"
|
180
180
|
]),
|
181
181
|
"}"
|
182
|
-
|
182
|
+
]
|
183
183
|
: [
|
184
184
|
"// Execute the module function",
|
185
185
|
`modules[moduleId].call(module.exports, module, module.exports, ${this.renderRequireFunctionForModule(
|
@@ -187,7 +187,7 @@ module.exports = class MainTemplate extends Tapable {
|
|
187
187
|
chunk,
|
188
188
|
"moduleId"
|
189
189
|
)});`
|
190
|
-
|
190
|
+
]
|
191
191
|
),
|
192
192
|
"",
|
193
193
|
"// Flag the module as loaded",
|