webpack 4.41.6 → 4.42.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/declarations/WebpackOptions.d.ts +1 -1
- package/lib/ConstPlugin.js +5 -0
- package/lib/DllPlugin.js +2 -2
- package/lib/FlagAllModulesAsUsedPlugin.js +38 -0
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Parser.js +21 -8
- package/lib/optimize/ConcatenatedModule.js +132 -159
- package/package.json +1 -1
- package/schemas/WebpackOptions.json +2 -10
@@ -1118,7 +1118,7 @@ export interface OutputOptions {
|
|
1118
1118
|
/**
|
1119
1119
|
* The filename of the Hot Update Chunks. They are inside the output.path directory.
|
1120
1120
|
*/
|
1121
|
-
hotUpdateChunkFilename?: string
|
1121
|
+
hotUpdateChunkFilename?: string;
|
1122
1122
|
/**
|
1123
1123
|
* The JSONP function used by webpack for async loading of hot update chunks.
|
1124
1124
|
*/
|
package/lib/ConstPlugin.js
CHANGED
@@ -119,6 +119,7 @@ class ConstPlugin {
|
|
119
119
|
|
120
120
|
const handler = parser => {
|
121
121
|
parser.hooks.statementIf.tap("ConstPlugin", statement => {
|
122
|
+
if (parser.scope.isAsmJs) return;
|
122
123
|
const param = parser.evaluateExpression(statement.test);
|
123
124
|
const bool = param.asBool();
|
124
125
|
if (typeof bool === "boolean") {
|
@@ -189,6 +190,7 @@ class ConstPlugin {
|
|
189
190
|
parser.hooks.expressionConditionalOperator.tap(
|
190
191
|
"ConstPlugin",
|
191
192
|
expression => {
|
193
|
+
if (parser.scope.isAsmJs) return;
|
192
194
|
const param = parser.evaluateExpression(expression.test);
|
193
195
|
const bool = param.asBool();
|
194
196
|
if (typeof bool === "boolean") {
|
@@ -224,6 +226,7 @@ class ConstPlugin {
|
|
224
226
|
parser.hooks.expressionLogicalOperator.tap(
|
225
227
|
"ConstPlugin",
|
226
228
|
expression => {
|
229
|
+
if (parser.scope.isAsmJs) return;
|
227
230
|
if (
|
228
231
|
expression.operator === "&&" ||
|
229
232
|
expression.operator === "||"
|
@@ -309,6 +312,7 @@ class ConstPlugin {
|
|
309
312
|
parser.hooks.evaluateIdentifier
|
310
313
|
.for("__resourceQuery")
|
311
314
|
.tap("ConstPlugin", expr => {
|
315
|
+
if (parser.scope.isAsmJs) return;
|
312
316
|
if (!parser.state.module) return;
|
313
317
|
return ParserHelpers.evaluateToString(
|
314
318
|
getQuery(parser.state.module.resource)
|
@@ -317,6 +321,7 @@ class ConstPlugin {
|
|
317
321
|
parser.hooks.expression
|
318
322
|
.for("__resourceQuery")
|
319
323
|
.tap("ConstPlugin", () => {
|
324
|
+
if (parser.scope.isAsmJs) return;
|
320
325
|
if (!parser.state.module) return;
|
321
326
|
parser.state.current.addVariable(
|
322
327
|
"__resourceQuery",
|
package/lib/DllPlugin.js
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const DllEntryPlugin = require("./DllEntryPlugin");
|
8
|
+
const FlagAllModulesAsUsedPlugin = require("./FlagAllModulesAsUsedPlugin");
|
8
9
|
const LibManifestPlugin = require("./LibManifestPlugin");
|
9
|
-
const FlagInitialModulesAsUsedPlugin = require("./FlagInitialModulesAsUsedPlugin");
|
10
10
|
|
11
11
|
const validateOptions = require("schema-utils");
|
12
12
|
const schema = require("../schemas/plugins/DllPlugin.json");
|
@@ -41,7 +41,7 @@ class DllPlugin {
|
|
41
41
|
});
|
42
42
|
new LibManifestPlugin(this.options).apply(compiler);
|
43
43
|
if (!this.options.entryOnly) {
|
44
|
-
new
|
44
|
+
new FlagAllModulesAsUsedPlugin("DllPlugin").apply(compiler);
|
45
45
|
}
|
46
46
|
}
|
47
47
|
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/** @typedef {import("./Compiler")} Compiler */
|
9
|
+
|
10
|
+
class FlagAllModulesAsUsedPlugin {
|
11
|
+
constructor(explanation) {
|
12
|
+
this.explanation = explanation;
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @param {Compiler} compiler webpack compiler
|
17
|
+
* @returns {void}
|
18
|
+
*/
|
19
|
+
apply(compiler) {
|
20
|
+
compiler.hooks.compilation.tap(
|
21
|
+
"FlagAllModulesAsUsedPlugin",
|
22
|
+
compilation => {
|
23
|
+
compilation.hooks.optimizeDependencies.tap(
|
24
|
+
"FlagAllModulesAsUsedPlugin",
|
25
|
+
modules => {
|
26
|
+
for (const module of modules) {
|
27
|
+
module.used = true;
|
28
|
+
module.usedExports = true;
|
29
|
+
module.addReason(null, null, this.explanation);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
);
|
33
|
+
}
|
34
|
+
);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
module.exports = FlagAllModulesAsUsedPlugin;
|
package/lib/Parser.js
CHANGED
@@ -1229,7 +1229,7 @@ class Parser extends Tapable {
|
|
1229
1229
|
this.walkPattern(param);
|
1230
1230
|
}
|
1231
1231
|
if (statement.body.type === "BlockStatement") {
|
1232
|
-
this.
|
1232
|
+
this.detectMode(statement.body.body);
|
1233
1233
|
this.prewalkStatement(statement.body);
|
1234
1234
|
this.walkStatement(statement.body);
|
1235
1235
|
} else {
|
@@ -1697,7 +1697,7 @@ class Parser extends Tapable {
|
|
1697
1697
|
this.walkPattern(param);
|
1698
1698
|
}
|
1699
1699
|
if (expression.body.type === "BlockStatement") {
|
1700
|
-
this.
|
1700
|
+
this.detectMode(expression.body.body);
|
1701
1701
|
this.prewalkStatement(expression.body);
|
1702
1702
|
this.walkStatement(expression.body);
|
1703
1703
|
} else {
|
@@ -1713,7 +1713,7 @@ class Parser extends Tapable {
|
|
1713
1713
|
this.walkPattern(param);
|
1714
1714
|
}
|
1715
1715
|
if (expression.body.type === "BlockStatement") {
|
1716
|
-
this.
|
1716
|
+
this.detectMode(expression.body.body);
|
1717
1717
|
this.prewalkStatement(expression.body);
|
1718
1718
|
this.walkStatement(expression.body);
|
1719
1719
|
} else {
|
@@ -1894,6 +1894,7 @@ class Parser extends Tapable {
|
|
1894
1894
|
this.scope.renames.set(params[i].name, param);
|
1895
1895
|
}
|
1896
1896
|
if (functionExpression.body.type === "BlockStatement") {
|
1897
|
+
this.detectMode(functionExpression.body.body);
|
1897
1898
|
this.prewalkStatement(functionExpression.body);
|
1898
1899
|
this.walkStatement(functionExpression.body);
|
1899
1900
|
} else {
|
@@ -2001,6 +2002,7 @@ class Parser extends Tapable {
|
|
2001
2002
|
inTry: false,
|
2002
2003
|
inShorthand: false,
|
2003
2004
|
isStrict: oldScope.isStrict,
|
2005
|
+
isAsmJs: oldScope.isAsmJs,
|
2004
2006
|
definitions: oldScope.definitions.createChild(),
|
2005
2007
|
renames: oldScope.renames.createChild()
|
2006
2008
|
};
|
@@ -2024,6 +2026,7 @@ class Parser extends Tapable {
|
|
2024
2026
|
inTry: false,
|
2025
2027
|
inShorthand: false,
|
2026
2028
|
isStrict: oldScope.isStrict,
|
2029
|
+
isAsmJs: oldScope.isAsmJs,
|
2027
2030
|
definitions: oldScope.definitions.createChild(),
|
2028
2031
|
renames: oldScope.renames.createChild()
|
2029
2032
|
};
|
@@ -2049,6 +2052,7 @@ class Parser extends Tapable {
|
|
2049
2052
|
inTry: oldScope.inTry,
|
2050
2053
|
inShorthand: false,
|
2051
2054
|
isStrict: oldScope.isStrict,
|
2055
|
+
isAsmJs: oldScope.isAsmJs,
|
2052
2056
|
definitions: oldScope.definitions.createChild(),
|
2053
2057
|
renames: oldScope.renames.createChild()
|
2054
2058
|
};
|
@@ -2058,15 +2062,23 @@ class Parser extends Tapable {
|
|
2058
2062
|
this.scope = oldScope;
|
2059
2063
|
}
|
2060
2064
|
|
2065
|
+
// TODO webpack 5: remove this methods
|
2066
|
+
// only for backward-compat
|
2061
2067
|
detectStrictMode(statements) {
|
2062
|
-
|
2068
|
+
this.detectMode(statements);
|
2069
|
+
}
|
2070
|
+
|
2071
|
+
detectMode(statements) {
|
2072
|
+
const isLiteral =
|
2063
2073
|
statements.length >= 1 &&
|
2064
2074
|
statements[0].type === "ExpressionStatement" &&
|
2065
|
-
statements[0].expression.type === "Literal"
|
2066
|
-
|
2067
|
-
if (isStrict) {
|
2075
|
+
statements[0].expression.type === "Literal";
|
2076
|
+
if (isLiteral && statements[0].expression.value === "use strict") {
|
2068
2077
|
this.scope.isStrict = true;
|
2069
2078
|
}
|
2079
|
+
if (isLiteral && statements[0].expression.value === "use asm") {
|
2080
|
+
this.scope.isAsmJs = true;
|
2081
|
+
}
|
2070
2082
|
}
|
2071
2083
|
|
2072
2084
|
enterPatterns(patterns, onIdent) {
|
@@ -2272,13 +2284,14 @@ class Parser extends Tapable {
|
|
2272
2284
|
inTry: false,
|
2273
2285
|
inShorthand: false,
|
2274
2286
|
isStrict: false,
|
2287
|
+
isAsmJs: false,
|
2275
2288
|
definitions: new StackedSetMap(),
|
2276
2289
|
renames: new StackedSetMap()
|
2277
2290
|
};
|
2278
2291
|
const state = (this.state = initialState || {});
|
2279
2292
|
this.comments = comments;
|
2280
2293
|
if (this.hooks.program.call(ast, comments) === undefined) {
|
2281
|
-
this.
|
2294
|
+
this.detectMode(ast.body);
|
2282
2295
|
this.prewalkStatements(ast.body);
|
2283
2296
|
this.blockPrewalkStatements(ast.body);
|
2284
2297
|
this.walkStatements(ast.body);
|
@@ -22,6 +22,23 @@ const createHash = require("../util/createHash");
|
|
22
22
|
/** @typedef {import("../Dependency")} Dependency */
|
23
23
|
/** @typedef {import("../Compilation")} Compilation */
|
24
24
|
/** @typedef {import("../util/createHash").Hash} Hash */
|
25
|
+
/** @typedef {import("../RequestShortener")} RequestShortener */
|
26
|
+
|
27
|
+
const joinIterableWithComma = iterable => {
|
28
|
+
// This is more performant than Array.from().join(", ")
|
29
|
+
// as it doesn't create an array
|
30
|
+
let str = "";
|
31
|
+
let first = true;
|
32
|
+
for (const item of iterable) {
|
33
|
+
if (first) {
|
34
|
+
first = false;
|
35
|
+
} else {
|
36
|
+
str += ", ";
|
37
|
+
}
|
38
|
+
str += item;
|
39
|
+
}
|
40
|
+
return str;
|
41
|
+
};
|
25
42
|
|
26
43
|
/**
|
27
44
|
* @typedef {Object} ConcatenationEntry
|
@@ -287,6 +304,41 @@ const getPathInAst = (ast, node) => {
|
|
287
304
|
}
|
288
305
|
};
|
289
306
|
|
307
|
+
const getHarmonyExportImportedSpecifierDependencyExports = dep => {
|
308
|
+
const importModule = dep._module;
|
309
|
+
if (!importModule) return [];
|
310
|
+
if (dep._id) {
|
311
|
+
// export { named } from "module"
|
312
|
+
return [
|
313
|
+
{
|
314
|
+
name: dep.name,
|
315
|
+
id: dep._id,
|
316
|
+
module: importModule
|
317
|
+
}
|
318
|
+
];
|
319
|
+
}
|
320
|
+
if (dep.name) {
|
321
|
+
// export * as abc from "module"
|
322
|
+
return [
|
323
|
+
{
|
324
|
+
name: dep.name,
|
325
|
+
id: true,
|
326
|
+
module: importModule
|
327
|
+
}
|
328
|
+
];
|
329
|
+
}
|
330
|
+
// export * from "module"
|
331
|
+
return importModule.buildMeta.providedExports
|
332
|
+
.filter(exp => exp !== "default" && !dep.activeExports.has(exp))
|
333
|
+
.map(exp => {
|
334
|
+
return {
|
335
|
+
name: exp,
|
336
|
+
id: exp,
|
337
|
+
module: importModule
|
338
|
+
};
|
339
|
+
});
|
340
|
+
};
|
341
|
+
|
290
342
|
class ConcatenatedModule extends Module {
|
291
343
|
constructor(rootModule, modules, concatenationList) {
|
292
344
|
super("javascript/esm", null);
|
@@ -626,10 +678,7 @@ class ConcatenatedModule extends Module {
|
|
626
678
|
);
|
627
679
|
innerDependencyTemplates.set(
|
628
680
|
HarmonyExportSpecifierDependency,
|
629
|
-
new
|
630
|
-
dependencyTemplates.get(HarmonyExportSpecifierDependency),
|
631
|
-
this.rootModule
|
632
|
-
)
|
681
|
+
new NullTemplate()
|
633
682
|
);
|
634
683
|
innerDependencyTemplates.set(
|
635
684
|
HarmonyExportExpressionDependency,
|
@@ -640,19 +689,11 @@ class ConcatenatedModule extends Module {
|
|
640
689
|
);
|
641
690
|
innerDependencyTemplates.set(
|
642
691
|
HarmonyExportImportedSpecifierDependency,
|
643
|
-
new
|
644
|
-
dependencyTemplates.get(HarmonyExportImportedSpecifierDependency),
|
645
|
-
this.rootModule,
|
646
|
-
moduleToInfoMap
|
647
|
-
)
|
692
|
+
new NullTemplate()
|
648
693
|
);
|
649
694
|
innerDependencyTemplates.set(
|
650
695
|
HarmonyCompatibilityDependency,
|
651
|
-
new
|
652
|
-
dependencyTemplates.get(HarmonyCompatibilityDependency),
|
653
|
-
this.rootModule,
|
654
|
-
moduleToInfoMap
|
655
|
-
)
|
696
|
+
new NullTemplate()
|
656
697
|
);
|
657
698
|
|
658
699
|
// Must use full identifier in our cache here to ensure that the source
|
@@ -1105,11 +1146,62 @@ class ConcatenatedModule extends Module {
|
|
1105
1146
|
}
|
1106
1147
|
}
|
1107
1148
|
|
1149
|
+
// Map with all root exposed used exports
|
1150
|
+
/** @type {Map<string, function(RequestShortener): string>} */
|
1151
|
+
const exportsMap = new Map();
|
1152
|
+
|
1153
|
+
// Set with all root exposed unused exports
|
1154
|
+
/** @type {Set<string>} */
|
1155
|
+
const unusedExports = new Set();
|
1156
|
+
|
1157
|
+
for (const dep of this.rootModule.dependencies) {
|
1158
|
+
if (dep instanceof HarmonyExportSpecifierDependency) {
|
1159
|
+
const used = this.rootModule.isUsed(dep.name);
|
1160
|
+
if (used) {
|
1161
|
+
const info = moduleToInfoMap.get(this.rootModule);
|
1162
|
+
if (!exportsMap.has(used)) {
|
1163
|
+
exportsMap.set(
|
1164
|
+
used,
|
1165
|
+
() => `/* binding */ ${info.internalNames.get(dep.id)}`
|
1166
|
+
);
|
1167
|
+
}
|
1168
|
+
} else {
|
1169
|
+
unusedExports.add(dep.name || "namespace");
|
1170
|
+
}
|
1171
|
+
} else if (dep instanceof HarmonyExportImportedSpecifierDependency) {
|
1172
|
+
const exportDefs = getHarmonyExportImportedSpecifierDependencyExports(
|
1173
|
+
dep
|
1174
|
+
);
|
1175
|
+
for (const def of exportDefs) {
|
1176
|
+
const info = moduleToInfoMap.get(def.module);
|
1177
|
+
const used = dep.originModule.isUsed(def.name);
|
1178
|
+
if (used) {
|
1179
|
+
if (!exportsMap.has(used)) {
|
1180
|
+
exportsMap.set(used, requestShortener => {
|
1181
|
+
const finalName = getFinalName(
|
1182
|
+
info,
|
1183
|
+
def.id,
|
1184
|
+
moduleToInfoMap,
|
1185
|
+
requestShortener,
|
1186
|
+
false,
|
1187
|
+
this.rootModule.buildMeta.strictHarmonyModule
|
1188
|
+
);
|
1189
|
+
return `/* reexport */ ${finalName}`;
|
1190
|
+
});
|
1191
|
+
}
|
1192
|
+
} else {
|
1193
|
+
unusedExports.add(def.name);
|
1194
|
+
}
|
1195
|
+
}
|
1196
|
+
}
|
1197
|
+
}
|
1198
|
+
|
1108
1199
|
const result = new ConcatSource();
|
1109
1200
|
|
1110
1201
|
// add harmony compatibility flag (must be first because of possible circular dependencies)
|
1111
1202
|
const usedExports = this.rootModule.usedExports;
|
1112
1203
|
if (usedExports === true || usedExports === null) {
|
1204
|
+
result.add(`// ESM COMPAT FLAG\n`);
|
1113
1205
|
result.add(
|
1114
1206
|
runtimeTemplate.defineEsModuleFlagStatement({
|
1115
1207
|
exportsArgument: this.exportsArgument
|
@@ -1117,9 +1209,33 @@ class ConcatenatedModule extends Module {
|
|
1117
1209
|
);
|
1118
1210
|
}
|
1119
1211
|
|
1212
|
+
// define exports
|
1213
|
+
if (exportsMap.size > 0) {
|
1214
|
+
result.add(`\n// EXPORTS\n`);
|
1215
|
+
for (const [key, value] of exportsMap) {
|
1216
|
+
result.add(
|
1217
|
+
`__webpack_require__.d(${this.exportsArgument}, ${JSON.stringify(
|
1218
|
+
key
|
1219
|
+
)}, function() { return ${value(requestShortener)}; });\n`
|
1220
|
+
);
|
1221
|
+
}
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
// list unused exports
|
1225
|
+
if (unusedExports.size > 0) {
|
1226
|
+
result.add(
|
1227
|
+
`\n// UNUSED EXPORTS: ${joinIterableWithComma(unusedExports)}\n`
|
1228
|
+
);
|
1229
|
+
}
|
1230
|
+
|
1120
1231
|
// define required namespace objects (must be before evaluation modules)
|
1121
1232
|
for (const info of modulesWithInfo) {
|
1122
1233
|
if (info.namespaceObjectSource) {
|
1234
|
+
result.add(
|
1235
|
+
`\n// NAMESPACE OBJECT: ${info.module.readableIdentifier(
|
1236
|
+
requestShortener
|
1237
|
+
)}\n`
|
1238
|
+
);
|
1123
1239
|
result.add(info.namespaceObjectSource);
|
1124
1240
|
}
|
1125
1241
|
}
|
@@ -1321,38 +1437,6 @@ class HarmonyImportSideEffectDependencyConcatenatedTemplate {
|
|
1321
1437
|
}
|
1322
1438
|
}
|
1323
1439
|
|
1324
|
-
class HarmonyExportSpecifierDependencyConcatenatedTemplate {
|
1325
|
-
constructor(originalTemplate, rootModule) {
|
1326
|
-
this.originalTemplate = originalTemplate;
|
1327
|
-
this.rootModule = rootModule;
|
1328
|
-
}
|
1329
|
-
|
1330
|
-
getHarmonyInitOrder(dep) {
|
1331
|
-
if (dep.originModule === this.rootModule) {
|
1332
|
-
return this.originalTemplate.getHarmonyInitOrder(dep);
|
1333
|
-
}
|
1334
|
-
return NaN;
|
1335
|
-
}
|
1336
|
-
|
1337
|
-
harmonyInit(dep, source, runtime, dependencyTemplates) {
|
1338
|
-
if (dep.originModule === this.rootModule) {
|
1339
|
-
this.originalTemplate.harmonyInit(
|
1340
|
-
dep,
|
1341
|
-
source,
|
1342
|
-
runtime,
|
1343
|
-
dependencyTemplates
|
1344
|
-
);
|
1345
|
-
return;
|
1346
|
-
}
|
1347
|
-
}
|
1348
|
-
|
1349
|
-
apply(dep, source, runtime, dependencyTemplates) {
|
1350
|
-
if (dep.originModule === this.rootModule) {
|
1351
|
-
this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
|
1352
|
-
}
|
1353
|
-
}
|
1354
|
-
}
|
1355
|
-
|
1356
1440
|
class HarmonyExportExpressionDependencyConcatenatedTemplate {
|
1357
1441
|
constructor(originalTemplate, rootModule) {
|
1358
1442
|
this.originalTemplate = originalTemplate;
|
@@ -1386,119 +1470,8 @@ class HarmonyExportExpressionDependencyConcatenatedTemplate {
|
|
1386
1470
|
}
|
1387
1471
|
}
|
1388
1472
|
|
1389
|
-
class
|
1390
|
-
|
1391
|
-
this.originalTemplate = originalTemplate;
|
1392
|
-
this.rootModule = rootModule;
|
1393
|
-
this.modulesMap = modulesMap;
|
1394
|
-
}
|
1395
|
-
|
1396
|
-
getExports(dep) {
|
1397
|
-
const importModule = dep._module;
|
1398
|
-
if (dep._id) {
|
1399
|
-
// export { named } from "module"
|
1400
|
-
return [
|
1401
|
-
{
|
1402
|
-
name: dep.name,
|
1403
|
-
id: dep._id,
|
1404
|
-
module: importModule
|
1405
|
-
}
|
1406
|
-
];
|
1407
|
-
}
|
1408
|
-
if (dep.name) {
|
1409
|
-
// export * as abc from "module"
|
1410
|
-
return [
|
1411
|
-
{
|
1412
|
-
name: dep.name,
|
1413
|
-
id: true,
|
1414
|
-
module: importModule
|
1415
|
-
}
|
1416
|
-
];
|
1417
|
-
}
|
1418
|
-
// export * from "module"
|
1419
|
-
return importModule.buildMeta.providedExports
|
1420
|
-
.filter(exp => exp !== "default" && !dep.activeExports.has(exp))
|
1421
|
-
.map(exp => {
|
1422
|
-
return {
|
1423
|
-
name: exp,
|
1424
|
-
id: exp,
|
1425
|
-
module: importModule
|
1426
|
-
};
|
1427
|
-
});
|
1428
|
-
}
|
1429
|
-
|
1430
|
-
getHarmonyInitOrder(dep) {
|
1431
|
-
const module = dep._module;
|
1432
|
-
const info = this.modulesMap.get(module);
|
1433
|
-
if (!info) {
|
1434
|
-
return this.originalTemplate.getHarmonyInitOrder(dep);
|
1435
|
-
}
|
1436
|
-
return NaN;
|
1437
|
-
}
|
1438
|
-
|
1439
|
-
harmonyInit(dep, source, runtime, dependencyTemplates) {
|
1440
|
-
const module = dep._module;
|
1441
|
-
const info = this.modulesMap.get(module);
|
1442
|
-
if (!info) {
|
1443
|
-
this.originalTemplate.harmonyInit(
|
1444
|
-
dep,
|
1445
|
-
source,
|
1446
|
-
runtime,
|
1447
|
-
dependencyTemplates
|
1448
|
-
);
|
1449
|
-
return;
|
1450
|
-
}
|
1451
|
-
}
|
1452
|
-
|
1453
|
-
apply(dep, source, runtime, dependencyTemplates) {
|
1454
|
-
if (dep.originModule === this.rootModule) {
|
1455
|
-
if (this.modulesMap.get(dep._module)) {
|
1456
|
-
const exportDefs = this.getExports(dep);
|
1457
|
-
for (const def of exportDefs) {
|
1458
|
-
const info = this.modulesMap.get(def.module);
|
1459
|
-
const used = dep.originModule.isUsed(def.name);
|
1460
|
-
if (!used) {
|
1461
|
-
source.insert(
|
1462
|
-
-1,
|
1463
|
-
`/* unused concated harmony import ${def.name} */\n`
|
1464
|
-
);
|
1465
|
-
continue;
|
1466
|
-
}
|
1467
|
-
let finalName;
|
1468
|
-
const strictFlag = dep.originModule.buildMeta.strictHarmonyModule
|
1469
|
-
? "_strict"
|
1470
|
-
: "";
|
1471
|
-
if (def.id === true) {
|
1472
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
1473
|
-
} else {
|
1474
|
-
const exportData = Buffer.from(def.id, "utf-8").toString("hex");
|
1475
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${strictFlag}__`;
|
1476
|
-
}
|
1477
|
-
const exportsName = this.rootModule.exportsArgument;
|
1478
|
-
const content =
|
1479
|
-
`/* concated harmony reexport ${def.name} */` +
|
1480
|
-
`__webpack_require__.d(${exportsName}, ` +
|
1481
|
-
`${JSON.stringify(used)}, ` +
|
1482
|
-
`function() { return ${finalName}; });\n`;
|
1483
|
-
source.insert(-1, content);
|
1484
|
-
}
|
1485
|
-
} else {
|
1486
|
-
this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
|
1487
|
-
}
|
1488
|
-
}
|
1489
|
-
}
|
1490
|
-
}
|
1491
|
-
|
1492
|
-
class HarmonyCompatibilityDependencyConcatenatedTemplate {
|
1493
|
-
constructor(originalTemplate, rootModule, modulesMap) {
|
1494
|
-
this.originalTemplate = originalTemplate;
|
1495
|
-
this.rootModule = rootModule;
|
1496
|
-
this.modulesMap = modulesMap;
|
1497
|
-
}
|
1498
|
-
|
1499
|
-
apply(dep, source, runtime, dependencyTemplates) {
|
1500
|
-
// do nothing
|
1501
|
-
}
|
1473
|
+
class NullTemplate {
|
1474
|
+
apply() {}
|
1502
1475
|
}
|
1503
1476
|
|
1504
1477
|
module.exports = ConcatenatedModule;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.42.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -940,16 +940,8 @@
|
|
940
940
|
},
|
941
941
|
"hotUpdateChunkFilename": {
|
942
942
|
"description": "The filename of the Hot Update Chunks. They are inside the output.path directory.",
|
943
|
-
"
|
944
|
-
|
945
|
-
"type": "string",
|
946
|
-
"absolutePath": false
|
947
|
-
},
|
948
|
-
{
|
949
|
-
"instanceof": "Function",
|
950
|
-
"tsType": "Function"
|
951
|
-
}
|
952
|
-
]
|
943
|
+
"type": "string",
|
944
|
+
"absolutePath": false
|
953
945
|
},
|
954
946
|
"hotUpdateFunction": {
|
955
947
|
"description": "The JSONP function used by webpack for async loading of hot update chunks.",
|