webpack 4.38.0 → 4.39.3
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/README.md +5 -1
- package/lib/BannerPlugin.js +4 -6
- package/lib/CachePlugin.js +12 -14
- package/lib/ChunkGroup.js +12 -12
- package/lib/Compilation.js +0 -10
- package/lib/Compiler.js +11 -4
- package/lib/Entrypoint.js +2 -2
- package/lib/MultiCompiler.js +8 -1
- package/lib/ProgressPlugin.js +21 -62
- package/lib/Stats.js +8 -2
- package/lib/SystemMainTemplatePlugin.js +5 -1
- package/lib/TemplatedPathPlugin.js +8 -1
- package/lib/buildChunkGraph.js +49 -14
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/logging/Logger.js +6 -1
- package/lib/logging/createConsoleLogger.js +46 -25
- package/lib/logging/runtime.js +2 -1
- package/lib/logging/truncateArgs.js +76 -0
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/node/nodeConsole.js +135 -0
- package/lib/wasm/WebAssemblyGenerator.js +13 -7
- package/lib/web/JsonpMainTemplatePlugin.js +1 -1
- package/package.json +20 -22
package/README.md
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
[![builds2][builds2]][builds2-url]
|
15
15
|
[![coverage][cover]][cover-url]
|
16
16
|
[![licenses][licenses]][licenses-url]
|
17
|
+
[![PR's welcome][prs]][prs-url]
|
17
18
|
|
18
19
|
<br>
|
19
20
|
<a href="https://dependabot.com/compatibility-score.html?dependency-name=webpack&package-manager=npm_and_yarn&new-version=latest">
|
@@ -346,7 +347,7 @@ If you create a loader or plugin, we would <3 for you to open source it, and put
|
|
346
347
|
|
347
348
|
<h2 align="center">Support</h2>
|
348
349
|
|
349
|
-
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
|
350
|
+
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
|
350
351
|
|
351
352
|
If you're just getting started, take a look at [our new docs and concepts page](https://webpack.js.org/concepts/). This has a high level overview that is great for beginners!!
|
352
353
|
|
@@ -767,6 +768,9 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
|
|
767
768
|
[tests]: https://img.shields.io/travis/webpack/webpack/master.svg
|
768
769
|
[tests-url]: https://travis-ci.org/webpack/webpack
|
769
770
|
|
771
|
+
[prs]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
772
|
+
[prs-url]: https://webpack.js.org/contribute/
|
773
|
+
|
770
774
|
[builds-url]: https://ci.appveyor.com/project/sokra/webpack/branch/master
|
771
775
|
[builds]: https://ci.appveyor.com/api/projects/status/github/webpack/webpack?svg=true
|
772
776
|
|
package/lib/BannerPlugin.js
CHANGED
@@ -81,7 +81,6 @@ class BannerPlugin {
|
|
81
81
|
continue;
|
82
82
|
}
|
83
83
|
|
84
|
-
let basename;
|
85
84
|
let query = "";
|
86
85
|
let filename = file;
|
87
86
|
const hash = compilation.hash;
|
@@ -94,11 +93,10 @@ class BannerPlugin {
|
|
94
93
|
|
95
94
|
const lastSlashIndex = filename.lastIndexOf("/");
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}
|
96
|
+
const basename =
|
97
|
+
lastSlashIndex === -1
|
98
|
+
? filename
|
99
|
+
: filename.substr(lastSlashIndex + 1);
|
102
100
|
|
103
101
|
const data = {
|
104
102
|
hash,
|
package/lib/CachePlugin.js
CHANGED
@@ -24,21 +24,19 @@ class CachePlugin {
|
|
24
24
|
compilation.hooks.childCompiler.tap(
|
25
25
|
"CachePlugin",
|
26
26
|
(childCompiler, compilerName, compilerIndex) => {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
cache.children = {};
|
31
|
-
}
|
32
|
-
if (!cache.children[compilerName]) {
|
33
|
-
cache.children[compilerName] = [];
|
34
|
-
}
|
35
|
-
if (cache.children[compilerName][compilerIndex]) {
|
36
|
-
childCache = cache.children[compilerName][compilerIndex];
|
37
|
-
} else {
|
38
|
-
cache.children[compilerName].push((childCache = {}));
|
39
|
-
}
|
40
|
-
registerCacheToCompiler(childCompiler, childCache);
|
27
|
+
let childCache;
|
28
|
+
if (!cache.children) {
|
29
|
+
cache.children = {};
|
41
30
|
}
|
31
|
+
if (!cache.children[compilerName]) {
|
32
|
+
cache.children[compilerName] = [];
|
33
|
+
}
|
34
|
+
if (cache.children[compilerName][compilerIndex]) {
|
35
|
+
childCache = cache.children[compilerName][compilerIndex];
|
36
|
+
} else {
|
37
|
+
cache.children[compilerName].push((childCache = {}));
|
38
|
+
}
|
39
|
+
registerCacheToCompiler(childCompiler, childCache);
|
42
40
|
}
|
43
41
|
);
|
44
42
|
});
|
package/lib/ChunkGroup.js
CHANGED
@@ -70,12 +70,12 @@ class ChunkGroup {
|
|
70
70
|
this.chunks = [];
|
71
71
|
/** @type {OriginRecord[]} */
|
72
72
|
this.origins = [];
|
73
|
-
/**
|
73
|
+
/** Indices in top-down order */
|
74
74
|
/** @private @type {Map<Module, number>} */
|
75
|
-
this.
|
76
|
-
/**
|
75
|
+
this._moduleIndices = new Map();
|
76
|
+
/** Indices in bottom-up order */
|
77
77
|
/** @private @type {Map<Module, number>} */
|
78
|
-
this.
|
78
|
+
this._moduleIndices2 = new Map();
|
79
79
|
}
|
80
80
|
|
81
81
|
/**
|
@@ -174,7 +174,7 @@ class ChunkGroup {
|
|
174
174
|
/**
|
175
175
|
* add a chunk into ChunkGroup. Is pushed on or prepended
|
176
176
|
* @param {Chunk} chunk chunk being pushed into ChunkGroupS
|
177
|
-
* @returns {boolean} returns true if chunk addition was
|
177
|
+
* @returns {boolean} returns true if chunk addition was successful.
|
178
178
|
*/
|
179
179
|
pushChunk(chunk) {
|
180
180
|
const oldIdx = this.chunks.indexOf(chunk);
|
@@ -187,8 +187,8 @@ class ChunkGroup {
|
|
187
187
|
|
188
188
|
/**
|
189
189
|
* @param {Chunk} oldChunk chunk to be replaced
|
190
|
-
* @param {Chunk} newChunk New
|
191
|
-
* @returns {boolean}
|
190
|
+
* @param {Chunk} newChunk New chunk that will be replaced with
|
191
|
+
* @returns {boolean} returns true if the replacement was successful
|
192
192
|
*/
|
193
193
|
replaceChunk(oldChunk, newChunk) {
|
194
194
|
const oldIdx = this.chunks.indexOf(oldChunk);
|
@@ -369,7 +369,7 @@ class ChunkGroup {
|
|
369
369
|
|
370
370
|
/**
|
371
371
|
* we need to iterate again over the children
|
372
|
-
* to remove this from the
|
372
|
+
* to remove this from the child's parents.
|
373
373
|
* This can not be done in the above loop
|
374
374
|
* as it is not guaranteed that `this._parents` contains anything.
|
375
375
|
*/
|
@@ -460,7 +460,7 @@ class ChunkGroup {
|
|
460
460
|
* @returns {void}
|
461
461
|
*/
|
462
462
|
setModuleIndex(module, index) {
|
463
|
-
this.
|
463
|
+
this._moduleIndices.set(module, index);
|
464
464
|
}
|
465
465
|
|
466
466
|
/**
|
@@ -469,7 +469,7 @@ class ChunkGroup {
|
|
469
469
|
* @returns {number} index
|
470
470
|
*/
|
471
471
|
getModuleIndex(module) {
|
472
|
-
return this.
|
472
|
+
return this._moduleIndices.get(module);
|
473
473
|
}
|
474
474
|
|
475
475
|
/**
|
@@ -479,7 +479,7 @@ class ChunkGroup {
|
|
479
479
|
* @returns {void}
|
480
480
|
*/
|
481
481
|
setModuleIndex2(module, index) {
|
482
|
-
this.
|
482
|
+
this._moduleIndices2.set(module, index);
|
483
483
|
}
|
484
484
|
|
485
485
|
/**
|
@@ -488,7 +488,7 @@ class ChunkGroup {
|
|
488
488
|
* @returns {number} index
|
489
489
|
*/
|
490
490
|
getModuleIndex2(module) {
|
491
|
-
return this.
|
491
|
+
return this._moduleIndices2.get(module);
|
492
492
|
}
|
493
493
|
|
494
494
|
checkConstraints() {
|
package/lib/Compilation.js
CHANGED
@@ -913,11 +913,6 @@ class Compilation extends Tapable {
|
|
913
913
|
iterationDependencies(dependencies);
|
914
914
|
|
915
915
|
const afterBuild = () => {
|
916
|
-
if (currentProfile) {
|
917
|
-
const afterBuilding = Date.now();
|
918
|
-
currentProfile.building = afterBuilding - afterFactory;
|
919
|
-
}
|
920
|
-
|
921
916
|
if (recursive && addModuleResult.dependencies) {
|
922
917
|
this.processModuleDependencies(dependentModule, callback);
|
923
918
|
} else {
|
@@ -1059,11 +1054,6 @@ class Compilation extends Tapable {
|
|
1059
1054
|
module.addReason(null, dependency);
|
1060
1055
|
|
1061
1056
|
const afterBuild = () => {
|
1062
|
-
if (currentProfile) {
|
1063
|
-
const afterBuilding = Date.now();
|
1064
|
-
currentProfile.building = afterBuilding - afterFactory;
|
1065
|
-
}
|
1066
|
-
|
1067
1057
|
if (addModuleResult.dependencies) {
|
1068
1058
|
this.processModuleDependencies(module, err => {
|
1069
1059
|
if (err) return callback(err);
|
package/lib/Compiler.js
CHANGED
@@ -55,6 +55,8 @@ class Compiler extends Tapable {
|
|
55
55
|
run: new AsyncSeriesHook(["compiler"]),
|
56
56
|
/** @type {AsyncSeriesHook<Compilation>} */
|
57
57
|
emit: new AsyncSeriesHook(["compilation"]),
|
58
|
+
/** @type {AsyncSeriesHook<string, Buffer>} */
|
59
|
+
assetEmitted: new AsyncSeriesHook(["file", "content"]),
|
58
60
|
/** @type {AsyncSeriesHook<Compilation>} */
|
59
61
|
afterEmit: new AsyncSeriesHook(["compilation"]),
|
60
62
|
|
@@ -86,7 +88,7 @@ class Compiler extends Tapable {
|
|
86
88
|
watchClose: new SyncHook([]),
|
87
89
|
|
88
90
|
/** @type {SyncBailHook<string, string, any[]>} */
|
89
|
-
|
91
|
+
infrastructureLog: new SyncBailHook(["origin", "type", "args"]),
|
90
92
|
|
91
93
|
// TODO the following hooks are weirdly located here
|
92
94
|
// TODO move them for webpack 5
|
@@ -101,6 +103,8 @@ class Compiler extends Tapable {
|
|
101
103
|
/** @type {SyncBailHook<string, Entry>} */
|
102
104
|
entryOption: new SyncBailHook(["context", "entry"])
|
103
105
|
};
|
106
|
+
// TODO webpack 5 remove this
|
107
|
+
this.hooks.infrastructurelog = this.hooks.infrastructureLog;
|
104
108
|
|
105
109
|
this._pluginCompat.tap("Compiler", options => {
|
106
110
|
switch (options.name) {
|
@@ -221,7 +225,7 @@ class Compiler extends Tapable {
|
|
221
225
|
);
|
222
226
|
}
|
223
227
|
}
|
224
|
-
if (this.hooks.
|
228
|
+
if (this.hooks.infrastructureLog.call(name, type, args) === undefined) {
|
225
229
|
if (this.infrastructureLogger !== undefined) {
|
226
230
|
this.infrastructureLogger(name, type, args);
|
227
231
|
}
|
@@ -430,7 +434,7 @@ class Compiler extends Tapable {
|
|
430
434
|
: targetFileGeneration + 1;
|
431
435
|
cacheEntry.writtenTo.set(targetPath, newGeneration);
|
432
436
|
this._assetEmittingWrittenFiles.set(targetPath, newGeneration);
|
433
|
-
callback
|
437
|
+
this.hooks.assetEmitted.callAsync(file, content, callback);
|
434
438
|
});
|
435
439
|
} else {
|
436
440
|
if (source.existsAt === targetPath) {
|
@@ -445,7 +449,10 @@ class Compiler extends Tapable {
|
|
445
449
|
|
446
450
|
source.existsAt = targetPath;
|
447
451
|
source.emitted = true;
|
448
|
-
this.outputFileSystem.writeFile(targetPath, content,
|
452
|
+
this.outputFileSystem.writeFile(targetPath, content, err => {
|
453
|
+
if (err) return callback(err);
|
454
|
+
this.hooks.assetEmitted.callAsync(file, content, callback);
|
455
|
+
});
|
449
456
|
}
|
450
457
|
};
|
451
458
|
|
package/lib/Entrypoint.js
CHANGED
@@ -52,8 +52,8 @@ class Entrypoint extends ChunkGroup {
|
|
52
52
|
|
53
53
|
/**
|
54
54
|
* @param {Chunk} oldChunk chunk to be replaced
|
55
|
-
* @param {Chunk} newChunk New
|
56
|
-
* @returns {boolean}
|
55
|
+
* @param {Chunk} newChunk New chunk that will be replaced with
|
56
|
+
* @returns {boolean} returns true if the replacement was successful
|
57
57
|
*/
|
58
58
|
replaceChunk(oldChunk, newChunk) {
|
59
59
|
if (this.runtimeChunk === oldChunk) this.runtimeChunk = newChunk;
|
package/lib/MultiCompiler.js
CHANGED
@@ -18,7 +18,10 @@ module.exports = class MultiCompiler extends Tapable {
|
|
18
18
|
invalid: new MultiHook(compilers.map(c => c.hooks.invalid)),
|
19
19
|
run: new MultiHook(compilers.map(c => c.hooks.run)),
|
20
20
|
watchClose: new SyncHook([]),
|
21
|
-
watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun))
|
21
|
+
watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun)),
|
22
|
+
infrastructureLog: new MultiHook(
|
23
|
+
compilers.map(c => c.hooks.infrastructureLog)
|
24
|
+
)
|
22
25
|
};
|
23
26
|
if (!Array.isArray(compilers)) {
|
24
27
|
compilers = Object.keys(compilers).map(name => {
|
@@ -90,6 +93,10 @@ module.exports = class MultiCompiler extends Tapable {
|
|
90
93
|
}
|
91
94
|
}
|
92
95
|
|
96
|
+
getInfrastructureLogger(name) {
|
97
|
+
return this.compilers[0].getInfrastructureLogger(name);
|
98
|
+
}
|
99
|
+
|
93
100
|
validateDependencies(callback) {
|
94
101
|
const edges = new Set();
|
95
102
|
const missing = [];
|
package/lib/ProgressPlugin.js
CHANGED
@@ -10,50 +10,14 @@ const schema = require("../schemas/plugins/ProgressPlugin.json");
|
|
10
10
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginArgument} ProgressPluginArgument */
|
11
11
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginOptions} ProgressPluginOptions */
|
12
12
|
|
13
|
-
const createDefaultHandler = profile => {
|
14
|
-
let lineCaretPosition = 0;
|
15
|
-
let lastMessage = "";
|
13
|
+
const createDefaultHandler = (profile, logger) => {
|
16
14
|
let lastState;
|
17
15
|
let lastStateTime;
|
18
16
|
|
19
17
|
const defaultHandler = (percentage, msg, ...args) => {
|
20
|
-
|
21
|
-
const details = args.filter(v => v.length);
|
22
|
-
const maxLineLength = process.stderr.columns || Infinity;
|
23
|
-
if (percentage < 1) {
|
24
|
-
percentage = Math.floor(percentage * 100);
|
25
|
-
msg = `${percentage}% ${msg}`;
|
26
|
-
if (percentage < 100) {
|
27
|
-
msg = ` ${msg}`;
|
28
|
-
}
|
29
|
-
if (percentage < 10) {
|
30
|
-
msg = ` ${msg}`;
|
31
|
-
}
|
32
|
-
|
33
|
-
if (details.length) {
|
34
|
-
const maxTotalDetailsLength = maxLineLength - msg.length;
|
35
|
-
const totalDetailsLength = details.reduce(
|
36
|
-
(a, b) => a + b.length,
|
37
|
-
details.length // account for added space before each detail text
|
38
|
-
);
|
39
|
-
const maxDetailLength =
|
40
|
-
totalDetailsLength < maxTotalDetailsLength
|
41
|
-
? Infinity
|
42
|
-
: Math.floor(maxTotalDetailsLength / details.length);
|
43
|
-
|
44
|
-
for (let detail of details) {
|
45
|
-
if (!detail) continue;
|
46
|
-
if (detail.length + 1 > maxDetailLength) {
|
47
|
-
const truncatePrefix = "...";
|
48
|
-
detail = `${truncatePrefix}${detail.substr(
|
49
|
-
-(maxDetailLength - truncatePrefix.length - 1)
|
50
|
-
)}`;
|
51
|
-
}
|
52
|
-
msg += ` ${detail}`;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
18
|
+
logger.status(`${Math.floor(percentage * 100)}%`, msg, ...args);
|
56
19
|
if (profile) {
|
20
|
+
let state = msg;
|
57
21
|
state = state.replace(/^\d+\/\d+\s+/, "");
|
58
22
|
if (percentage === 0) {
|
59
23
|
lastState = null;
|
@@ -61,33 +25,23 @@ const createDefaultHandler = profile => {
|
|
61
25
|
} else if (state !== lastState || percentage === 1) {
|
62
26
|
const now = Date.now();
|
63
27
|
if (lastState) {
|
64
|
-
const
|
65
|
-
|
66
|
-
|
67
|
-
|
28
|
+
const diff = now - lastStateTime;
|
29
|
+
const stateMsg = `${diff}ms ${lastState}`;
|
30
|
+
if (diff > 1000) {
|
31
|
+
logger.warn(stateMsg);
|
32
|
+
} else if (diff > 10) {
|
33
|
+
logger.info(stateMsg);
|
34
|
+
} else if (diff > 0) {
|
35
|
+
logger.log(stateMsg);
|
36
|
+
} else {
|
37
|
+
logger.debug(stateMsg);
|
38
|
+
}
|
68
39
|
}
|
69
40
|
lastState = state;
|
70
41
|
lastStateTime = now;
|
71
42
|
}
|
72
43
|
}
|
73
|
-
if (
|
74
|
-
goToLineStart(msg);
|
75
|
-
msg = msg.substring(0, maxLineLength);
|
76
|
-
process.stderr.write(msg);
|
77
|
-
lastMessage = msg;
|
78
|
-
}
|
79
|
-
};
|
80
|
-
|
81
|
-
const goToLineStart = nextMessage => {
|
82
|
-
let str = "";
|
83
|
-
for (; lineCaretPosition > nextMessage.length; lineCaretPosition--) {
|
84
|
-
str += "\b \b";
|
85
|
-
}
|
86
|
-
for (var i = 0; i < lineCaretPosition; i++) {
|
87
|
-
str += "\b";
|
88
|
-
}
|
89
|
-
lineCaretPosition = nextMessage.length;
|
90
|
-
if (str) process.stderr.write(str);
|
44
|
+
if (percentage === 1) logger.status();
|
91
45
|
};
|
92
46
|
|
93
47
|
return defaultHandler;
|
@@ -118,7 +72,12 @@ class ProgressPlugin {
|
|
118
72
|
|
119
73
|
apply(compiler) {
|
120
74
|
const { modulesCount } = this;
|
121
|
-
const handler =
|
75
|
+
const handler =
|
76
|
+
this.handler ||
|
77
|
+
createDefaultHandler(
|
78
|
+
this.profile,
|
79
|
+
compiler.getInfrastructureLogger("webpack.Progress")
|
80
|
+
);
|
122
81
|
const showEntries = this.showEntries;
|
123
82
|
const showModules = this.showModules;
|
124
83
|
const showActiveModules = this.showActiveModules;
|
package/lib/Stats.js
CHANGED
@@ -755,6 +755,7 @@ class Stats {
|
|
755
755
|
LogType.profile,
|
756
756
|
LogType.profileEnd,
|
757
757
|
LogType.time,
|
758
|
+
LogType.status,
|
758
759
|
LogType.clear
|
759
760
|
]);
|
760
761
|
collapsedGroups = true;
|
@@ -1442,7 +1443,7 @@ class Stats {
|
|
1442
1443
|
let indent = "";
|
1443
1444
|
for (const entry of logData.entries) {
|
1444
1445
|
let color = colors.normal;
|
1445
|
-
let prefix = "";
|
1446
|
+
let prefix = " ";
|
1446
1447
|
switch (entry.type) {
|
1447
1448
|
case LogType.clear:
|
1448
1449
|
colors.normal(`${indent}-------`);
|
@@ -1467,6 +1468,10 @@ class Stats {
|
|
1467
1468
|
case LogType.debug:
|
1468
1469
|
color = colors.normal;
|
1469
1470
|
break;
|
1471
|
+
case LogType.status:
|
1472
|
+
color = colors.magenta;
|
1473
|
+
prefix = "<s> ";
|
1474
|
+
break;
|
1470
1475
|
case LogType.profile:
|
1471
1476
|
color = colors.magenta;
|
1472
1477
|
prefix = "<p> ";
|
@@ -1481,13 +1486,14 @@ class Stats {
|
|
1481
1486
|
break;
|
1482
1487
|
case LogType.group:
|
1483
1488
|
color = colors.cyan;
|
1489
|
+
prefix = "<-> ";
|
1484
1490
|
break;
|
1485
1491
|
case LogType.groupCollapsed:
|
1486
1492
|
color = colors.cyan;
|
1487
1493
|
prefix = "<+> ";
|
1488
1494
|
break;
|
1489
1495
|
case LogType.groupEnd:
|
1490
|
-
if (indent.length
|
1496
|
+
if (indent.length >= 2)
|
1491
1497
|
indent = indent.slice(0, indent.length - 2);
|
1492
1498
|
continue;
|
1493
1499
|
}
|
@@ -34,7 +34,11 @@ class SystemMainTemplatePlugin {
|
|
34
34
|
const externals = chunk.getModules().filter(m => m.external);
|
35
35
|
|
36
36
|
// The name this bundle should be registered as with System
|
37
|
-
const name = this.name
|
37
|
+
const name = this.name
|
38
|
+
? `${JSON.stringify(
|
39
|
+
mainTemplate.getAssetPath(this.name, { hash, chunk })
|
40
|
+
)}, `
|
41
|
+
: "";
|
38
42
|
|
39
43
|
// The array of dependencies that are external to webpack and will be provided by System
|
40
44
|
const systemDependencies = JSON.stringify(
|
@@ -47,12 +47,18 @@ const getReplacer = (value, allowEmpty) => {
|
|
47
47
|
}
|
48
48
|
return "";
|
49
49
|
} else {
|
50
|
-
return `${value}`;
|
50
|
+
return `${escapePathVariables(value)}`;
|
51
51
|
}
|
52
52
|
};
|
53
53
|
return fn;
|
54
54
|
};
|
55
55
|
|
56
|
+
const escapePathVariables = value => {
|
57
|
+
return typeof value === "string"
|
58
|
+
? value.replace(/\[(\\*[\w:]+\\*)\]/gi, "[\\$1\\]")
|
59
|
+
: value;
|
60
|
+
};
|
61
|
+
|
56
62
|
const replacePathVariables = (path, data) => {
|
57
63
|
const chunk = data.chunk;
|
58
64
|
const chunkId = chunk && chunk.id;
|
@@ -114,6 +120,7 @@ const replacePathVariables = (path, data) => {
|
|
114
120
|
.replace(REGEXP_QUERY, getReplacer(data.query, true))
|
115
121
|
// only available in sourceMappingURLComment
|
116
122
|
.replace(REGEXP_URL, getReplacer(data.url))
|
123
|
+
.replace(/\[\\(\\*[\w:]+\\*)\\\]/gi, "[$1]")
|
117
124
|
);
|
118
125
|
};
|
119
126
|
|
package/lib/buildChunkGraph.js
CHANGED
@@ -28,11 +28,13 @@ const GraphHelpers = require("./GraphHelpers");
|
|
28
28
|
|
29
29
|
/**
|
30
30
|
* @typedef {Object} ChunkGroupInfo
|
31
|
+
* @property {ChunkGroup} chunkGroup the chunk group
|
31
32
|
* @property {Set<Module>} minAvailableModules current minimal set of modules available at this point
|
32
33
|
* @property {boolean} minAvailableModulesOwned true, if minAvailableModules is owned and can be modified
|
33
34
|
* @property {Set<Module>[]} availableModulesToBeMerged enqueued updates to the minimal set of available modules
|
34
35
|
* @property {QueueItem[]} skippedItems queue items that were skipped because module is already available in parent chunks (need to reconsider when minAvailableModules is shrinking)
|
35
36
|
* @property {Set<Module>} resultingAvailableModules set of modules available including modules from this chunk group
|
37
|
+
* @property {Set<ChunkGroup>} children set of children chunk groups, that will be revisited when availableModules shrink
|
36
38
|
*/
|
37
39
|
|
38
40
|
/**
|
@@ -196,11 +198,13 @@ const visitModules = (
|
|
196
198
|
});
|
197
199
|
}
|
198
200
|
chunkGroupInfoMap.set(chunkGroup, {
|
201
|
+
chunkGroup,
|
199
202
|
minAvailableModules: new Set(),
|
200
203
|
minAvailableModulesOwned: true,
|
201
204
|
availableModulesToBeMerged: [],
|
202
205
|
skippedItems: [],
|
203
|
-
resultingAvailableModules: undefined
|
206
|
+
resultingAvailableModules: undefined,
|
207
|
+
children: undefined
|
204
208
|
});
|
205
209
|
return queue;
|
206
210
|
};
|
@@ -418,7 +422,7 @@ const visitModules = (
|
|
418
422
|
}
|
419
423
|
logger.timeEnd("visiting");
|
420
424
|
|
421
|
-
|
425
|
+
while (queueConnect.size > 0) {
|
422
426
|
logger.time("calculating available modules");
|
423
427
|
|
424
428
|
// Figure out new parents for chunk groups
|
@@ -435,17 +439,26 @@ const visitModules = (
|
|
435
439
|
}
|
436
440
|
}
|
437
441
|
info.resultingAvailableModules = resultingAvailableModules;
|
442
|
+
if (info.children === undefined) {
|
443
|
+
info.children = targets;
|
444
|
+
} else {
|
445
|
+
for (const target of targets) {
|
446
|
+
info.children.add(target);
|
447
|
+
}
|
448
|
+
}
|
438
449
|
|
439
450
|
// 2. Update chunk group info
|
440
451
|
for (const target of targets) {
|
441
452
|
let chunkGroupInfo = chunkGroupInfoMap.get(target);
|
442
453
|
if (chunkGroupInfo === undefined) {
|
443
454
|
chunkGroupInfo = {
|
455
|
+
chunkGroup: target,
|
444
456
|
minAvailableModules: undefined,
|
445
457
|
minAvailableModulesOwned: undefined,
|
446
458
|
availableModulesToBeMerged: [],
|
447
459
|
skippedItems: [],
|
448
|
-
resultingAvailableModules: undefined
|
460
|
+
resultingAvailableModules: undefined,
|
461
|
+
children: undefined
|
449
462
|
};
|
450
463
|
chunkGroupInfoMap.set(target, chunkGroupInfo);
|
451
464
|
}
|
@@ -463,7 +476,7 @@ const visitModules = (
|
|
463
476
|
// Execute the merge
|
464
477
|
for (const info of outdatedChunkGroupInfo) {
|
465
478
|
const availableModulesToBeMerged = info.availableModulesToBeMerged;
|
466
|
-
let
|
479
|
+
let cachedMinAvailableModules = info.minAvailableModules;
|
467
480
|
|
468
481
|
// 1. Get minimal available modules
|
469
482
|
// It doesn't make sense to traverse a chunk again with more available modules.
|
@@ -474,29 +487,31 @@ const visitModules = (
|
|
474
487
|
}
|
475
488
|
let changed = false;
|
476
489
|
for (const availableModules of availableModulesToBeMerged) {
|
477
|
-
if (
|
478
|
-
|
479
|
-
info.minAvailableModules =
|
490
|
+
if (cachedMinAvailableModules === undefined) {
|
491
|
+
cachedMinAvailableModules = availableModules;
|
492
|
+
info.minAvailableModules = cachedMinAvailableModules;
|
480
493
|
info.minAvailableModulesOwned = false;
|
481
494
|
changed = true;
|
482
495
|
} else {
|
483
496
|
if (info.minAvailableModulesOwned) {
|
484
497
|
// We own it and can modify it
|
485
|
-
for (const m of
|
498
|
+
for (const m of cachedMinAvailableModules) {
|
486
499
|
if (!availableModules.has(m)) {
|
487
|
-
|
500
|
+
cachedMinAvailableModules.delete(m);
|
488
501
|
changed = true;
|
489
502
|
}
|
490
503
|
}
|
491
504
|
} else {
|
492
|
-
for (const m of
|
505
|
+
for (const m of cachedMinAvailableModules) {
|
493
506
|
if (!availableModules.has(m)) {
|
494
|
-
//
|
507
|
+
// cachedMinAvailableModules need to be modified
|
495
508
|
// but we don't own it
|
496
|
-
// construct a new Set as intersection of
|
509
|
+
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
497
510
|
/** @type {Set<Module>} */
|
498
511
|
const newSet = new Set();
|
499
|
-
const iterator =
|
512
|
+
const iterator = cachedMinAvailableModules[
|
513
|
+
Symbol.iterator
|
514
|
+
]();
|
500
515
|
/** @type {IteratorResult<Module>} */
|
501
516
|
let it;
|
502
517
|
while (!(it = iterator.next()).done) {
|
@@ -510,9 +525,16 @@ const visitModules = (
|
|
510
525
|
newSet.add(module);
|
511
526
|
}
|
512
527
|
}
|
513
|
-
|
528
|
+
cachedMinAvailableModules = newSet;
|
514
529
|
info.minAvailableModulesOwned = true;
|
515
530
|
info.minAvailableModules = newSet;
|
531
|
+
|
532
|
+
// Update the cache from the first queue
|
533
|
+
// if the chunkGroup is currently cached
|
534
|
+
if (chunkGroup === info.chunkGroup) {
|
535
|
+
minAvailableModules = cachedMinAvailableModules;
|
536
|
+
}
|
537
|
+
|
516
538
|
changed = true;
|
517
539
|
break;
|
518
540
|
}
|
@@ -528,6 +550,19 @@ const visitModules = (
|
|
528
550
|
queue.push(queueItem);
|
529
551
|
}
|
530
552
|
info.skippedItems.length = 0;
|
553
|
+
|
554
|
+
// 3. Reconsider children chunk groups
|
555
|
+
if (info.children !== undefined) {
|
556
|
+
const chunkGroup = info.chunkGroup;
|
557
|
+
for (const c of info.children) {
|
558
|
+
let connectList = queueConnect.get(chunkGroup);
|
559
|
+
if (connectList === undefined) {
|
560
|
+
connectList = new Set();
|
561
|
+
queueConnect.set(chunkGroup, connectList);
|
562
|
+
}
|
563
|
+
connectList.add(c);
|
564
|
+
}
|
565
|
+
}
|
531
566
|
}
|
532
567
|
outdatedChunkGroupInfo.clear();
|
533
568
|
logger.timeEnd("merging available modules");
|
@@ -391,8 +391,8 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
|
|
391
391
|
id,
|
392
392
|
cat: defaultCategory
|
393
393
|
});
|
394
|
+
const callback = args.pop();
|
394
395
|
fn(...args, (...r) => {
|
395
|
-
const callback = args.pop();
|
396
396
|
tracer.trace.end({
|
397
397
|
name,
|
398
398
|
id,
|
package/lib/logging/Logger.js
CHANGED
@@ -26,7 +26,8 @@ const LogType = Object.freeze({
|
|
26
26
|
|
27
27
|
time: "time", // name, time as [seconds, nanoseconds]
|
28
28
|
|
29
|
-
clear: "clear" // no arguments
|
29
|
+
clear: "clear", // no arguments
|
30
|
+
status: "status" // message, arguments
|
30
31
|
});
|
31
32
|
|
32
33
|
exports.LogType = LogType;
|
@@ -78,6 +79,10 @@ class WebpackLogger {
|
|
78
79
|
this[LOG_SYMBOL](LogType.clear);
|
79
80
|
}
|
80
81
|
|
82
|
+
status(...args) {
|
83
|
+
this[LOG_SYMBOL](LogType.status, args);
|
84
|
+
}
|
85
|
+
|
81
86
|
group(...args) {
|
82
87
|
this[LOG_SYMBOL](LogType.group, args);
|
83
88
|
}
|
@@ -15,8 +15,9 @@ const { LogType } = require("./Logger");
|
|
15
15
|
|
16
16
|
/**
|
17
17
|
* @typedef {Object} LoggerOptions
|
18
|
-
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"}
|
19
|
-
* @property {FilterTypes|boolean}
|
18
|
+
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel
|
19
|
+
* @property {FilterTypes|boolean} debug filter for debug logging
|
20
|
+
* @property {Console & { status?: Function, logTime?: Function }} console the console to log to
|
20
21
|
*/
|
21
22
|
|
22
23
|
/**
|
@@ -62,7 +63,7 @@ const LogLevel = {
|
|
62
63
|
* @param {LoggerOptions} options options object
|
63
64
|
* @returns {function(string, LogTypeEnum, any[]): void} logging function
|
64
65
|
*/
|
65
|
-
module.exports = ({ level = "info", debug = false }) => {
|
66
|
+
module.exports = ({ level = "info", debug = false, console }) => {
|
66
67
|
const debugFilters =
|
67
68
|
typeof debug === "boolean"
|
68
69
|
? [() => debug]
|
@@ -79,12 +80,12 @@ module.exports = ({ level = "info", debug = false }) => {
|
|
79
80
|
* @returns {void}
|
80
81
|
*/
|
81
82
|
const logger = (name, type, args) => {
|
82
|
-
const labeledArgs = (
|
83
|
+
const labeledArgs = () => {
|
83
84
|
if (Array.isArray(args)) {
|
84
85
|
if (args.length > 0 && typeof args[0] === "string") {
|
85
|
-
return [
|
86
|
+
return [`[${name}] ${args[0]}`, ...args.slice(1)];
|
86
87
|
} else {
|
87
|
-
return [
|
88
|
+
return [`[${name}]`, ...args];
|
88
89
|
}
|
89
90
|
} else {
|
90
91
|
return [];
|
@@ -108,20 +109,33 @@ module.exports = ({ level = "info", debug = false }) => {
|
|
108
109
|
break;
|
109
110
|
case LogType.info:
|
110
111
|
if (!debug && loglevel > LogLevel.info) return;
|
111
|
-
console.info(...labeledArgs(
|
112
|
+
console.info(...labeledArgs());
|
112
113
|
break;
|
113
114
|
case LogType.warn:
|
114
115
|
if (!debug && loglevel > LogLevel.warn) return;
|
115
|
-
console.warn(...labeledArgs(
|
116
|
+
console.warn(...labeledArgs());
|
116
117
|
break;
|
117
118
|
case LogType.error:
|
118
119
|
if (!debug && loglevel > LogLevel.error) return;
|
119
|
-
console.error(...labeledArgs(
|
120
|
+
console.error(...labeledArgs());
|
120
121
|
break;
|
121
122
|
case LogType.trace:
|
122
123
|
if (!debug) return;
|
123
124
|
console.trace();
|
124
125
|
break;
|
126
|
+
case LogType.groupCollapsed:
|
127
|
+
if (!debug && loglevel > LogLevel.log) return;
|
128
|
+
if (!debug && loglevel > LogLevel.verbose) {
|
129
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
130
|
+
if (typeof console.groupCollapsed === "function") {
|
131
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
132
|
+
console.groupCollapsed(...labeledArgs());
|
133
|
+
} else {
|
134
|
+
console.log(...labeledArgs());
|
135
|
+
}
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
// falls through
|
125
139
|
case LogType.group:
|
126
140
|
if (!debug && loglevel > LogLevel.log) return;
|
127
141
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
@@ -132,32 +146,25 @@ module.exports = ({ level = "info", debug = false }) => {
|
|
132
146
|
console.log(...labeledArgs());
|
133
147
|
}
|
134
148
|
break;
|
135
|
-
case LogType.groupCollapsed:
|
136
|
-
if (!debug && loglevel > LogLevel.log) return;
|
137
|
-
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
138
|
-
if (typeof console.groupCollapsed === "function") {
|
139
|
-
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
140
|
-
console.groupCollapsed(...labeledArgs());
|
141
|
-
} else {
|
142
|
-
console.log(...labeledArgs("<g> "));
|
143
|
-
}
|
144
|
-
break;
|
145
149
|
case LogType.groupEnd:
|
146
150
|
if (!debug && loglevel > LogLevel.log) return;
|
147
151
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
148
152
|
if (typeof console.groupEnd === "function") {
|
149
153
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
150
154
|
console.groupEnd();
|
151
|
-
} else {
|
152
|
-
console.log(...labeledArgs("</g> "));
|
153
155
|
}
|
154
156
|
break;
|
155
|
-
case LogType.time:
|
157
|
+
case LogType.time: {
|
156
158
|
if (!debug && loglevel > LogLevel.log) return;
|
157
|
-
|
158
|
-
|
159
|
-
)
|
159
|
+
const ms = args[1] * 1000 + args[2] / 1000000;
|
160
|
+
const msg = `[${name}] ${args[0]}: ${ms}ms`;
|
161
|
+
if (typeof console.logTime === "function") {
|
162
|
+
console.logTime(msg);
|
163
|
+
} else {
|
164
|
+
console.log(msg);
|
165
|
+
}
|
160
166
|
break;
|
167
|
+
}
|
161
168
|
case LogType.profile:
|
162
169
|
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
163
170
|
if (typeof console.profile === "function") {
|
@@ -180,6 +187,20 @@ module.exports = ({ level = "info", debug = false }) => {
|
|
180
187
|
console.clear();
|
181
188
|
}
|
182
189
|
break;
|
190
|
+
case LogType.status:
|
191
|
+
if (!debug && loglevel > LogLevel.info) return;
|
192
|
+
if (typeof console.status === "function") {
|
193
|
+
if (args.length === 0) {
|
194
|
+
console.status();
|
195
|
+
} else {
|
196
|
+
console.status(...labeledArgs());
|
197
|
+
}
|
198
|
+
} else {
|
199
|
+
if (args.length !== 0) {
|
200
|
+
console.info(...labeledArgs());
|
201
|
+
}
|
202
|
+
}
|
203
|
+
break;
|
183
204
|
default:
|
184
205
|
throw new Error(`Unexpected LogType ${type}`);
|
185
206
|
}
|
package/lib/logging/runtime.js
CHANGED
@@ -5,7 +5,8 @@ const createConsoleLogger = require("./createConsoleLogger");
|
|
5
5
|
/** @type {createConsoleLogger.LoggerOptions} */
|
6
6
|
let currentDefaultLoggerOptions = {
|
7
7
|
level: "info",
|
8
|
-
debug: false
|
8
|
+
debug: false,
|
9
|
+
console
|
9
10
|
};
|
10
11
|
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
11
12
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @param {any[]} args items to be truncated
|
10
|
+
* @param {number} maxLength maximum length of args including spaces between
|
11
|
+
* @returns {string[]} truncated args
|
12
|
+
*/
|
13
|
+
const truncateArgs = (args, maxLength) => {
|
14
|
+
const lengths = args.map(a => `${a}`.length);
|
15
|
+
const availableLength = maxLength - lengths.length + 1;
|
16
|
+
|
17
|
+
if (availableLength > 0 && args.length === 1) {
|
18
|
+
if (availableLength >= args[0].length) {
|
19
|
+
return args;
|
20
|
+
} else if (availableLength > 3) {
|
21
|
+
return ["..." + args[0].slice(-availableLength + 3)];
|
22
|
+
} else {
|
23
|
+
return [args[0].slice(-availableLength)];
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// Check if there is space for at least 4 chars per arg
|
28
|
+
if (availableLength < lengths.reduce((s, i) => s + Math.min(i, 6), 0)) {
|
29
|
+
// remove args
|
30
|
+
if (args.length > 1)
|
31
|
+
return truncateArgs(args.slice(0, args.length - 1), maxLength);
|
32
|
+
return [];
|
33
|
+
}
|
34
|
+
|
35
|
+
let currentLength = lengths.reduce((a, b) => a + b, 0);
|
36
|
+
|
37
|
+
// Check if all fits into maxLength
|
38
|
+
if (currentLength <= availableLength) return args;
|
39
|
+
|
40
|
+
// Try to remove chars from the longest items until it fits
|
41
|
+
while (currentLength > availableLength) {
|
42
|
+
const maxLength = Math.max(...lengths);
|
43
|
+
const shorterItems = lengths.filter(l => l !== maxLength);
|
44
|
+
const nextToMaxLength =
|
45
|
+
shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
|
46
|
+
const maxReduce = maxLength - nextToMaxLength;
|
47
|
+
let maxItems = lengths.length - shorterItems.length;
|
48
|
+
let overrun = currentLength - availableLength;
|
49
|
+
for (let i = 0; i < lengths.length; i++) {
|
50
|
+
if (lengths[i] === maxLength) {
|
51
|
+
const reduce = Math.min(Math.floor(overrun / maxItems), maxReduce);
|
52
|
+
lengths[i] -= reduce;
|
53
|
+
currentLength -= reduce;
|
54
|
+
overrun -= reduce;
|
55
|
+
maxItems--;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
// Return args reduced to length in lengths
|
61
|
+
return args.map((a, i) => {
|
62
|
+
const str = `${a}`;
|
63
|
+
const length = lengths[i];
|
64
|
+
if (str.length === length) {
|
65
|
+
return str;
|
66
|
+
} else if (length > 5) {
|
67
|
+
return "..." + str.slice(-length + 3);
|
68
|
+
} else if (length > 0) {
|
69
|
+
return str.slice(-length);
|
70
|
+
} else {
|
71
|
+
return "";
|
72
|
+
}
|
73
|
+
});
|
74
|
+
};
|
75
|
+
|
76
|
+
module.exports = truncateArgs;
|
@@ -9,6 +9,7 @@ const NodeOutputFileSystem = require("./NodeOutputFileSystem");
|
|
9
9
|
const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
|
10
10
|
const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
|
11
11
|
const createConsoleLogger = require("../logging/createConsoleLogger");
|
12
|
+
const nodeConsole = require("./nodeConsole");
|
12
13
|
|
13
14
|
class NodeEnvironmentPlugin {
|
14
15
|
constructor(options) {
|
@@ -20,7 +21,8 @@ class NodeEnvironmentPlugin {
|
|
20
21
|
Object.assign(
|
21
22
|
{
|
22
23
|
level: "info",
|
23
|
-
debug: false
|
24
|
+
debug: false,
|
25
|
+
console: nodeConsole
|
24
26
|
},
|
25
27
|
this.options.infrastructureLogging
|
26
28
|
)
|
@@ -0,0 +1,135 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const truncateArgs = require("../logging/truncateArgs");
|
9
|
+
const util = require("util");
|
10
|
+
|
11
|
+
const tty = process.stderr.isTTY && process.env.TERM !== "dumb";
|
12
|
+
|
13
|
+
let currentStatusMessage = undefined;
|
14
|
+
let hasStatusMessage = false;
|
15
|
+
let currentIndent = "";
|
16
|
+
let currentCollapsed = 0;
|
17
|
+
|
18
|
+
const indent = (str, prefix, colorPrefix, colorSuffix) => {
|
19
|
+
if (str === "") return str;
|
20
|
+
prefix = currentIndent + prefix;
|
21
|
+
if (tty) {
|
22
|
+
return (
|
23
|
+
prefix +
|
24
|
+
colorPrefix +
|
25
|
+
str.replace(/\n/g, colorSuffix + "\n" + prefix + colorPrefix) +
|
26
|
+
colorSuffix
|
27
|
+
);
|
28
|
+
} else {
|
29
|
+
return prefix + str.replace(/\n/g, "\n" + prefix);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
const clearStatusMessage = () => {
|
34
|
+
if (hasStatusMessage) {
|
35
|
+
process.stderr.write("\x1b[2K\r");
|
36
|
+
hasStatusMessage = false;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
const writeStatusMessage = () => {
|
41
|
+
if (!currentStatusMessage) return;
|
42
|
+
const l = process.stderr.columns;
|
43
|
+
const args = l
|
44
|
+
? truncateArgs(currentStatusMessage, l - 1)
|
45
|
+
: currentStatusMessage;
|
46
|
+
const str = args.join(" ");
|
47
|
+
const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
|
48
|
+
process.stderr.write(`\x1b[2K\r${coloredStr}`);
|
49
|
+
hasStatusMessage = true;
|
50
|
+
};
|
51
|
+
|
52
|
+
const writeColored = (prefix, colorPrefix, colorSuffix) => {
|
53
|
+
return (...args) => {
|
54
|
+
if (currentCollapsed > 0) return;
|
55
|
+
clearStatusMessage();
|
56
|
+
// @ts-ignore
|
57
|
+
const str = indent(util.format(...args), prefix, colorPrefix, colorSuffix);
|
58
|
+
process.stderr.write(str + "\n");
|
59
|
+
writeStatusMessage();
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
const writeGroupMessage = writeColored(
|
64
|
+
"<-> ",
|
65
|
+
"\u001b[1m\u001b[36m",
|
66
|
+
"\u001b[39m\u001b[22m"
|
67
|
+
);
|
68
|
+
|
69
|
+
const writeGroupCollapsedMessage = writeColored(
|
70
|
+
"<+> ",
|
71
|
+
"\u001b[1m\u001b[36m",
|
72
|
+
"\u001b[39m\u001b[22m"
|
73
|
+
);
|
74
|
+
|
75
|
+
module.exports = {
|
76
|
+
log: writeColored(" ", "\u001b[1m", "\u001b[22m"),
|
77
|
+
debug: writeColored(" ", "", ""),
|
78
|
+
trace: writeColored(" ", "", ""),
|
79
|
+
info: writeColored("<i> ", "\u001b[1m\u001b[32m", "\u001b[39m\u001b[22m"),
|
80
|
+
warn: writeColored("<w> ", "\u001b[1m\u001b[33m", "\u001b[39m\u001b[22m"),
|
81
|
+
error: writeColored("<e> ", "\u001b[1m\u001b[31m", "\u001b[39m\u001b[22m"),
|
82
|
+
logTime: writeColored("<t> ", "\u001b[1m\u001b[35m", "\u001b[39m\u001b[22m"),
|
83
|
+
group: (...args) => {
|
84
|
+
writeGroupMessage(...args);
|
85
|
+
if (currentCollapsed > 0) {
|
86
|
+
currentCollapsed++;
|
87
|
+
} else {
|
88
|
+
currentIndent += " ";
|
89
|
+
}
|
90
|
+
},
|
91
|
+
groupCollapsed: (...args) => {
|
92
|
+
writeGroupCollapsedMessage(...args);
|
93
|
+
currentCollapsed++;
|
94
|
+
},
|
95
|
+
groupEnd: () => {
|
96
|
+
if (currentCollapsed > 0) currentCollapsed--;
|
97
|
+
else if (currentIndent.length >= 2)
|
98
|
+
currentIndent = currentIndent.slice(0, currentIndent.length - 2);
|
99
|
+
},
|
100
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
101
|
+
profile: console.profile && (name => console.profile(name)),
|
102
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
103
|
+
profileEnd: console.profileEnd && (name => console.profileEnd(name)),
|
104
|
+
clear:
|
105
|
+
tty &&
|
106
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
107
|
+
console.clear &&
|
108
|
+
(() => {
|
109
|
+
clearStatusMessage();
|
110
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
111
|
+
console.clear();
|
112
|
+
writeStatusMessage();
|
113
|
+
}),
|
114
|
+
status: tty
|
115
|
+
? (name, ...args) => {
|
116
|
+
args = args.filter(Boolean);
|
117
|
+
if (name === undefined && args.length === 0) {
|
118
|
+
clearStatusMessage();
|
119
|
+
currentStatusMessage = undefined;
|
120
|
+
} else if (
|
121
|
+
typeof name === "string" &&
|
122
|
+
name.startsWith("[webpack.Progress] ")
|
123
|
+
) {
|
124
|
+
currentStatusMessage = [name.slice(19), ...args];
|
125
|
+
writeStatusMessage();
|
126
|
+
} else if (name === "[webpack.Progress]") {
|
127
|
+
currentStatusMessage = [...args];
|
128
|
+
writeStatusMessage();
|
129
|
+
} else {
|
130
|
+
currentStatusMessage = [name, ...args];
|
131
|
+
writeStatusMessage();
|
132
|
+
}
|
133
|
+
}
|
134
|
+
: writeColored("<s> ", "", "")
|
135
|
+
};
|
@@ -70,7 +70,7 @@ const getImportedGlobals = ast => {
|
|
70
70
|
|
71
71
|
t.traverse(ast, {
|
72
72
|
ModuleImport({ node }) {
|
73
|
-
if (t.isGlobalType(node.descr)
|
73
|
+
if (t.isGlobalType(node.descr)) {
|
74
74
|
importedGlobals.push(node);
|
75
75
|
}
|
76
76
|
}
|
@@ -79,12 +79,18 @@ const getImportedGlobals = ast => {
|
|
79
79
|
return importedGlobals;
|
80
80
|
};
|
81
81
|
|
82
|
+
/**
|
83
|
+
* Get the count for imported func
|
84
|
+
*
|
85
|
+
* @param {Object} ast Module's AST
|
86
|
+
* @returns {Number} - count
|
87
|
+
*/
|
82
88
|
const getCountImportedFunc = ast => {
|
83
89
|
let count = 0;
|
84
90
|
|
85
91
|
t.traverse(ast, {
|
86
92
|
ModuleImport({ node }) {
|
87
|
-
if (t.isFuncImportDescr(node.descr)
|
93
|
+
if (t.isFuncImportDescr(node.descr)) {
|
88
94
|
count++;
|
89
95
|
}
|
90
96
|
}
|
@@ -133,7 +139,7 @@ const getNextFuncIndex = (ast, countImportedFunc) => {
|
|
133
139
|
};
|
134
140
|
|
135
141
|
/**
|
136
|
-
*
|
142
|
+
* Creates an init instruction for a global type
|
137
143
|
* @param {t.GlobalType} globalType the global type
|
138
144
|
* @returns {t.Instruction} init expression
|
139
145
|
*/
|
@@ -156,7 +162,7 @@ const createDefaultInitForGlobal = globalType => {
|
|
156
162
|
/**
|
157
163
|
* Rewrite the import globals:
|
158
164
|
* - removes the ModuleImport instruction
|
159
|
-
* - injects at the same offset a mutable global of the same
|
165
|
+
* - injects at the same offset a mutable global of the same type
|
160
166
|
*
|
161
167
|
* Since the imported globals are before the other global declarations, our
|
162
168
|
* indices will be preserved.
|
@@ -172,7 +178,7 @@ const rewriteImportedGlobals = state => bin => {
|
|
172
178
|
|
173
179
|
bin = editWithAST(state.ast, bin, {
|
174
180
|
ModuleImport(path) {
|
175
|
-
if (t.isGlobalType(path.node.descr)
|
181
|
+
if (t.isGlobalType(path.node.descr)) {
|
176
182
|
const globalType = path.node.descr;
|
177
183
|
|
178
184
|
globalType.mutability = "var";
|
@@ -206,8 +212,8 @@ const rewriteImportedGlobals = state => bin => {
|
|
206
212
|
|
207
213
|
additionalInitCode.push(
|
208
214
|
/**
|
209
|
-
* get_global in global
|
210
|
-
* They have the same indices
|
215
|
+
* get_global in global initializer only works for imported globals.
|
216
|
+
* They have the same indices as the init params, so use the
|
211
217
|
* same index.
|
212
218
|
*/
|
213
219
|
t.instruction("get_local", [initialGlobalidx]),
|
@@ -367,7 +367,7 @@ class JsonpMainTemplatePlugin {
|
|
367
367
|
"for(;i < chunkIds.length; i++) {",
|
368
368
|
Template.indent([
|
369
369
|
"chunkId = chunkIds[i];",
|
370
|
-
"if(installedChunks[chunkId]) {",
|
370
|
+
"if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {",
|
371
371
|
Template.indent("resolves.push(installedChunks[chunkId][0]);"),
|
372
372
|
"}",
|
373
373
|
"installedChunks[chunkId] = 0;"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.39.3",
|
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",
|
@@ -9,25 +9,25 @@
|
|
9
9
|
"@webassemblyjs/helper-module-context": "1.8.5",
|
10
10
|
"@webassemblyjs/wasm-edit": "1.8.5",
|
11
11
|
"@webassemblyjs/wasm-parser": "1.8.5",
|
12
|
-
"acorn": "^6.2.
|
13
|
-
"ajv": "^6.
|
14
|
-
"ajv-keywords": "^3.1
|
15
|
-
"chrome-trace-event": "^1.0.
|
12
|
+
"acorn": "^6.2.1",
|
13
|
+
"ajv": "^6.10.2",
|
14
|
+
"ajv-keywords": "^3.4.1",
|
15
|
+
"chrome-trace-event": "^1.0.2",
|
16
16
|
"enhanced-resolve": "^4.1.0",
|
17
|
-
"eslint-scope": "^4.0.
|
17
|
+
"eslint-scope": "^4.0.3",
|
18
18
|
"json-parse-better-errors": "^1.0.2",
|
19
|
-
"loader-runner": "^2.
|
20
|
-
"loader-utils": "^1.
|
21
|
-
"memory-fs": "
|
22
|
-
"micromatch": "^3.1.
|
23
|
-
"mkdirp": "
|
24
|
-
"neo-async": "^2.
|
25
|
-
"node-libs-browser": "^2.
|
19
|
+
"loader-runner": "^2.4.0",
|
20
|
+
"loader-utils": "^1.2.3",
|
21
|
+
"memory-fs": "^0.4.1",
|
22
|
+
"micromatch": "^3.1.10",
|
23
|
+
"mkdirp": "^0.5.1",
|
24
|
+
"neo-async": "^2.6.1",
|
25
|
+
"node-libs-browser": "^2.2.1",
|
26
26
|
"schema-utils": "^1.0.0",
|
27
|
-
"tapable": "^1.1.
|
28
|
-
"terser-webpack-plugin": "^1.1
|
29
|
-
"watchpack": "^1.
|
30
|
-
"webpack-sources": "^1.
|
27
|
+
"tapable": "^1.1.3",
|
28
|
+
"terser-webpack-plugin": "^1.4.1",
|
29
|
+
"watchpack": "^1.6.0",
|
30
|
+
"webpack-sources": "^1.4.1"
|
31
31
|
},
|
32
32
|
"devDependencies": {
|
33
33
|
"@types/node": "^10.12.21",
|
@@ -53,8 +53,6 @@
|
|
53
53
|
"husky": "^1.1.3",
|
54
54
|
"i18n-webpack-plugin": "^1.0.0",
|
55
55
|
"istanbul": "^0.4.5",
|
56
|
-
"jade": "^1.11.0",
|
57
|
-
"jade-loader": "~0.8.0",
|
58
56
|
"jest": "24.1.0",
|
59
57
|
"jest-junit": "^6.2.1",
|
60
58
|
"json-loader": "^0.5.7",
|
@@ -64,7 +62,7 @@
|
|
64
62
|
"lint-staged": "^8.0.4",
|
65
63
|
"lodash": "^4.17.4",
|
66
64
|
"prettier": "^1.14.3",
|
67
|
-
"pug": "^2.0.
|
65
|
+
"pug": "^2.0.4",
|
68
66
|
"pug-loader": "^2.4.0",
|
69
67
|
"raw-loader": "^1.0.0",
|
70
68
|
"react": "^16.8.0",
|
@@ -122,12 +120,12 @@
|
|
122
120
|
"pretest": "yarn lint",
|
123
121
|
"prelint": "yarn setup",
|
124
122
|
"lint": "yarn code-lint && yarn jest-lint && yarn type-lint && yarn special-lint",
|
125
|
-
"code-lint": "eslint --
|
123
|
+
"code-lint": "eslint . --ext '.js' --cache",
|
126
124
|
"type-lint": "tsc --pretty",
|
127
125
|
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
|
128
126
|
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
|
129
127
|
"fix": "yarn code-lint --fix && yarn special-lint-fix",
|
130
|
-
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
128
|
+
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
131
129
|
"jest-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
|
132
130
|
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
|
133
131
|
"cover": "yarn cover:all && yarn cover:report",
|