webpack 5.18.0 → 5.20.2
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +10 -47
- package/bin/webpack.js +0 -0
- package/lib/CleanPlugin.js +357 -0
- package/lib/CodeGenerationResults.js +28 -26
- package/lib/Compilation.js +192 -12
- package/lib/Dependency.js +1 -1
- package/lib/FlagDependencyUsagePlugin.js +8 -4
- package/lib/Generator.js +1 -0
- package/lib/ModuleGraph.js +8 -0
- package/lib/ModuleGraphConnection.js +3 -3
- package/lib/ModuleProfile.js +31 -4
- package/lib/NormalModule.js +17 -3
- package/lib/ProgressPlugin.js +12 -10
- package/lib/RuntimeGlobals.js +14 -0
- package/lib/RuntimePlugin.js +8 -0
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/WebpackOptionsApply.js +16 -7
- package/lib/asset/AssetGenerator.js +10 -1
- package/lib/asset/AssetModulesPlugin.js +14 -5
- package/lib/async-modules/AwaitDependenciesInitFragment.js +12 -2
- package/lib/cache/IdleFileCachePlugin.js +9 -3
- package/lib/config/defaults.js +13 -2
- package/lib/config/normalization.js +1 -0
- package/lib/container/ContainerEntryModule.js +4 -1
- package/lib/container/ContainerPlugin.js +4 -2
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -4
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +1 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -5
- package/lib/dependencies/URLDependency.js +9 -4
- package/lib/hmr/LazyCompilationPlugin.js +29 -3
- package/lib/hmr/lazyCompilationBackend.js +2 -3
- package/lib/index.js +4 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -2
- package/lib/optimize/InnerGraph.js +28 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +137 -0
- package/lib/serialization/BinaryMiddleware.js +10 -2
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/util/ArrayQueue.js +103 -0
- package/lib/util/AsyncQueue.js +58 -27
- package/lib/util/ParallelismFactorCalculator.js +59 -0
- package/lib/util/fs.js +3 -0
- package/lib/util/runtime.js +135 -24
- package/lib/validateSchema.js +2 -2
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +24 -22
- package/package.json +2 -3
- package/schemas/WebpackOptions.json +65 -0
- package/schemas/_container.json +4 -0
- package/schemas/plugins/container/ContainerPlugin.json +4 -0
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -0
- package/types.d.ts +111 -19
package/lib/util/AsyncQueue.js
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const { SyncHook, AsyncSeriesHook } = require("tapable");
|
9
|
+
const ArrayQueue = require("./ArrayQueue");
|
9
10
|
|
10
11
|
const QUEUED_STATE = 0;
|
11
12
|
const PROCESSING_STATE = 1;
|
@@ -51,23 +52,35 @@ class AsyncQueue {
|
|
51
52
|
/**
|
52
53
|
* @param {Object} options options object
|
53
54
|
* @param {string=} options.name name of the queue
|
54
|
-
* @param {number} options.parallelism how many items should be processed at once
|
55
|
+
* @param {number=} options.parallelism how many items should be processed at once
|
56
|
+
* @param {AsyncQueue<any, any, any>=} options.parent parent queue, which will have priority over this queue and with shared parallelism
|
55
57
|
* @param {function(T): K=} options.getKey extract key from item
|
56
58
|
* @param {function(T, Callback<R>): void} options.processor async function to process items
|
57
59
|
*/
|
58
|
-
constructor({ name, parallelism, processor, getKey }) {
|
60
|
+
constructor({ name, parallelism, parent, processor, getKey }) {
|
59
61
|
this._name = name;
|
60
|
-
this._parallelism = parallelism;
|
62
|
+
this._parallelism = parallelism || 1;
|
61
63
|
this._processor = processor;
|
62
64
|
this._getKey =
|
63
65
|
getKey || /** @type {(T) => K} */ (item => /** @type {any} */ (item));
|
64
66
|
/** @type {Map<K, AsyncQueueEntry<T, K, R>>} */
|
65
67
|
this._entries = new Map();
|
66
|
-
/** @type {AsyncQueueEntry<T, K, R
|
67
|
-
this._queued =
|
68
|
+
/** @type {ArrayQueue<AsyncQueueEntry<T, K, R>>} */
|
69
|
+
this._queued = new ArrayQueue();
|
70
|
+
/** @type {AsyncQueue<any, any, any>[]} */
|
71
|
+
this._children = undefined;
|
68
72
|
this._activeTasks = 0;
|
69
73
|
this._willEnsureProcessing = false;
|
74
|
+
this._needProcessing = false;
|
70
75
|
this._stopped = false;
|
76
|
+
this._root = parent ? parent._root : this;
|
77
|
+
if (parent) {
|
78
|
+
if (this._root._children === undefined) {
|
79
|
+
this._root._children = [this];
|
80
|
+
} else {
|
81
|
+
this._root._children.push(this);
|
82
|
+
}
|
83
|
+
}
|
71
84
|
|
72
85
|
this.hooks = {
|
73
86
|
/** @type {AsyncSeriesHook<[T]>} */
|
@@ -112,16 +125,18 @@ class AsyncQueue {
|
|
112
125
|
const newEntry = new AsyncQueueEntry(item, callback);
|
113
126
|
if (this._stopped) {
|
114
127
|
this.hooks.added.call(item);
|
115
|
-
this._activeTasks++;
|
128
|
+
this._root._activeTasks++;
|
116
129
|
process.nextTick(() =>
|
117
130
|
this._handleResult(newEntry, new Error("Queue was stopped"))
|
118
131
|
);
|
119
132
|
} else {
|
120
133
|
this._entries.set(key, newEntry);
|
121
|
-
this._queued.
|
122
|
-
|
123
|
-
|
124
|
-
|
134
|
+
this._queued.enqueue(newEntry);
|
135
|
+
const root = this._root;
|
136
|
+
root._needProcessing = true;
|
137
|
+
if (root._willEnsureProcessing === false) {
|
138
|
+
root._willEnsureProcessing = true;
|
139
|
+
setImmediate(root._ensureProcessing);
|
125
140
|
}
|
126
141
|
this.hooks.added.call(item);
|
127
142
|
}
|
@@ -137,10 +152,7 @@ class AsyncQueue {
|
|
137
152
|
const entry = this._entries.get(key);
|
138
153
|
this._entries.delete(key);
|
139
154
|
if (entry.state === QUEUED_STATE) {
|
140
|
-
|
141
|
-
if (idx >= 0) {
|
142
|
-
this._queued.splice(idx, 1);
|
143
|
-
}
|
155
|
+
this._queued.delete(entry);
|
144
156
|
}
|
145
157
|
}
|
146
158
|
|
@@ -150,10 +162,11 @@ class AsyncQueue {
|
|
150
162
|
stop() {
|
151
163
|
this._stopped = true;
|
152
164
|
const queue = this._queued;
|
153
|
-
this._queued =
|
165
|
+
this._queued = new ArrayQueue();
|
166
|
+
const root = this._root;
|
154
167
|
for (const entry of queue) {
|
155
168
|
this._entries.delete(this._getKey(entry.item));
|
156
|
-
|
169
|
+
root._activeTasks++;
|
157
170
|
this._handleResult(entry, new Error("Queue was stopped"));
|
158
171
|
}
|
159
172
|
}
|
@@ -162,11 +175,12 @@ class AsyncQueue {
|
|
162
175
|
* @returns {void}
|
163
176
|
*/
|
164
177
|
increaseParallelism() {
|
165
|
-
this.
|
178
|
+
const root = this._root;
|
179
|
+
root._parallelism++;
|
166
180
|
/* istanbul ignore next */
|
167
|
-
if (
|
168
|
-
|
169
|
-
setImmediate(
|
181
|
+
if (root._willEnsureProcessing === false && root._needProcessing) {
|
182
|
+
root._willEnsureProcessing = true;
|
183
|
+
setImmediate(root._ensureProcessing);
|
170
184
|
}
|
171
185
|
}
|
172
186
|
|
@@ -174,7 +188,8 @@ class AsyncQueue {
|
|
174
188
|
* @returns {void}
|
175
189
|
*/
|
176
190
|
decreaseParallelism() {
|
177
|
-
this.
|
191
|
+
const root = this._root;
|
192
|
+
root._parallelism--;
|
178
193
|
}
|
179
194
|
|
180
195
|
/**
|
@@ -211,13 +226,28 @@ class AsyncQueue {
|
|
211
226
|
* @returns {void}
|
212
227
|
*/
|
213
228
|
_ensureProcessing() {
|
214
|
-
while (this._activeTasks < this._parallelism
|
215
|
-
const entry = this._queued.
|
229
|
+
while (this._activeTasks < this._parallelism) {
|
230
|
+
const entry = this._queued.dequeue();
|
231
|
+
if (entry === undefined) break;
|
216
232
|
this._activeTasks++;
|
217
233
|
entry.state = PROCESSING_STATE;
|
218
234
|
this._startProcessing(entry);
|
219
235
|
}
|
220
236
|
this._willEnsureProcessing = false;
|
237
|
+
if (this._queued.length > 0) return;
|
238
|
+
if (this._children !== undefined) {
|
239
|
+
for (const child of this._children) {
|
240
|
+
while (this._activeTasks < this._parallelism) {
|
241
|
+
const entry = child._queued.dequeue();
|
242
|
+
if (entry === undefined) break;
|
243
|
+
this._activeTasks++;
|
244
|
+
entry.state = PROCESSING_STATE;
|
245
|
+
child._startProcessing(entry);
|
246
|
+
}
|
247
|
+
if (child._queued.length > 0) return;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
if (!this._willEnsureProcessing) this._needProcessing = false;
|
221
251
|
}
|
222
252
|
|
223
253
|
/**
|
@@ -261,11 +291,12 @@ class AsyncQueue {
|
|
261
291
|
entry.callbacks = undefined;
|
262
292
|
entry.result = result;
|
263
293
|
entry.error = error;
|
264
|
-
this._activeTasks--;
|
265
294
|
|
266
|
-
|
267
|
-
|
268
|
-
|
295
|
+
const root = this._root;
|
296
|
+
root._activeTasks--;
|
297
|
+
if (root._willEnsureProcessing === false && root._needProcessing) {
|
298
|
+
root._willEnsureProcessing = true;
|
299
|
+
setImmediate(root._ensureProcessing);
|
269
300
|
}
|
270
301
|
|
271
302
|
if (inHandleResult++ > 3) {
|
@@ -0,0 +1,59 @@
|
|
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 binarySearchBounds = require("../util/binarySearchBounds");
|
9
|
+
|
10
|
+
class ParallelismFactorCalculator {
|
11
|
+
constructor() {
|
12
|
+
this._rangePoints = [];
|
13
|
+
this._rangeCallbacks = [];
|
14
|
+
}
|
15
|
+
|
16
|
+
range(start, end, callback) {
|
17
|
+
if (start === end) return callback(1);
|
18
|
+
this._rangePoints.push(start);
|
19
|
+
this._rangePoints.push(end);
|
20
|
+
this._rangeCallbacks.push(callback);
|
21
|
+
}
|
22
|
+
|
23
|
+
calculate() {
|
24
|
+
const segments = Array.from(new Set(this._rangePoints)).sort((a, b) =>
|
25
|
+
a < b ? -1 : 1
|
26
|
+
);
|
27
|
+
const parallelism = segments.map(() => 0);
|
28
|
+
const rangeStartIndices = [];
|
29
|
+
for (let i = 0; i < this._rangePoints.length; i += 2) {
|
30
|
+
const start = this._rangePoints[i];
|
31
|
+
const end = this._rangePoints[i + 1];
|
32
|
+
let idx = binarySearchBounds.eq(segments, start);
|
33
|
+
rangeStartIndices.push(idx);
|
34
|
+
do {
|
35
|
+
parallelism[idx]++;
|
36
|
+
idx++;
|
37
|
+
} while (segments[idx] < end);
|
38
|
+
}
|
39
|
+
for (let i = 0; i < this._rangeCallbacks.length; i++) {
|
40
|
+
const start = this._rangePoints[i * 2];
|
41
|
+
const end = this._rangePoints[i * 2 + 1];
|
42
|
+
let idx = rangeStartIndices[i];
|
43
|
+
let sum = 0;
|
44
|
+
let totalDuration = 0;
|
45
|
+
let current = start;
|
46
|
+
do {
|
47
|
+
const p = parallelism[idx];
|
48
|
+
idx++;
|
49
|
+
const duration = segments[idx] - current;
|
50
|
+
totalDuration += duration;
|
51
|
+
current = segments[idx];
|
52
|
+
sum += p * duration;
|
53
|
+
} while (current < end);
|
54
|
+
this._rangeCallbacks[i](sum / totalDuration);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
module.exports = ParallelismFactorCalculator;
|
package/lib/util/fs.js
CHANGED
@@ -84,6 +84,9 @@ const path = require("path");
|
|
84
84
|
* @typedef {Object} OutputFileSystem
|
85
85
|
* @property {function(string, Buffer|string, Callback): void} writeFile
|
86
86
|
* @property {function(string, Callback): void} mkdir
|
87
|
+
* @property {function(string, DirentArrayCallback): void=} readdir
|
88
|
+
* @property {function(string, Callback): void=} rmdir
|
89
|
+
* @property {function(string, Callback): void=} unlink
|
87
90
|
* @property {function(string, StatsCallback): void} stat
|
88
91
|
* @property {function(string, BufferOrStringCallback): void} readFile
|
89
92
|
* @property {(function(string, string): string)=} join
|
package/lib/util/runtime.js
CHANGED
@@ -129,7 +129,7 @@ exports.runtimeConditionToString = runtimeCondition => {
|
|
129
129
|
* @param {RuntimeSpec} b second
|
130
130
|
* @returns {boolean} true, when they are equal
|
131
131
|
*/
|
132
|
-
|
132
|
+
const runtimeEqual = (a, b) => {
|
133
133
|
if (a === b) {
|
134
134
|
return true;
|
135
135
|
} else if (
|
@@ -154,6 +154,7 @@ exports.runtimeEqual = (a, b) => {
|
|
154
154
|
}
|
155
155
|
}
|
156
156
|
};
|
157
|
+
exports.runtimeEqual = runtimeEqual;
|
157
158
|
|
158
159
|
/**
|
159
160
|
* @param {RuntimeSpec} a first
|
@@ -269,9 +270,7 @@ const mergeRuntimeOwned = (a, b) => {
|
|
269
270
|
return a;
|
270
271
|
} else if (a === undefined) {
|
271
272
|
if (typeof b === "string") {
|
272
|
-
|
273
|
-
set.add(b);
|
274
|
-
return set;
|
273
|
+
return b;
|
275
274
|
} else {
|
276
275
|
return new SortableSet(b);
|
277
276
|
}
|
@@ -424,8 +423,13 @@ class RuntimeSpecMap {
|
|
424
423
|
* @param {RuntimeSpecMap<T>=} clone copy form this
|
425
424
|
*/
|
426
425
|
constructor(clone) {
|
427
|
-
|
428
|
-
|
426
|
+
this._mode = clone ? clone._mode : 0; // 0 = empty, 1 = single entry, 2 = map
|
427
|
+
/** @type {RuntimeSpec} */
|
428
|
+
this._singleRuntime = clone ? clone._singleRuntime : undefined;
|
429
|
+
/** @type {T} */
|
430
|
+
this._singleValue = clone ? clone._singleValue : undefined;
|
431
|
+
/** @type {Map<string, T> | undefined} */
|
432
|
+
this._map = clone && clone._map ? new Map(clone._map) : undefined;
|
429
433
|
}
|
430
434
|
|
431
435
|
/**
|
@@ -433,8 +437,16 @@ class RuntimeSpecMap {
|
|
433
437
|
* @returns {T} value
|
434
438
|
*/
|
435
439
|
get(runtime) {
|
436
|
-
|
437
|
-
|
440
|
+
switch (this._mode) {
|
441
|
+
case 0:
|
442
|
+
return undefined;
|
443
|
+
case 1:
|
444
|
+
return runtimeEqual(this._singleRuntime, runtime)
|
445
|
+
? this._singleValue
|
446
|
+
: undefined;
|
447
|
+
default:
|
448
|
+
return this._map.get(getRuntimeKey(runtime));
|
449
|
+
}
|
438
450
|
}
|
439
451
|
|
440
452
|
/**
|
@@ -442,40 +454,139 @@ class RuntimeSpecMap {
|
|
442
454
|
* @returns {boolean} true, when the runtime is stored
|
443
455
|
*/
|
444
456
|
has(runtime) {
|
445
|
-
|
446
|
-
|
457
|
+
switch (this._mode) {
|
458
|
+
case 0:
|
459
|
+
return false;
|
460
|
+
case 1:
|
461
|
+
return runtimeEqual(this._singleRuntime, runtime);
|
462
|
+
default:
|
463
|
+
return this._map.has(getRuntimeKey(runtime));
|
464
|
+
}
|
447
465
|
}
|
448
466
|
|
449
467
|
set(runtime, value) {
|
450
|
-
this.
|
468
|
+
switch (this._mode) {
|
469
|
+
case 0:
|
470
|
+
this._mode = 1;
|
471
|
+
this._singleRuntime = runtime;
|
472
|
+
this._singleValue = value;
|
473
|
+
break;
|
474
|
+
case 1:
|
475
|
+
if (runtimeEqual(this._singleRuntime, runtime)) {
|
476
|
+
this._singleValue = value;
|
477
|
+
break;
|
478
|
+
}
|
479
|
+
this._mode = 2;
|
480
|
+
this._map = new Map();
|
481
|
+
this._map.set(getRuntimeKey(this._singleRuntime), this._singleValue);
|
482
|
+
this._singleRuntime = undefined;
|
483
|
+
this._singleValue = undefined;
|
484
|
+
/* falls through */
|
485
|
+
default:
|
486
|
+
this._map.set(getRuntimeKey(runtime), value);
|
487
|
+
}
|
451
488
|
}
|
452
489
|
|
453
490
|
provide(runtime, computer) {
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
491
|
+
switch (this._mode) {
|
492
|
+
case 0:
|
493
|
+
this._mode = 1;
|
494
|
+
this._singleRuntime = runtime;
|
495
|
+
return (this._singleValue = computer());
|
496
|
+
case 1: {
|
497
|
+
if (runtimeEqual(this._singleRuntime, runtime)) {
|
498
|
+
return this._singleValue;
|
499
|
+
}
|
500
|
+
this._mode = 2;
|
501
|
+
this._map = new Map();
|
502
|
+
this._map.set(getRuntimeKey(this._singleRuntime), this._singleValue);
|
503
|
+
this._singleRuntime = undefined;
|
504
|
+
this._singleValue = undefined;
|
505
|
+
const newValue = computer();
|
506
|
+
this._map.set(getRuntimeKey(runtime), newValue);
|
507
|
+
return newValue;
|
508
|
+
}
|
509
|
+
default: {
|
510
|
+
const key = getRuntimeKey(runtime);
|
511
|
+
const value = this._map.get(key);
|
512
|
+
if (value !== undefined) return value;
|
513
|
+
const newValue = computer();
|
514
|
+
this._map.set(key, newValue);
|
515
|
+
return newValue;
|
516
|
+
}
|
517
|
+
}
|
460
518
|
}
|
461
519
|
|
462
520
|
delete(runtime) {
|
463
|
-
this.
|
521
|
+
switch (this._mode) {
|
522
|
+
case 0:
|
523
|
+
return;
|
524
|
+
case 1:
|
525
|
+
if (runtimeEqual(this._singleRuntime, runtime)) {
|
526
|
+
this._mode = 0;
|
527
|
+
this._singleRuntime = undefined;
|
528
|
+
this._singleValue = undefined;
|
529
|
+
}
|
530
|
+
return;
|
531
|
+
default:
|
532
|
+
this._map.delete(getRuntimeKey(runtime));
|
533
|
+
}
|
464
534
|
}
|
465
535
|
|
466
536
|
update(runtime, fn) {
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
537
|
+
switch (this._mode) {
|
538
|
+
case 0:
|
539
|
+
throw new Error("runtime passed to update must exist");
|
540
|
+
case 1: {
|
541
|
+
if (runtimeEqual(this._singleRuntime, runtime)) {
|
542
|
+
this._singleValue = fn(this._singleValue);
|
543
|
+
break;
|
544
|
+
}
|
545
|
+
const newValue = fn(undefined);
|
546
|
+
if (newValue !== undefined) {
|
547
|
+
this._mode = 2;
|
548
|
+
this._map = new Map();
|
549
|
+
this._map.set(getRuntimeKey(this._singleRuntime), this._singleValue);
|
550
|
+
this._singleRuntime = undefined;
|
551
|
+
this._singleValue = undefined;
|
552
|
+
this._map.set(getRuntimeKey(runtime), newValue);
|
553
|
+
}
|
554
|
+
break;
|
555
|
+
}
|
556
|
+
default: {
|
557
|
+
const key = getRuntimeKey(runtime);
|
558
|
+
const oldValue = this._map.get(key);
|
559
|
+
const newValue = fn(oldValue);
|
560
|
+
if (newValue !== oldValue) this._map.set(key, newValue);
|
561
|
+
}
|
562
|
+
}
|
471
563
|
}
|
472
564
|
|
473
565
|
keys() {
|
474
|
-
|
566
|
+
switch (this._mode) {
|
567
|
+
case 0:
|
568
|
+
return [];
|
569
|
+
case 1:
|
570
|
+
return [this._singleRuntime];
|
571
|
+
default:
|
572
|
+
return Array.from(this._map.keys(), keyToRuntime);
|
573
|
+
}
|
475
574
|
}
|
476
575
|
|
477
576
|
values() {
|
478
|
-
|
577
|
+
switch (this._mode) {
|
578
|
+
case 0:
|
579
|
+
return [][Symbol.iterator]();
|
580
|
+
case 1:
|
581
|
+
return [this._singleValue][Symbol.iterator]();
|
582
|
+
default:
|
583
|
+
return this._map.values();
|
584
|
+
}
|
585
|
+
}
|
586
|
+
|
587
|
+
get size() {
|
588
|
+
if (this._mode <= 1) return this._mode;
|
589
|
+
return this._map.size;
|
479
590
|
}
|
480
591
|
}
|
481
592
|
|
package/lib/validateSchema.js
CHANGED
@@ -63,9 +63,9 @@ const DID_YOU_MEAN = {
|
|
63
63
|
|
64
64
|
const REMOVED = {
|
65
65
|
concord:
|
66
|
-
"BREAKING CHANGE: resolve.concord has been removed and is no longer
|
66
|
+
"BREAKING CHANGE: resolve.concord has been removed and is no longer available.",
|
67
67
|
devtoolLineToLine:
|
68
|
-
"BREAKING CHANGE: output.devtoolLineToLine has been removed and is no longer
|
68
|
+
"BREAKING CHANGE: output.devtoolLineToLine has been removed and is no longer available."
|
69
69
|
};
|
70
70
|
/* cSpell:enable */
|
71
71
|
|
@@ -155,30 +155,32 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
155
155
|
chunkGraph.getRenderedModuleHash(module, runtime)
|
156
156
|
)}` + (importsObj ? `, ${importsObj})` : `)`);
|
157
157
|
|
158
|
+
if (promises.length > 0)
|
159
|
+
runtimeRequirements.add(RuntimeGlobals.asyncModule);
|
160
|
+
|
158
161
|
const source = new RawSource(
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
: `${importsCompatCode}${module.moduleArgument}.exports = ${instantiateCall}`
|
180
|
-
}`
|
162
|
+
promises.length > 0
|
163
|
+
? Template.asString([
|
164
|
+
`var __webpack_instantiate__ = ${runtimeTemplate.basicFunction(
|
165
|
+
`[${promises.join(", ")}]`,
|
166
|
+
`${importsCompatCode}return ${instantiateCall};`
|
167
|
+
)}`,
|
168
|
+
`${RuntimeGlobals.asyncModule}(${
|
169
|
+
module.moduleArgument
|
170
|
+
}, ${runtimeTemplate.basicFunction(
|
171
|
+
"__webpack_handle_async_dependencies__",
|
172
|
+
[
|
173
|
+
importsCode,
|
174
|
+
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${promises.join(
|
175
|
+
", "
|
176
|
+
)}]);`,
|
177
|
+
"return __webpack_async_dependencies__.then ? __webpack_async_dependencies__.then(__webpack_instantiate__) : __webpack_instantiate__(__webpack_async_dependencies__);"
|
178
|
+
]
|
179
|
+
)}, 1);`
|
180
|
+
])
|
181
|
+
: `${importsCode}${importsCompatCode}module.exports = ${instantiateCall};`
|
181
182
|
);
|
183
|
+
|
182
184
|
return InitFragment.addToSource(source, initFragments, generateContext);
|
183
185
|
}
|
184
186
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.20.2",
|
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",
|
@@ -23,7 +23,6 @@
|
|
23
23
|
"loader-runner": "^4.2.0",
|
24
24
|
"mime-types": "^2.1.27",
|
25
25
|
"neo-async": "^2.6.2",
|
26
|
-
"pkg-dir": "^5.0.0",
|
27
26
|
"schema-utils": "^3.0.0",
|
28
27
|
"tapable": "^2.1.1",
|
29
28
|
"terser-webpack-plugin": "^5.1.1",
|
@@ -70,7 +69,7 @@
|
|
70
69
|
"json-loader": "^0.5.7",
|
71
70
|
"json5": "^2.1.3",
|
72
71
|
"less": "^4.0.0",
|
73
|
-
"less-loader": "^
|
72
|
+
"less-loader": "^8.0.0",
|
74
73
|
"lint-staged": "^10.2.11",
|
75
74
|
"loader-utils": "^2.0.0",
|
76
75
|
"lodash": "^4.17.19",
|
@@ -224,6 +224,45 @@
|
|
224
224
|
}
|
225
225
|
]
|
226
226
|
},
|
227
|
+
"Clean": {
|
228
|
+
"description": "Clean the output directory before emit.",
|
229
|
+
"anyOf": [
|
230
|
+
{
|
231
|
+
"type": "boolean"
|
232
|
+
},
|
233
|
+
{
|
234
|
+
"$ref": "#/definitions/CleanOptions"
|
235
|
+
}
|
236
|
+
]
|
237
|
+
},
|
238
|
+
"CleanOptions": {
|
239
|
+
"description": "Advanced options for cleaning assets.",
|
240
|
+
"type": "object",
|
241
|
+
"additionalProperties": false,
|
242
|
+
"properties": {
|
243
|
+
"dry": {
|
244
|
+
"description": "Log the assets that should be removed instead of deleting them.",
|
245
|
+
"type": "boolean"
|
246
|
+
},
|
247
|
+
"keep": {
|
248
|
+
"description": "Keep these assets.",
|
249
|
+
"anyOf": [
|
250
|
+
{
|
251
|
+
"instanceof": "RegExp",
|
252
|
+
"tsType": "RegExp"
|
253
|
+
},
|
254
|
+
{
|
255
|
+
"type": "string",
|
256
|
+
"absolutePath": false
|
257
|
+
},
|
258
|
+
{
|
259
|
+
"instanceof": "Function",
|
260
|
+
"tsType": "((filename: string) => boolean)"
|
261
|
+
}
|
262
|
+
]
|
263
|
+
}
|
264
|
+
}
|
265
|
+
},
|
227
266
|
"CompareBeforeEmit": {
|
228
267
|
"description": "Check if to be emitted file already exists and have the same content before writing to output filesystem.",
|
229
268
|
"type": "boolean"
|
@@ -603,6 +642,26 @@
|
|
603
642
|
"entries": {
|
604
643
|
"description": "Enable/disable lazy compilation for entries.",
|
605
644
|
"type": "boolean"
|
645
|
+
},
|
646
|
+
"imports": {
|
647
|
+
"description": "Enable/disable lazy compilation for import() modules.",
|
648
|
+
"type": "boolean"
|
649
|
+
},
|
650
|
+
"test": {
|
651
|
+
"description": "Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name.",
|
652
|
+
"anyOf": [
|
653
|
+
{
|
654
|
+
"instanceof": "RegExp",
|
655
|
+
"tsType": "RegExp"
|
656
|
+
},
|
657
|
+
{
|
658
|
+
"type": "string"
|
659
|
+
},
|
660
|
+
{
|
661
|
+
"instanceof": "Function",
|
662
|
+
"tsType": "((module: import('../lib/Module')) => boolean)"
|
663
|
+
}
|
664
|
+
]
|
606
665
|
}
|
607
666
|
}
|
608
667
|
}
|
@@ -2350,6 +2409,9 @@
|
|
2350
2409
|
"chunkLoadingGlobal": {
|
2351
2410
|
"$ref": "#/definitions/ChunkLoadingGlobal"
|
2352
2411
|
},
|
2412
|
+
"clean": {
|
2413
|
+
"$ref": "#/definitions/Clean"
|
2414
|
+
},
|
2353
2415
|
"compareBeforeEmit": {
|
2354
2416
|
"$ref": "#/definitions/CompareBeforeEmit"
|
2355
2417
|
},
|
@@ -2517,6 +2579,9 @@
|
|
2517
2579
|
"chunkLoadingGlobal": {
|
2518
2580
|
"$ref": "#/definitions/ChunkLoadingGlobal"
|
2519
2581
|
},
|
2582
|
+
"clean": {
|
2583
|
+
"$ref": "#/definitions/Clean"
|
2584
|
+
},
|
2520
2585
|
"compareBeforeEmit": {
|
2521
2586
|
"$ref": "#/definitions/CompareBeforeEmit"
|
2522
2587
|
},
|
package/schemas/_container.json
CHANGED