webpack 4.41.3 → 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 +9 -6
- package/lib/CommonJsStuffPlugin.js +8 -6
- package/lib/ConstPlugin.js +5 -0
- package/lib/DefinePlugin.js +8 -6
- package/lib/DllPlugin.js +2 -2
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +5 -0
- package/lib/FlagAllModulesAsUsedPlugin.js +38 -0
- package/lib/FlagDependencyExportsPlugin.js +35 -16
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/HotModuleReplacement.runtime.js +11 -2
- package/lib/Parser.js +21 -8
- package/lib/ProvidePlugin.js +4 -3
- package/lib/SourceMapDevToolPlugin.js +20 -16
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +5 -1
- package/lib/logging/Logger.js +15 -18
- package/lib/node/NodeMainTemplate.runtime.js +6 -1
- package/lib/node/NodeMainTemplateAsync.runtime.js +7 -1
- package/lib/optimize/ConcatenatedModule.js +137 -159
- package/lib/optimize/SideEffectsFlagPlugin.js +1 -1
- package/lib/util/identifier.js +25 -0
- package/lib/wasm/WebAssemblyModulesPlugin.js +14 -4
- package/lib/web/JsonpMainTemplate.runtime.js +8 -1
- package/lib/webworker/WebWorkerMainTemplate.runtime.js +9 -1
- package/package.json +3 -1
- package/schemas/WebpackOptions.json +4 -14
- package/schemas/ajv.absolutePath.js +6 -4
@@ -50,7 +50,8 @@ export type Externals =
|
|
50
50
|
request: string,
|
51
51
|
callback: (err?: Error, result?: string) => void
|
52
52
|
) => void)
|
53
|
-
| ExternalItem
|
53
|
+
| ExternalItem
|
54
|
+
)[];
|
54
55
|
/**
|
55
56
|
* This interface was referenced by `WebpackOptions`'s JSON-Schema
|
56
57
|
* via the `definition` "ExternalItem".
|
@@ -131,7 +132,7 @@ export type RuleSetCondition =
|
|
131
132
|
* This interface was referenced by `WebpackOptions`'s JSON-Schema
|
132
133
|
* via the `definition` "RuleSetConditions".
|
133
134
|
*/
|
134
|
-
export type RuleSetConditions =
|
135
|
+
export type RuleSetConditions = RuleSetCondition[];
|
135
136
|
/**
|
136
137
|
* One or multiple rule conditions
|
137
138
|
*
|
@@ -180,7 +181,7 @@ export type RuleSetConditionAbsolute =
|
|
180
181
|
* This interface was referenced by `WebpackOptions`'s JSON-Schema
|
181
182
|
* via the `definition` "RuleSetConditionsAbsolute".
|
182
183
|
*/
|
183
|
-
export type RuleSetConditionsAbsolute =
|
184
|
+
export type RuleSetConditionsAbsolute = RuleSetConditionAbsolute[];
|
184
185
|
/**
|
185
186
|
* This interface was referenced by `WebpackOptions`'s JSON-Schema
|
186
187
|
* via the `definition` "RuleSetLoader".
|
@@ -391,7 +392,8 @@ export interface WebpackOptions {
|
|
391
392
|
| "normal"
|
392
393
|
| "detailed"
|
393
394
|
| "verbose"
|
394
|
-
| "errors-warnings"
|
395
|
+
| "errors-warnings"
|
396
|
+
);
|
395
397
|
/**
|
396
398
|
* Environment to build for
|
397
399
|
*/
|
@@ -404,7 +406,8 @@ export interface WebpackOptions {
|
|
404
406
|
| "node-webkit"
|
405
407
|
| "electron-main"
|
406
408
|
| "electron-renderer"
|
407
|
-
| "electron-preload"
|
409
|
+
| "electron-preload"
|
410
|
+
)
|
408
411
|
| ((compiler: import("../lib/Compiler")) => void);
|
409
412
|
/**
|
410
413
|
* Enter watch mode, which rebuilds on file change.
|
@@ -1115,7 +1118,7 @@ export interface OutputOptions {
|
|
1115
1118
|
/**
|
1116
1119
|
* The filename of the Hot Update Chunks. They are inside the output.path directory.
|
1117
1120
|
*/
|
1118
|
-
hotUpdateChunkFilename?: string
|
1121
|
+
hotUpdateChunkFilename?: string;
|
1119
1122
|
/**
|
1120
1123
|
* The JSONP function used by webpack for async loading of hot update chunks.
|
1121
1124
|
*/
|
@@ -45,18 +45,20 @@ class CommonJsStuffPlugin {
|
|
45
45
|
.tap("CommonJsStuffPlugin", expr => {
|
46
46
|
parser.state.module.buildMeta.moduleConcatenationBailout =
|
47
47
|
"module.loaded";
|
48
|
-
return ParserHelpers.toConstantDependency(
|
49
|
-
|
50
|
-
|
48
|
+
return ParserHelpers.toConstantDependency(
|
49
|
+
parser,
|
50
|
+
"module.l"
|
51
|
+
)(expr);
|
51
52
|
});
|
52
53
|
parser.hooks.expression
|
53
54
|
.for("module.id")
|
54
55
|
.tap("CommonJsStuffPlugin", expr => {
|
55
56
|
parser.state.module.buildMeta.moduleConcatenationBailout =
|
56
57
|
"module.id";
|
57
|
-
return ParserHelpers.toConstantDependency(
|
58
|
-
|
59
|
-
|
58
|
+
return ParserHelpers.toConstantDependency(
|
59
|
+
parser,
|
60
|
+
"module.i"
|
61
|
+
)(expr);
|
60
62
|
});
|
61
63
|
parser.hooks.expression
|
62
64
|
.for("module.exports")
|
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/DefinePlugin.js
CHANGED
@@ -190,9 +190,10 @@ class DefinePlugin {
|
|
190
190
|
strCode
|
191
191
|
)(expr);
|
192
192
|
} else {
|
193
|
-
return ParserHelpers.toConstantDependency(
|
194
|
-
|
195
|
-
|
193
|
+
return ParserHelpers.toConstantDependency(
|
194
|
+
parser,
|
195
|
+
strCode
|
196
|
+
)(expr);
|
196
197
|
}
|
197
198
|
});
|
198
199
|
}
|
@@ -255,9 +256,10 @@ class DefinePlugin {
|
|
255
256
|
strCode
|
256
257
|
)(expr);
|
257
258
|
} else {
|
258
|
-
return ParserHelpers.toConstantDependency(
|
259
|
-
|
260
|
-
|
259
|
+
return ParserHelpers.toConstantDependency(
|
260
|
+
parser,
|
261
|
+
strCode
|
262
|
+
)(expr);
|
261
263
|
}
|
262
264
|
});
|
263
265
|
parser.hooks.typeof.for(key).tap("DefinePlugin", expr => {
|
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
|
}
|
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
const { RawSource } = require("webpack-sources");
|
8
8
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
9
|
+
const { absolutify } = require("./util/identifier");
|
9
10
|
|
10
11
|
const cache = new WeakMap();
|
11
12
|
|
@@ -60,7 +61,11 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
|
|
60
61
|
obj[key] = sourceMap[key];
|
61
62
|
return obj;
|
62
63
|
}, {});
|
64
|
+
const context = this.compilation.compiler.options.context;
|
63
65
|
const modules = sourceMap.sources.map(source => {
|
66
|
+
if (source.startsWith("webpack://")) {
|
67
|
+
source = absolutify(context, source.slice(10));
|
68
|
+
}
|
64
69
|
const module = self.compilation.findModule(source);
|
65
70
|
return module || source;
|
66
71
|
});
|
@@ -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;
|
@@ -7,14 +7,9 @@
|
|
7
7
|
const Queue = require("./util/Queue");
|
8
8
|
|
9
9
|
const addToSet = (a, b) => {
|
10
|
-
let changed = false;
|
11
10
|
for (const item of b) {
|
12
|
-
|
13
|
-
a.add(item);
|
14
|
-
changed = true;
|
15
|
-
}
|
11
|
+
a.add(item);
|
16
12
|
}
|
17
|
-
return changed;
|
18
13
|
};
|
19
14
|
|
20
15
|
class FlagDependencyExportsPlugin {
|
@@ -61,14 +56,11 @@ class FlagDependencyExportsPlugin {
|
|
61
56
|
// break if it should move to the worst state
|
62
57
|
if (exports === true) {
|
63
58
|
module.buildMeta.providedExports = true;
|
64
|
-
notifyDependencies();
|
65
59
|
return true;
|
66
60
|
}
|
67
61
|
// merge in new exports
|
68
62
|
if (Array.isArray(exports)) {
|
69
|
-
|
70
|
-
notifyDependencies();
|
71
|
-
}
|
63
|
+
addToSet(moduleProvidedExports, exports);
|
72
64
|
}
|
73
65
|
// store dependencies
|
74
66
|
const exportDeps = exportDesc.dependencies;
|
@@ -96,6 +88,26 @@ class FlagDependencyExportsPlugin {
|
|
96
88
|
}
|
97
89
|
};
|
98
90
|
|
91
|
+
const notifyDependenciesIfDifferent = (set, array) => {
|
92
|
+
const deps = dependencies.get(module);
|
93
|
+
if (deps !== undefined) {
|
94
|
+
if (set.size === array.length) {
|
95
|
+
let i = 0;
|
96
|
+
let different = false;
|
97
|
+
for (const item of set) {
|
98
|
+
if (item !== array[i++]) {
|
99
|
+
different = true;
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
if (!different) return;
|
104
|
+
}
|
105
|
+
for (const dep of deps) {
|
106
|
+
queue.enqueue(dep);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
99
111
|
// Start with all modules without provided exports
|
100
112
|
for (const module of modules) {
|
101
113
|
if (module.buildInfo.temporaryProvidedExports) {
|
@@ -114,18 +126,25 @@ class FlagDependencyExportsPlugin {
|
|
114
126
|
if (module.buildMeta.providedExports !== true) {
|
115
127
|
moduleWithExports =
|
116
128
|
module.buildMeta && module.buildMeta.exportsType;
|
117
|
-
moduleProvidedExports =
|
118
|
-
module.buildMeta.providedExports
|
119
|
-
)
|
120
|
-
? new Set(module.buildMeta.providedExports)
|
121
|
-
: new Set();
|
129
|
+
moduleProvidedExports = new Set();
|
122
130
|
providedExportsAreTemporary = false;
|
123
131
|
processDependenciesBlock(module);
|
124
132
|
module.buildInfo.temporaryProvidedExports = providedExportsAreTemporary;
|
125
133
|
if (!moduleWithExports) {
|
134
|
+
notifyDependencies();
|
126
135
|
module.buildMeta.providedExports = true;
|
136
|
+
} else if (module.buildMeta.providedExports === true) {
|
137
|
+
notifyDependencies();
|
138
|
+
} else if (!module.buildMeta.providedExports) {
|
127
139
|
notifyDependencies();
|
128
|
-
|
140
|
+
module.buildMeta.providedExports = Array.from(
|
141
|
+
moduleProvidedExports
|
142
|
+
);
|
143
|
+
} else {
|
144
|
+
notifyDependenciesIfDifferent(
|
145
|
+
moduleProvidedExports,
|
146
|
+
module.buildMeta.providedExports
|
147
|
+
);
|
129
148
|
module.buildMeta.providedExports = Array.from(
|
130
149
|
moduleProvidedExports
|
131
150
|
);
|
@@ -2,7 +2,17 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
// eslint-disable no-unused-vars
|
6
|
+
var $hash$ = undefined;
|
7
|
+
var $requestTimeout$ = undefined;
|
8
|
+
var installedModules = undefined;
|
9
|
+
var $require$ = undefined;
|
10
|
+
var hotDownloadManifest = undefined;
|
11
|
+
var hotDownloadUpdateChunk = undefined;
|
12
|
+
var hotDisposeChunk = undefined;
|
13
|
+
var modules = undefined;
|
14
|
+
var chunkId = undefined;
|
15
|
+
|
6
16
|
module.exports = function() {
|
7
17
|
var hotApplyOnUpdate = true;
|
8
18
|
// eslint-disable-next-line no-unused-vars
|
@@ -204,7 +214,6 @@ module.exports = function() {
|
|
204
214
|
/*foreachInstalledChunks*/
|
205
215
|
// eslint-disable-next-line no-lone-blocks
|
206
216
|
{
|
207
|
-
/*globals chunkId */
|
208
217
|
hotEnsureUpdateChunk(chunkId);
|
209
218
|
}
|
210
219
|
if (
|
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);
|
package/lib/ProvidePlugin.js
CHANGED
@@ -62,9 +62,10 @@ class ProvidePlugin {
|
|
62
62
|
return false;
|
63
63
|
}
|
64
64
|
if (scopedName) {
|
65
|
-
ParserHelpers.toConstantDependency(
|
66
|
-
|
67
|
-
|
65
|
+
ParserHelpers.toConstantDependency(
|
66
|
+
parser,
|
67
|
+
nameIdentifier
|
68
|
+
)(expr);
|
68
69
|
}
|
69
70
|
return true;
|
70
71
|
});
|
@@ -9,6 +9,7 @@ const { ConcatSource, RawSource } = require("webpack-sources");
|
|
9
9
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
10
10
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
11
11
|
const createHash = require("./util/createHash");
|
12
|
+
const { absolutify } = require("./util/identifier");
|
12
13
|
|
13
14
|
const validateOptions = require("schema-utils");
|
14
15
|
const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
|
@@ -68,16 +69,24 @@ const getTaskForFile = (file, asset, chunk, options, compilation) => {
|
|
68
69
|
sourceMap = asset.map(options);
|
69
70
|
source = asset.source();
|
70
71
|
}
|
71
|
-
if (sourceMap)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
72
|
+
if (!sourceMap || typeof source !== "string") return;
|
73
|
+
const context = compilation.options.context;
|
74
|
+
const modules = sourceMap.sources.map(source => {
|
75
|
+
if (source.startsWith("webpack://")) {
|
76
|
+
source = absolutify(context, source.slice(10));
|
77
|
+
}
|
78
|
+
const module = compilation.findModule(source);
|
79
|
+
return module || source;
|
80
|
+
});
|
81
|
+
|
82
|
+
return {
|
83
|
+
chunk,
|
84
|
+
file,
|
85
|
+
asset,
|
86
|
+
source,
|
87
|
+
sourceMap,
|
88
|
+
modules
|
89
|
+
};
|
81
90
|
};
|
82
91
|
|
83
92
|
class SourceMapDevToolPlugin {
|
@@ -212,10 +221,7 @@ class SourceMapDevToolPlugin {
|
|
212
221
|
);
|
213
222
|
|
214
223
|
if (task) {
|
215
|
-
const modules = task.
|
216
|
-
const module = compilation.findModule(source);
|
217
|
-
return module || source;
|
218
|
-
});
|
224
|
+
const modules = task.modules;
|
219
225
|
|
220
226
|
for (let idx = 0; idx < modules.length; idx++) {
|
221
227
|
const module = modules[idx];
|
@@ -234,8 +240,6 @@ class SourceMapDevToolPlugin {
|
|
234
240
|
}
|
235
241
|
}
|
236
242
|
|
237
|
-
task.modules = modules;
|
238
|
-
|
239
243
|
tasks.push(task);
|
240
244
|
}
|
241
245
|
});
|
@@ -304,9 +304,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
304
304
|
}
|
305
305
|
|
306
306
|
if (Array.isArray(importedModule.buildMeta.providedExports)) {
|
307
|
+
const activeFromOtherStarExports = this._discoverActiveExportsFromOtherStartExports();
|
307
308
|
return {
|
308
309
|
exports: importedModule.buildMeta.providedExports.filter(
|
309
|
-
id =>
|
310
|
+
id =>
|
311
|
+
id !== "default" &&
|
312
|
+
!activeFromOtherStarExports.has(id) &&
|
313
|
+
!this.activeExports.has(id)
|
310
314
|
),
|
311
315
|
dependencies: [importedModule]
|
312
316
|
};
|
package/lib/logging/Logger.js
CHANGED
@@ -5,34 +5,31 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
/**
|
9
|
-
* @enum {string}
|
10
|
-
*/
|
11
8
|
const LogType = Object.freeze({
|
12
|
-
error: "error", // message, c style arguments
|
13
|
-
warn: "warn", // message, c style arguments
|
14
|
-
info: "info", // message, c style arguments
|
15
|
-
log: "log", // message, c style arguments
|
16
|
-
debug: "debug", // message, c style arguments
|
9
|
+
error: /** @type {"error"} */ ("error"), // message, c style arguments
|
10
|
+
warn: /** @type {"warn"} */ ("warn"), // message, c style arguments
|
11
|
+
info: /** @type {"info"} */ ("info"), // message, c style arguments
|
12
|
+
log: /** @type {"log"} */ ("log"), // message, c style arguments
|
13
|
+
debug: /** @type {"debug"} */ ("debug"), // message, c style arguments
|
17
14
|
|
18
|
-
trace: "trace", // no arguments
|
15
|
+
trace: /** @type {"trace"} */ ("trace"), // no arguments
|
19
16
|
|
20
|
-
group: "group", // [label]
|
21
|
-
groupCollapsed: "groupCollapsed", // [label]
|
22
|
-
groupEnd: "groupEnd", // [label]
|
17
|
+
group: /** @type {"group"} */ ("group"), // [label]
|
18
|
+
groupCollapsed: /** @type {"groupCollapsed"} */ ("groupCollapsed"), // [label]
|
19
|
+
groupEnd: /** @type {"groupEnd"} */ ("groupEnd"), // [label]
|
23
20
|
|
24
|
-
profile: "profile", // [profileName]
|
25
|
-
profileEnd: "profileEnd", // [profileName]
|
21
|
+
profile: /** @type {"profile"} */ ("profile"), // [profileName]
|
22
|
+
profileEnd: /** @type {"profileEnd"} */ ("profileEnd"), // [profileName]
|
26
23
|
|
27
|
-
time: "time", // name, time as [seconds, nanoseconds]
|
24
|
+
time: /** @type {"time"} */ ("time"), // name, time as [seconds, nanoseconds]
|
28
25
|
|
29
|
-
clear: "clear", // no arguments
|
30
|
-
status: "status" // message, arguments
|
26
|
+
clear: /** @type {"clear"} */ ("clear"), // no arguments
|
27
|
+
status: /** @type {"status"} */ ("status") // message, arguments
|
31
28
|
});
|
32
29
|
|
33
30
|
exports.LogType = LogType;
|
34
31
|
|
35
|
-
/** @typedef {keyof typeof LogType} LogTypeEnum */
|
32
|
+
/** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */
|
36
33
|
|
37
34
|
const LOG_SYMBOL = Symbol("webpack logger raw log method");
|
38
35
|
const TIMERS_SYMBOL = Symbol("webpack logger times");
|
@@ -2,7 +2,12 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
6
|
+
var $hotChunkFilename$ = undefined;
|
7
|
+
var hotAddUpdateChunk = undefined;
|
8
|
+
var installedChunks = undefined;
|
9
|
+
var $hotMainFilename$ = undefined;
|
10
|
+
|
6
11
|
module.exports = function() {
|
7
12
|
// eslint-disable-next-line no-unused-vars
|
8
13
|
function hotDownloadUpdateChunk(chunkId) {
|
@@ -2,7 +2,13 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
6
|
+
var $hotChunkFilename$ = undefined;
|
7
|
+
var $require$ = undefined;
|
8
|
+
var hotAddUpdateChunk = undefined;
|
9
|
+
var $hotMainFilename$ = undefined;
|
10
|
+
var installedChunks = undefined;
|
11
|
+
|
6
12
|
module.exports = function() {
|
7
13
|
// eslint-disable-next-line no-unused-vars
|
8
14
|
function hotDownloadUpdateChunk(chunkId) {
|
@@ -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);
|
@@ -330,6 +382,7 @@ class ConcatenatedModule extends Module {
|
|
330
382
|
);
|
331
383
|
|
332
384
|
this.dependencies = [];
|
385
|
+
this.blocks = [];
|
333
386
|
|
334
387
|
this.warnings = [];
|
335
388
|
this.errors = [];
|
@@ -348,6 +401,10 @@ class ConcatenatedModule extends Module {
|
|
348
401
|
)) {
|
349
402
|
this.dependencies.push(d);
|
350
403
|
}
|
404
|
+
// populate blocks
|
405
|
+
for (const d of m.blocks) {
|
406
|
+
this.blocks.push(d);
|
407
|
+
}
|
351
408
|
// populate file dependencies
|
352
409
|
if (m.buildInfo.fileDependencies) {
|
353
410
|
for (const file of m.buildInfo.fileDependencies) {
|
@@ -621,10 +678,7 @@ class ConcatenatedModule extends Module {
|
|
621
678
|
);
|
622
679
|
innerDependencyTemplates.set(
|
623
680
|
HarmonyExportSpecifierDependency,
|
624
|
-
new
|
625
|
-
dependencyTemplates.get(HarmonyExportSpecifierDependency),
|
626
|
-
this.rootModule
|
627
|
-
)
|
681
|
+
new NullTemplate()
|
628
682
|
);
|
629
683
|
innerDependencyTemplates.set(
|
630
684
|
HarmonyExportExpressionDependency,
|
@@ -635,19 +689,11 @@ class ConcatenatedModule extends Module {
|
|
635
689
|
);
|
636
690
|
innerDependencyTemplates.set(
|
637
691
|
HarmonyExportImportedSpecifierDependency,
|
638
|
-
new
|
639
|
-
dependencyTemplates.get(HarmonyExportImportedSpecifierDependency),
|
640
|
-
this.rootModule,
|
641
|
-
moduleToInfoMap
|
642
|
-
)
|
692
|
+
new NullTemplate()
|
643
693
|
);
|
644
694
|
innerDependencyTemplates.set(
|
645
695
|
HarmonyCompatibilityDependency,
|
646
|
-
new
|
647
|
-
dependencyTemplates.get(HarmonyCompatibilityDependency),
|
648
|
-
this.rootModule,
|
649
|
-
moduleToInfoMap
|
650
|
-
)
|
696
|
+
new NullTemplate()
|
651
697
|
);
|
652
698
|
|
653
699
|
// Must use full identifier in our cache here to ensure that the source
|
@@ -1100,11 +1146,62 @@ class ConcatenatedModule extends Module {
|
|
1100
1146
|
}
|
1101
1147
|
}
|
1102
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
|
+
|
1103
1199
|
const result = new ConcatSource();
|
1104
1200
|
|
1105
1201
|
// add harmony compatibility flag (must be first because of possible circular dependencies)
|
1106
1202
|
const usedExports = this.rootModule.usedExports;
|
1107
1203
|
if (usedExports === true || usedExports === null) {
|
1204
|
+
result.add(`// ESM COMPAT FLAG\n`);
|
1108
1205
|
result.add(
|
1109
1206
|
runtimeTemplate.defineEsModuleFlagStatement({
|
1110
1207
|
exportsArgument: this.exportsArgument
|
@@ -1112,9 +1209,33 @@ class ConcatenatedModule extends Module {
|
|
1112
1209
|
);
|
1113
1210
|
}
|
1114
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
|
+
|
1115
1231
|
// define required namespace objects (must be before evaluation modules)
|
1116
1232
|
for (const info of modulesWithInfo) {
|
1117
1233
|
if (info.namespaceObjectSource) {
|
1234
|
+
result.add(
|
1235
|
+
`\n// NAMESPACE OBJECT: ${info.module.readableIdentifier(
|
1236
|
+
requestShortener
|
1237
|
+
)}\n`
|
1238
|
+
);
|
1118
1239
|
result.add(info.namespaceObjectSource);
|
1119
1240
|
}
|
1120
1241
|
}
|
@@ -1316,38 +1437,6 @@ class HarmonyImportSideEffectDependencyConcatenatedTemplate {
|
|
1316
1437
|
}
|
1317
1438
|
}
|
1318
1439
|
|
1319
|
-
class HarmonyExportSpecifierDependencyConcatenatedTemplate {
|
1320
|
-
constructor(originalTemplate, rootModule) {
|
1321
|
-
this.originalTemplate = originalTemplate;
|
1322
|
-
this.rootModule = rootModule;
|
1323
|
-
}
|
1324
|
-
|
1325
|
-
getHarmonyInitOrder(dep) {
|
1326
|
-
if (dep.originModule === this.rootModule) {
|
1327
|
-
return this.originalTemplate.getHarmonyInitOrder(dep);
|
1328
|
-
}
|
1329
|
-
return NaN;
|
1330
|
-
}
|
1331
|
-
|
1332
|
-
harmonyInit(dep, source, runtime, dependencyTemplates) {
|
1333
|
-
if (dep.originModule === this.rootModule) {
|
1334
|
-
this.originalTemplate.harmonyInit(
|
1335
|
-
dep,
|
1336
|
-
source,
|
1337
|
-
runtime,
|
1338
|
-
dependencyTemplates
|
1339
|
-
);
|
1340
|
-
return;
|
1341
|
-
}
|
1342
|
-
}
|
1343
|
-
|
1344
|
-
apply(dep, source, runtime, dependencyTemplates) {
|
1345
|
-
if (dep.originModule === this.rootModule) {
|
1346
|
-
this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
|
1347
|
-
}
|
1348
|
-
}
|
1349
|
-
}
|
1350
|
-
|
1351
1440
|
class HarmonyExportExpressionDependencyConcatenatedTemplate {
|
1352
1441
|
constructor(originalTemplate, rootModule) {
|
1353
1442
|
this.originalTemplate = originalTemplate;
|
@@ -1381,119 +1470,8 @@ class HarmonyExportExpressionDependencyConcatenatedTemplate {
|
|
1381
1470
|
}
|
1382
1471
|
}
|
1383
1472
|
|
1384
|
-
class
|
1385
|
-
|
1386
|
-
this.originalTemplate = originalTemplate;
|
1387
|
-
this.rootModule = rootModule;
|
1388
|
-
this.modulesMap = modulesMap;
|
1389
|
-
}
|
1390
|
-
|
1391
|
-
getExports(dep) {
|
1392
|
-
const importModule = dep._module;
|
1393
|
-
if (dep._id) {
|
1394
|
-
// export { named } from "module"
|
1395
|
-
return [
|
1396
|
-
{
|
1397
|
-
name: dep.name,
|
1398
|
-
id: dep._id,
|
1399
|
-
module: importModule
|
1400
|
-
}
|
1401
|
-
];
|
1402
|
-
}
|
1403
|
-
if (dep.name) {
|
1404
|
-
// export * as abc from "module"
|
1405
|
-
return [
|
1406
|
-
{
|
1407
|
-
name: dep.name,
|
1408
|
-
id: true,
|
1409
|
-
module: importModule
|
1410
|
-
}
|
1411
|
-
];
|
1412
|
-
}
|
1413
|
-
// export * from "module"
|
1414
|
-
return importModule.buildMeta.providedExports
|
1415
|
-
.filter(exp => exp !== "default" && !dep.activeExports.has(exp))
|
1416
|
-
.map(exp => {
|
1417
|
-
return {
|
1418
|
-
name: exp,
|
1419
|
-
id: exp,
|
1420
|
-
module: importModule
|
1421
|
-
};
|
1422
|
-
});
|
1423
|
-
}
|
1424
|
-
|
1425
|
-
getHarmonyInitOrder(dep) {
|
1426
|
-
const module = dep._module;
|
1427
|
-
const info = this.modulesMap.get(module);
|
1428
|
-
if (!info) {
|
1429
|
-
return this.originalTemplate.getHarmonyInitOrder(dep);
|
1430
|
-
}
|
1431
|
-
return NaN;
|
1432
|
-
}
|
1433
|
-
|
1434
|
-
harmonyInit(dep, source, runtime, dependencyTemplates) {
|
1435
|
-
const module = dep._module;
|
1436
|
-
const info = this.modulesMap.get(module);
|
1437
|
-
if (!info) {
|
1438
|
-
this.originalTemplate.harmonyInit(
|
1439
|
-
dep,
|
1440
|
-
source,
|
1441
|
-
runtime,
|
1442
|
-
dependencyTemplates
|
1443
|
-
);
|
1444
|
-
return;
|
1445
|
-
}
|
1446
|
-
}
|
1447
|
-
|
1448
|
-
apply(dep, source, runtime, dependencyTemplates) {
|
1449
|
-
if (dep.originModule === this.rootModule) {
|
1450
|
-
if (this.modulesMap.get(dep._module)) {
|
1451
|
-
const exportDefs = this.getExports(dep);
|
1452
|
-
for (const def of exportDefs) {
|
1453
|
-
const info = this.modulesMap.get(def.module);
|
1454
|
-
const used = dep.originModule.isUsed(def.name);
|
1455
|
-
if (!used) {
|
1456
|
-
source.insert(
|
1457
|
-
-1,
|
1458
|
-
`/* unused concated harmony import ${def.name} */\n`
|
1459
|
-
);
|
1460
|
-
continue;
|
1461
|
-
}
|
1462
|
-
let finalName;
|
1463
|
-
const strictFlag = dep.originModule.buildMeta.strictHarmonyModule
|
1464
|
-
? "_strict"
|
1465
|
-
: "";
|
1466
|
-
if (def.id === true) {
|
1467
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
1468
|
-
} else {
|
1469
|
-
const exportData = Buffer.from(def.id, "utf-8").toString("hex");
|
1470
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${strictFlag}__`;
|
1471
|
-
}
|
1472
|
-
const exportsName = this.rootModule.exportsArgument;
|
1473
|
-
const content =
|
1474
|
-
`/* concated harmony reexport ${def.name} */` +
|
1475
|
-
`__webpack_require__.d(${exportsName}, ` +
|
1476
|
-
`${JSON.stringify(used)}, ` +
|
1477
|
-
`function() { return ${finalName}; });\n`;
|
1478
|
-
source.insert(-1, content);
|
1479
|
-
}
|
1480
|
-
} else {
|
1481
|
-
this.originalTemplate.apply(dep, source, runtime, dependencyTemplates);
|
1482
|
-
}
|
1483
|
-
}
|
1484
|
-
}
|
1485
|
-
}
|
1486
|
-
|
1487
|
-
class HarmonyCompatibilityDependencyConcatenatedTemplate {
|
1488
|
-
constructor(originalTemplate, rootModule, modulesMap) {
|
1489
|
-
this.originalTemplate = originalTemplate;
|
1490
|
-
this.rootModule = rootModule;
|
1491
|
-
this.modulesMap = modulesMap;
|
1492
|
-
}
|
1493
|
-
|
1494
|
-
apply(dep, source, runtime, dependencyTemplates) {
|
1495
|
-
// do nothing
|
1496
|
-
}
|
1473
|
+
class NullTemplate {
|
1474
|
+
apply() {}
|
1497
1475
|
}
|
1498
1476
|
|
1499
1477
|
module.exports = ConcatenatedModule;
|
@@ -115,7 +115,7 @@ class SideEffectsFlagPlugin {
|
|
115
115
|
(dep instanceof HarmonyImportSpecifierDependency &&
|
116
116
|
!dep.namespaceObjectAsContext)
|
117
117
|
) {
|
118
|
-
const mapping = map.get(dep.
|
118
|
+
const mapping = map.get(dep._id);
|
119
119
|
if (mapping) {
|
120
120
|
dep.redirectedModule = mapping.module;
|
121
121
|
dep.redirectedId = mapping.exportName;
|
package/lib/util/identifier.js
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
const path = require("path");
|
3
3
|
|
4
|
+
/**
|
5
|
+
* @param {string} context context for relative path
|
6
|
+
* @param {string} relativePath path
|
7
|
+
* @returns {string} absolute path
|
8
|
+
*/
|
9
|
+
const requestToAbsolute = (context, relativePath) => {
|
10
|
+
if (relativePath.startsWith("./") || relativePath.startsWith("../"))
|
11
|
+
return path.join(context, relativePath);
|
12
|
+
return relativePath;
|
13
|
+
};
|
14
|
+
|
4
15
|
/**
|
5
16
|
* @typedef {Object} MakeRelativePathsCache
|
6
17
|
* @property {Map<string, Map<string, string>>=} relativePaths
|
@@ -100,3 +111,17 @@ exports.contextify = (context, request) => {
|
|
100
111
|
})
|
101
112
|
.join("!");
|
102
113
|
};
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @param {string} context absolute context path
|
117
|
+
* @param {string} request any request string
|
118
|
+
* @returns {string} a new request string using absolute paths when possible
|
119
|
+
*/
|
120
|
+
const _absolutify = (context, request) => {
|
121
|
+
return request
|
122
|
+
.split("!")
|
123
|
+
.map(r => requestToAbsolute(context, r))
|
124
|
+
.join("!");
|
125
|
+
};
|
126
|
+
|
127
|
+
exports.absolutify = _absolutify;
|
@@ -5,15 +5,16 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const Generator = require("../Generator");
|
8
|
-
const WebAssemblyParser = require("./WebAssemblyParser");
|
9
|
-
const WebAssemblyGenerator = require("./WebAssemblyGenerator");
|
10
|
-
const WebAssemblyJavascriptGenerator = require("./WebAssemblyJavascriptGenerator");
|
11
|
-
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
12
8
|
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
|
9
|
+
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
13
10
|
const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
|
14
11
|
|
15
12
|
/** @typedef {import("../Compiler")} Compiler */
|
16
13
|
|
14
|
+
let WebAssemblyGenerator;
|
15
|
+
let WebAssemblyJavascriptGenerator;
|
16
|
+
let WebAssemblyParser;
|
17
|
+
|
17
18
|
class WebAssemblyModulesPlugin {
|
18
19
|
constructor(options) {
|
19
20
|
this.options = options;
|
@@ -40,12 +41,21 @@ class WebAssemblyModulesPlugin {
|
|
40
41
|
normalModuleFactory.hooks.createParser
|
41
42
|
.for("webassembly/experimental")
|
42
43
|
.tap("WebAssemblyModulesPlugin", () => {
|
44
|
+
if (WebAssemblyParser === undefined) {
|
45
|
+
WebAssemblyParser = require("./WebAssemblyParser");
|
46
|
+
}
|
43
47
|
return new WebAssemblyParser();
|
44
48
|
});
|
45
49
|
|
46
50
|
normalModuleFactory.hooks.createGenerator
|
47
51
|
.for("webassembly/experimental")
|
48
52
|
.tap("WebAssemblyModulesPlugin", () => {
|
53
|
+
if (WebAssemblyGenerator === undefined) {
|
54
|
+
WebAssemblyGenerator = require("./WebAssemblyGenerator");
|
55
|
+
}
|
56
|
+
if (WebAssemblyJavascriptGenerator === undefined) {
|
57
|
+
WebAssemblyJavascriptGenerator = require("./WebAssemblyJavascriptGenerator");
|
58
|
+
}
|
49
59
|
return Generator.byType({
|
50
60
|
javascript: new WebAssemblyJavascriptGenerator(),
|
51
61
|
webassembly: new WebAssemblyGenerator(this.options)
|
@@ -2,7 +2,14 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
6
|
+
var hotAddUpdateChunk = undefined;
|
7
|
+
var parentHotUpdateCallback = undefined;
|
8
|
+
var $require$ = undefined;
|
9
|
+
var $hotMainFilename$ = undefined;
|
10
|
+
var $hotChunkFilename$ = undefined;
|
11
|
+
var $crossOriginLoading$ = undefined;
|
12
|
+
|
6
13
|
module.exports = function() {
|
7
14
|
// eslint-disable-next-line no-unused-vars
|
8
15
|
function webpackHotUpdateCallback(chunkId, moreModules) {
|
@@ -2,7 +2,15 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
6
|
+
var hotAddUpdateChunk = undefined;
|
7
|
+
var parentHotUpdateCallback = undefined;
|
8
|
+
var $require$ = undefined;
|
9
|
+
var $hotChunkFilename$ = undefined;
|
10
|
+
var $hotMainFilename$ = undefined;
|
11
|
+
var installedChunks = undefined;
|
12
|
+
var importScripts = undefined;
|
13
|
+
|
6
14
|
module.exports = function() {
|
7
15
|
// eslint-disable-next-line no-unused-vars
|
8
16
|
function webpackHotUpdateCallback(chunkId, moreModules) {
|
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",
|
@@ -30,10 +30,12 @@
|
|
30
30
|
"webpack-sources": "^1.4.1"
|
31
31
|
},
|
32
32
|
"devDependencies": {
|
33
|
+
"@babel/core": "^7.7.2",
|
33
34
|
"@types/node": "^10.12.21",
|
34
35
|
"@types/tapable": "^1.0.1",
|
35
36
|
"@types/webpack-sources": "^0.1.4",
|
36
37
|
"@yarnpkg/lockfile": "^1.1.0",
|
38
|
+
"babel-loader": "^8.0.6",
|
37
39
|
"benchmark": "^2.1.1",
|
38
40
|
"bundle-loader": "~0.5.0",
|
39
41
|
"coffee-loader": "^0.9.0",
|
@@ -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.",
|
@@ -1428,8 +1420,7 @@
|
|
1428
1420
|
"$ref": "#/definitions/RuleSetCondition"
|
1429
1421
|
}
|
1430
1422
|
]
|
1431
|
-
}
|
1432
|
-
"tsType": "RuleSetConditionsRecursive"
|
1423
|
+
}
|
1433
1424
|
},
|
1434
1425
|
"RuleSetConditionsAbsolute": {
|
1435
1426
|
"type": "array",
|
@@ -1440,8 +1431,7 @@
|
|
1440
1431
|
"$ref": "#/definitions/RuleSetConditionAbsolute"
|
1441
1432
|
}
|
1442
1433
|
]
|
1443
|
-
}
|
1444
|
-
"tsType": "RuleSetConditionsAbsoluteRecursive"
|
1434
|
+
}
|
1445
1435
|
},
|
1446
1436
|
"RuleSetLoader": {
|
1447
1437
|
"type": "string",
|
@@ -25,8 +25,6 @@ module.exports = ajv =>
|
|
25
25
|
function callback(data) {
|
26
26
|
let passes = true;
|
27
27
|
const isExclamationMarkPresent = data.includes("!");
|
28
|
-
const isCorrectAbsoluteOrRelativePath =
|
29
|
-
expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
|
30
28
|
|
31
29
|
if (isExclamationMarkPresent) {
|
32
30
|
callback.errors = [
|
@@ -40,8 +38,12 @@ module.exports = ajv =>
|
|
40
38
|
];
|
41
39
|
passes = false;
|
42
40
|
}
|
43
|
-
|
44
|
-
|
41
|
+
// ?:[A-Za-z]:\\ - Windows absolute path
|
42
|
+
// \\\\ - Windows network absolute path
|
43
|
+
// \/ - Unix-like OS absolute path
|
44
|
+
const isCorrectAbsolutePath =
|
45
|
+
expected === /^(?:[A-Za-z]:\\|\\\\|\/)/.test(data);
|
46
|
+
if (!isCorrectAbsolutePath) {
|
45
47
|
callback.errors = [getErrorFor(expected, data, schema)];
|
46
48
|
passes = false;
|
47
49
|
}
|