webpack 5.105.4 → 5.106.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/README.md +3 -6
- package/lib/BannerPlugin.js +13 -13
- package/lib/Chunk.js +25 -0
- package/lib/ChunkGraph.js +8 -4
- package/lib/CleanPlugin.js +23 -20
- package/lib/CompatibilityPlugin.js +1 -1
- package/lib/Compilation.js +34 -11
- package/lib/Compiler.js +59 -1
- package/lib/CssModule.js +17 -2
- package/lib/Dependency.js +1 -1
- package/lib/DllPlugin.js +17 -17
- package/lib/DllReferencePlugin.js +20 -18
- package/lib/DotenvPlugin.js +29 -27
- package/lib/ExternalModule.js +39 -6
- package/lib/FileSystemInfo.js +3 -1
- package/lib/IgnorePlugin.js +12 -11
- package/lib/LoaderOptionsPlugin.js +17 -15
- package/lib/ManifestPlugin.js +27 -25
- package/lib/Module.js +69 -4
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleParseError.js +1 -1
- package/lib/ModuleTypeConstants.js +1 -1
- package/lib/NormalModule.js +7 -3
- package/lib/NormalModuleFactory.js +20 -1
- package/lib/ProgressPlugin.js +39 -29
- package/lib/RuntimeGlobals.js +6 -0
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +13 -11
- package/lib/TemplatedPathPlugin.js +4 -3
- package/lib/WatchIgnorePlugin.js +15 -13
- package/lib/WebpackOptionsApply.js +4 -4
- package/lib/asset/AssetModulesPlugin.js +50 -29
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +27 -13
- package/lib/config/normalization.js +3 -2
- package/lib/container/ContainerPlugin.js +46 -42
- package/lib/container/ContainerReferencePlugin.js +42 -26
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +17 -13
- package/lib/css/CssGenerator.js +306 -192
- package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
- package/lib/css/CssLoadingRuntimeModule.js +1 -4
- package/lib/css/CssModulesPlugin.js +197 -98
- package/lib/css/CssParser.js +231 -134
- package/lib/css/walkCssTokens.js +115 -12
- package/lib/debug/ProfilingPlugin.js +16 -13
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
- package/lib/dependencies/CommonJsExportsDependency.js +1 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
- package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
- package/lib/dependencies/CommonJsRequireDependency.js +42 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +210 -87
- package/lib/dependencies/CssIcssImportDependency.js +13 -70
- package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
- package/lib/dependencies/HarmonyExportExpressionDependency.js +28 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +21 -8
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
- package/lib/dependencies/ImportContextDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +16 -2
- package/lib/dependencies/ImportMetaPlugin.js +39 -29
- package/lib/dependencies/ImportParserPlugin.js +4 -5
- package/lib/dependencies/ImportPhase.js +65 -22
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
- package/lib/ids/HashedModuleIdsPlugin.js +21 -23
- package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
- package/lib/javascript/JavascriptModulesPlugin.js +38 -12
- package/lib/javascript/JavascriptParser.js +5 -3
- package/lib/json/JsonModulesPlugin.js +28 -21
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +35 -13
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
- package/lib/optimize/ConcatenatedModule.js +4 -3
- package/lib/optimize/InnerGraphPlugin.js +11 -5
- package/lib/optimize/LimitChunkCountPlugin.js +22 -18
- package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
- package/lib/optimize/MinChunkSizePlugin.js +20 -16
- package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +20 -11
- package/lib/schemes/VirtualUrlPlugin.js +77 -30
- package/lib/serialization/FileMiddleware.js +7 -7
- package/lib/sharing/ConsumeSharedPlugin.js +32 -25
- package/lib/sharing/ProvideSharedPlugin.js +29 -25
- package/lib/util/{propertyName.js → property.js} +26 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
- package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
- package/lib/web/JsonpTemplatePlugin.js +1 -0
- package/lib/webpack.js +34 -4
- package/package.json +18 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +82 -22
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
- package/types.d.ts +511 -114
- package/lib/util/create-schema-validation.js +0 -41
- package/lib/util/propertyAccess.js +0 -30
package/lib/Module.js
CHANGED
|
@@ -41,12 +41,11 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
41
41
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
42
42
|
/** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */
|
|
43
43
|
/** @typedef {import("./ModuleGraph").OptimizationBailouts} OptimizationBailouts */
|
|
44
|
+
/** @typedef {import("./ModuleProfile")} ModuleProfile */
|
|
44
45
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
|
45
46
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
46
47
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
47
48
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
48
|
-
/** @typedef {import("../declarations/WebpackOptions").CssParserExportType} CssParserExportType */
|
|
49
|
-
|
|
50
49
|
/**
|
|
51
50
|
* @template T
|
|
52
51
|
* @typedef {import("./InitFragment")<T>} InitFragment
|
|
@@ -59,6 +58,10 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
59
58
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
60
59
|
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
61
60
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
61
|
+
/**
|
|
62
|
+
* @template T
|
|
63
|
+
* @typedef {import("./util/SortableSet")<T>} SortableSet
|
|
64
|
+
*/
|
|
62
65
|
/** @typedef {"namespace" | "default-only" | "default-with-named" | "dynamic"} ExportsType */
|
|
63
66
|
|
|
64
67
|
/**
|
|
@@ -156,7 +159,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
156
159
|
/**
|
|
157
160
|
* @typedef {object} KnownBuildMeta
|
|
158
161
|
* @property {("default" | "namespace" | "flagged" | "dynamic")=} exportsType
|
|
159
|
-
* @property {CssParserExportType=} exportType
|
|
160
162
|
* @property {(false | "redirect" | "redirect-warn")=} defaultObject
|
|
161
163
|
* @property {boolean=} strictHarmonyModule
|
|
162
164
|
* @property {boolean=} treatAsCommonJs
|
|
@@ -303,6 +305,7 @@ class Module extends DependenciesBlock {
|
|
|
303
305
|
// TODO remove in webpack 6
|
|
304
306
|
// BACKWARD-COMPAT START
|
|
305
307
|
/**
|
|
308
|
+
* @deprecated
|
|
306
309
|
* @returns {ModuleId | null} module id
|
|
307
310
|
*/
|
|
308
311
|
get id() {
|
|
@@ -314,6 +317,7 @@ class Module extends DependenciesBlock {
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
/**
|
|
320
|
+
* @deprecated
|
|
317
321
|
* @param {ModuleId} value value
|
|
318
322
|
*/
|
|
319
323
|
set id(value) {
|
|
@@ -329,6 +333,7 @@ class Module extends DependenciesBlock {
|
|
|
329
333
|
}
|
|
330
334
|
|
|
331
335
|
/**
|
|
336
|
+
* @deprecated
|
|
332
337
|
* @returns {string} the hash of the module
|
|
333
338
|
*/
|
|
334
339
|
get hash() {
|
|
@@ -340,6 +345,7 @@ class Module extends DependenciesBlock {
|
|
|
340
345
|
}
|
|
341
346
|
|
|
342
347
|
/**
|
|
348
|
+
* @deprecated
|
|
343
349
|
* @returns {string} the shortened hash of the module
|
|
344
350
|
*/
|
|
345
351
|
get renderedHash() {
|
|
@@ -350,6 +356,10 @@ class Module extends DependenciesBlock {
|
|
|
350
356
|
).getRenderedModuleHash(this, undefined);
|
|
351
357
|
}
|
|
352
358
|
|
|
359
|
+
/**
|
|
360
|
+
* @deprecated
|
|
361
|
+
* @returns {ModuleProfile | undefined} module profile
|
|
362
|
+
*/
|
|
353
363
|
get profile() {
|
|
354
364
|
return ModuleGraph.getModuleGraphForModule(
|
|
355
365
|
this,
|
|
@@ -358,6 +368,10 @@ class Module extends DependenciesBlock {
|
|
|
358
368
|
).getProfile(this);
|
|
359
369
|
}
|
|
360
370
|
|
|
371
|
+
/**
|
|
372
|
+
* @deprecated
|
|
373
|
+
* @param {ModuleProfile | undefined} value module profile
|
|
374
|
+
*/
|
|
361
375
|
set profile(value) {
|
|
362
376
|
ModuleGraph.getModuleGraphForModule(
|
|
363
377
|
this,
|
|
@@ -367,6 +381,7 @@ class Module extends DependenciesBlock {
|
|
|
367
381
|
}
|
|
368
382
|
|
|
369
383
|
/**
|
|
384
|
+
* @deprecated
|
|
370
385
|
* @returns {number | null} the pre order index
|
|
371
386
|
*/
|
|
372
387
|
get index() {
|
|
@@ -378,6 +393,7 @@ class Module extends DependenciesBlock {
|
|
|
378
393
|
}
|
|
379
394
|
|
|
380
395
|
/**
|
|
396
|
+
* @deprecated
|
|
381
397
|
* @param {number} value the pre order index
|
|
382
398
|
*/
|
|
383
399
|
set index(value) {
|
|
@@ -389,6 +405,7 @@ class Module extends DependenciesBlock {
|
|
|
389
405
|
}
|
|
390
406
|
|
|
391
407
|
/**
|
|
408
|
+
* @deprecated
|
|
392
409
|
* @returns {number | null} the post order index
|
|
393
410
|
*/
|
|
394
411
|
get index2() {
|
|
@@ -400,6 +417,7 @@ class Module extends DependenciesBlock {
|
|
|
400
417
|
}
|
|
401
418
|
|
|
402
419
|
/**
|
|
420
|
+
* @deprecated
|
|
403
421
|
* @param {number} value the post order index
|
|
404
422
|
*/
|
|
405
423
|
set index2(value) {
|
|
@@ -411,6 +429,7 @@ class Module extends DependenciesBlock {
|
|
|
411
429
|
}
|
|
412
430
|
|
|
413
431
|
/**
|
|
432
|
+
* @deprecated
|
|
414
433
|
* @returns {number | null} the depth
|
|
415
434
|
*/
|
|
416
435
|
get depth() {
|
|
@@ -422,6 +441,7 @@ class Module extends DependenciesBlock {
|
|
|
422
441
|
}
|
|
423
442
|
|
|
424
443
|
/**
|
|
444
|
+
* @deprecated
|
|
425
445
|
* @param {number} value the depth
|
|
426
446
|
*/
|
|
427
447
|
set depth(value) {
|
|
@@ -433,6 +453,7 @@ class Module extends DependenciesBlock {
|
|
|
433
453
|
}
|
|
434
454
|
|
|
435
455
|
/**
|
|
456
|
+
* @deprecated
|
|
436
457
|
* @returns {Module | null | undefined} issuer
|
|
437
458
|
*/
|
|
438
459
|
get issuer() {
|
|
@@ -444,6 +465,7 @@ class Module extends DependenciesBlock {
|
|
|
444
465
|
}
|
|
445
466
|
|
|
446
467
|
/**
|
|
468
|
+
* @deprecated
|
|
447
469
|
* @param {Module | null} value issuer
|
|
448
470
|
*/
|
|
449
471
|
set issuer(value) {
|
|
@@ -454,6 +476,10 @@ class Module extends DependenciesBlock {
|
|
|
454
476
|
).setIssuer(this, value);
|
|
455
477
|
}
|
|
456
478
|
|
|
479
|
+
/**
|
|
480
|
+
* @deprecated
|
|
481
|
+
* @returns {boolean | SortableSet<string> | null} used exports
|
|
482
|
+
*/
|
|
457
483
|
get usedExports() {
|
|
458
484
|
return ModuleGraph.getModuleGraphForModule(
|
|
459
485
|
this,
|
|
@@ -474,6 +500,10 @@ class Module extends DependenciesBlock {
|
|
|
474
500
|
).getOptimizationBailout(this);
|
|
475
501
|
}
|
|
476
502
|
|
|
503
|
+
/**
|
|
504
|
+
* @deprecated
|
|
505
|
+
* @returns {boolean} true when optional, otherwise false
|
|
506
|
+
*/
|
|
477
507
|
get optional() {
|
|
478
508
|
return this.isOptional(
|
|
479
509
|
ModuleGraph.getModuleGraphForModule(
|
|
@@ -485,6 +515,7 @@ class Module extends DependenciesBlock {
|
|
|
485
515
|
}
|
|
486
516
|
|
|
487
517
|
/**
|
|
518
|
+
* @deprecated
|
|
488
519
|
* @param {Chunk} chunk the chunk
|
|
489
520
|
* @returns {boolean} true, when the module was added
|
|
490
521
|
*/
|
|
@@ -500,6 +531,7 @@ class Module extends DependenciesBlock {
|
|
|
500
531
|
}
|
|
501
532
|
|
|
502
533
|
/**
|
|
534
|
+
* @deprecated
|
|
503
535
|
* @param {Chunk} chunk the chunk
|
|
504
536
|
* @returns {void}
|
|
505
537
|
*/
|
|
@@ -512,6 +544,7 @@ class Module extends DependenciesBlock {
|
|
|
512
544
|
}
|
|
513
545
|
|
|
514
546
|
/**
|
|
547
|
+
* @deprecated
|
|
515
548
|
* @param {Chunk} chunk the chunk
|
|
516
549
|
* @returns {boolean} true, when the module is in the chunk
|
|
517
550
|
*/
|
|
@@ -523,6 +556,10 @@ class Module extends DependenciesBlock {
|
|
|
523
556
|
).isModuleInChunk(this, chunk);
|
|
524
557
|
}
|
|
525
558
|
|
|
559
|
+
/**
|
|
560
|
+
* @deprecated
|
|
561
|
+
* @returns {boolean} true when is entry module, otherwise false
|
|
562
|
+
*/
|
|
526
563
|
isEntryModule() {
|
|
527
564
|
return ChunkGraph.getChunkGraphForModule(
|
|
528
565
|
this,
|
|
@@ -531,6 +568,10 @@ class Module extends DependenciesBlock {
|
|
|
531
568
|
).isEntryModule(this);
|
|
532
569
|
}
|
|
533
570
|
|
|
571
|
+
/**
|
|
572
|
+
* @deprecated
|
|
573
|
+
* @returns {Chunk[]} chunks
|
|
574
|
+
*/
|
|
534
575
|
getChunks() {
|
|
535
576
|
return ChunkGraph.getChunkGraphForModule(
|
|
536
577
|
this,
|
|
@@ -539,6 +580,10 @@ class Module extends DependenciesBlock {
|
|
|
539
580
|
).getModuleChunks(this);
|
|
540
581
|
}
|
|
541
582
|
|
|
583
|
+
/**
|
|
584
|
+
* @deprecated
|
|
585
|
+
* @returns {number} number of chunks
|
|
586
|
+
*/
|
|
542
587
|
getNumberOfChunks() {
|
|
543
588
|
return ChunkGraph.getChunkGraphForModule(
|
|
544
589
|
this,
|
|
@@ -547,6 +592,10 @@ class Module extends DependenciesBlock {
|
|
|
547
592
|
).getNumberOfModuleChunks(this);
|
|
548
593
|
}
|
|
549
594
|
|
|
595
|
+
/**
|
|
596
|
+
* @deprecated
|
|
597
|
+
* @returns {Iterable<Chunk>} chunks
|
|
598
|
+
*/
|
|
550
599
|
get chunksIterable() {
|
|
551
600
|
return ChunkGraph.getChunkGraphForModule(
|
|
552
601
|
this,
|
|
@@ -556,6 +605,7 @@ class Module extends DependenciesBlock {
|
|
|
556
605
|
}
|
|
557
606
|
|
|
558
607
|
/**
|
|
608
|
+
* @deprecated
|
|
559
609
|
* @param {string} exportName a name of an export
|
|
560
610
|
* @returns {boolean | null} true, if the export is provided why the module.
|
|
561
611
|
* null, if it's unknown.
|
|
@@ -1095,7 +1145,7 @@ class Module extends DependenciesBlock {
|
|
|
1095
1145
|
/**
|
|
1096
1146
|
* @param {Chunk} chunk the chunk which condition should be checked
|
|
1097
1147
|
* @param {Compilation} compilation the compilation
|
|
1098
|
-
* @returns {boolean} true
|
|
1148
|
+
* @returns {boolean} true if the module can be placed in the chunk
|
|
1099
1149
|
*/
|
|
1100
1150
|
chunkCondition(chunk, compilation) {
|
|
1101
1151
|
return true;
|
|
@@ -1221,6 +1271,21 @@ class Module extends DependenciesBlock {
|
|
|
1221
1271
|
this.codeGenerationDependencies = read();
|
|
1222
1272
|
super.deserialize(context);
|
|
1223
1273
|
}
|
|
1274
|
+
|
|
1275
|
+
// TODO remove in webpack 6
|
|
1276
|
+
/**
|
|
1277
|
+
* @deprecated In webpack 6, call getSourceBasicTypes() directly on the module instance instead of using this static method.
|
|
1278
|
+
* @param {Module} module the module
|
|
1279
|
+
* @returns {ReturnType<Module["getSourceBasicTypes"]>} the source types of the module
|
|
1280
|
+
*/
|
|
1281
|
+
static getSourceBasicTypes(module) {
|
|
1282
|
+
if (!(module instanceof Module)) {
|
|
1283
|
+
// https://github.com/webpack/webpack/issues/20597
|
|
1284
|
+
// fallback to javascript
|
|
1285
|
+
return JAVASCRIPT_TYPES;
|
|
1286
|
+
}
|
|
1287
|
+
return module.getSourceBasicTypes();
|
|
1288
|
+
}
|
|
1224
1289
|
}
|
|
1225
1290
|
|
|
1226
1291
|
makeSerializable(Module, "webpack/lib/Module");
|
package/lib/ModuleGraph.js
CHANGED
|
@@ -961,6 +961,7 @@ class ModuleGraph {
|
|
|
961
961
|
|
|
962
962
|
// TODO remove in webpack 6
|
|
963
963
|
/**
|
|
964
|
+
* @deprecated
|
|
964
965
|
* @param {Module} module the module
|
|
965
966
|
* @param {string} deprecateMessage message for the deprecation message
|
|
966
967
|
* @param {string} deprecationCode code for the deprecation
|
|
@@ -994,6 +995,7 @@ class ModuleGraph {
|
|
|
994
995
|
|
|
995
996
|
// TODO remove in webpack 6
|
|
996
997
|
/**
|
|
998
|
+
* @deprecated
|
|
997
999
|
* @param {Module} module the module
|
|
998
1000
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
999
1001
|
* @returns {void}
|
|
@@ -1004,6 +1006,7 @@ class ModuleGraph {
|
|
|
1004
1006
|
|
|
1005
1007
|
// TODO remove in webpack 6
|
|
1006
1008
|
/**
|
|
1009
|
+
* @deprecated
|
|
1007
1010
|
* @param {Module} module the module
|
|
1008
1011
|
* @returns {void}
|
|
1009
1012
|
*/
|
package/lib/ModuleParseError.js
CHANGED
|
@@ -28,7 +28,7 @@ class ModuleParseError extends WebpackError {
|
|
|
28
28
|
let loc;
|
|
29
29
|
|
|
30
30
|
if (
|
|
31
|
-
((Buffer.isBuffer(source) && source.
|
|
31
|
+
((Buffer.isBuffer(source) && source.subarray(0, 4).equals(WASM_HEADER)) ||
|
|
32
32
|
(typeof source === "string" && /^\0asm/.test(source))) &&
|
|
33
33
|
!type.startsWith("webassembly")
|
|
34
34
|
) {
|
|
@@ -175,7 +175,7 @@ module.exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
|
|
|
175
175
|
module.exports.JSON_MODULE_TYPE = JSON_MODULE_TYPE;
|
|
176
176
|
/** @type {WebAssemblyModuleTypes[]} */
|
|
177
177
|
module.exports.WEBASSEMBLY_MODULES = [
|
|
178
|
-
|
|
178
|
+
WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
|
179
179
|
WEBASSEMBLY_MODULE_TYPE_SYNC
|
|
180
180
|
];
|
|
181
181
|
module.exports.WEBASSEMBLY_MODULE_TYPE_ASYNC = WEBASSEMBLY_MODULE_TYPE_ASYNC;
|
package/lib/NormalModule.js
CHANGED
|
@@ -229,13 +229,18 @@ makeSerializable(
|
|
|
229
229
|
|
|
230
230
|
/** @typedef {LoaderContext<EXPECTED_ANY>} AnyLoaderContext */
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* @deprecated Use the `readResource` hook instead.
|
|
234
|
+
* @typedef {HookMap<FakeHook<AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>>>} DeprecatedReadResourceForScheme
|
|
235
|
+
*/
|
|
236
|
+
|
|
232
237
|
/**
|
|
233
238
|
* @typedef {object} NormalModuleCompilationHooks
|
|
234
239
|
* @property {SyncHook<[AnyLoaderContext, NormalModule]>} loader
|
|
235
240
|
* @property {SyncHook<[LoaderItem[], NormalModule, AnyLoaderContext]>} beforeLoaders
|
|
236
241
|
* @property {SyncHook<[NormalModule]>} beforeParse
|
|
237
242
|
* @property {SyncHook<[NormalModule]>} beforeSnapshot
|
|
238
|
-
* @property {
|
|
243
|
+
* @property {DeprecatedReadResourceForScheme} readResourceForScheme
|
|
239
244
|
* @property {HookMap<AsyncSeriesBailHook<[AnyLoaderContext], string | Buffer | null>>} readResource
|
|
240
245
|
* @property {SyncWaterfallHook<[Result, NormalModule]>} processResult
|
|
241
246
|
* @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild
|
|
@@ -735,7 +740,7 @@ class NormalModule extends Module {
|
|
|
735
740
|
options = {};
|
|
736
741
|
}
|
|
737
742
|
|
|
738
|
-
if (schema) {
|
|
743
|
+
if (schema && compilation.options.validate) {
|
|
739
744
|
let name = "Loader";
|
|
740
745
|
let baseDataPath = "options";
|
|
741
746
|
/** @type {RegExpExecArray | null} */
|
|
@@ -872,7 +877,6 @@ class NormalModule extends Module {
|
|
|
872
877
|
return /** @type {AnyLoaderContext} */ (loaderContext);
|
|
873
878
|
}
|
|
874
879
|
|
|
875
|
-
// TODO remove `loaderContext` in webpack@6
|
|
876
880
|
/**
|
|
877
881
|
* @param {AnyLoaderContext} loaderContext loader context
|
|
878
882
|
* @param {number} index index
|
|
@@ -20,6 +20,7 @@ const ModuleFactory = require("./ModuleFactory");
|
|
|
20
20
|
const ModuleGraph = require("./ModuleGraph");
|
|
21
21
|
const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants");
|
|
22
22
|
const NormalModule = require("./NormalModule");
|
|
23
|
+
const { ImportPhaseUtils } = require("./dependencies/ImportPhase");
|
|
23
24
|
const BasicEffectRulePlugin = require("./rules/BasicEffectRulePlugin");
|
|
24
25
|
const BasicMatcherRulePlugin = require("./rules/BasicMatcherRulePlugin");
|
|
25
26
|
const ObjectMatcherRulePlugin = require("./rules/ObjectMatcherRulePlugin");
|
|
@@ -52,6 +53,8 @@ const {
|
|
|
52
53
|
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
|
53
54
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
54
55
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
|
56
|
+
/** @typedef {import("./dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
|
|
57
|
+
/** @typedef {import("./dependencies/ImportPhase").ImportPhaseName} ImportPhaseName */
|
|
55
58
|
/** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
56
59
|
/** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */
|
|
57
60
|
/** @typedef {import("./rules/RuleSetCompiler").RuleSet} RuleSet */
|
|
@@ -72,7 +75,8 @@ const {
|
|
|
72
75
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
|
73
76
|
* @property {string} context
|
|
74
77
|
* @property {string} request
|
|
75
|
-
* @property {
|
|
78
|
+
* @property {ImportPhaseName=} phase
|
|
79
|
+
* @property {ImportAttributes=} attributes
|
|
76
80
|
* @property {ModuleDependency[]} dependencies
|
|
77
81
|
* @property {string} dependencyType
|
|
78
82
|
* @property {CreateData} createData
|
|
@@ -246,6 +250,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
246
250
|
new BasicMatcherRulePlugin("issuer"),
|
|
247
251
|
new BasicMatcherRulePlugin("compiler"),
|
|
248
252
|
new BasicMatcherRulePlugin("issuerLayer"),
|
|
253
|
+
new BasicMatcherRulePlugin("phase"),
|
|
249
254
|
new ObjectMatcherRulePlugin("assert", "attributes", (value) => {
|
|
250
255
|
if (value) {
|
|
251
256
|
return (
|
|
@@ -520,6 +525,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
520
525
|
dependencies,
|
|
521
526
|
dependencyType,
|
|
522
527
|
request,
|
|
528
|
+
phase,
|
|
523
529
|
attributes,
|
|
524
530
|
resolveOptions,
|
|
525
531
|
fileDependencies,
|
|
@@ -687,12 +693,14 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
687
693
|
} else {
|
|
688
694
|
settings.type = JAVASCRIPT_MODULE_TYPE_AUTO;
|
|
689
695
|
const resourceDataForRules = matchResourceData || resourceData;
|
|
696
|
+
|
|
690
697
|
const result = this.ruleSet.exec({
|
|
691
698
|
resource: resourceDataForRules.path,
|
|
692
699
|
realResource: resourceData.path,
|
|
693
700
|
resourceQuery: resourceDataForRules.query,
|
|
694
701
|
resourceFragment: resourceDataForRules.fragment,
|
|
695
702
|
scheme,
|
|
703
|
+
phase,
|
|
696
704
|
attributes,
|
|
697
705
|
mimetype: matchResourceData
|
|
698
706
|
? ""
|
|
@@ -977,6 +985,16 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
977
985
|
const attributes =
|
|
978
986
|
/** @type {ModuleDependency & { attributes: ImportAttributes }} */
|
|
979
987
|
(dependency).attributes;
|
|
988
|
+
const phase =
|
|
989
|
+
typeof (
|
|
990
|
+
/** @type {ModuleDependency & { phase?: ImportPhaseType }} */
|
|
991
|
+
(dependency).phase
|
|
992
|
+
) === "number"
|
|
993
|
+
? ImportPhaseUtils.stringify(
|
|
994
|
+
/** @type {ModuleDependency & { phase?: ImportPhaseType }} */
|
|
995
|
+
(dependency).phase
|
|
996
|
+
)
|
|
997
|
+
: "evaluation";
|
|
980
998
|
const dependencyType = dependency.category || "";
|
|
981
999
|
const contextInfo = data.contextInfo;
|
|
982
1000
|
/** @type {FileSystemDependencies} */
|
|
@@ -991,6 +1009,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
991
1009
|
resolveOptions,
|
|
992
1010
|
context,
|
|
993
1011
|
request,
|
|
1012
|
+
phase,
|
|
994
1013
|
attributes,
|
|
995
1014
|
dependencies,
|
|
996
1015
|
dependencyType,
|
package/lib/ProgressPlugin.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const Compiler = require("./Compiler");
|
|
9
9
|
const MultiCompiler = require("./MultiCompiler");
|
|
10
10
|
const NormalModule = require("./NormalModule");
|
|
11
|
-
const createSchemaValidation = require("./util/create-schema-validation");
|
|
12
11
|
const { contextify } = require("./util/identifier");
|
|
13
12
|
|
|
14
13
|
/** @typedef {import("tapable").Tap} Tap */
|
|
@@ -17,6 +16,7 @@ const { contextify } = require("./util/identifier");
|
|
|
17
16
|
* @typedef {import("tapable").Hook<T, R, AdditionalOptions>} Hook
|
|
18
17
|
*/
|
|
19
18
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginArgument} ProgressPluginArgument */
|
|
19
|
+
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginOptions} ProgressPluginOptions */
|
|
20
20
|
/** @typedef {import("./Compilation").FactorizeModuleOptions} FactorizeModuleOptions */
|
|
21
21
|
/** @typedef {import("./Dependency")} Dependency */
|
|
22
22
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
@@ -35,15 +35,6 @@ const { contextify } = require("./util/identifier");
|
|
|
35
35
|
* @property {number} dependenciesCount dependencies count
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
const validate = createSchemaValidation(
|
|
39
|
-
require("../schemas/plugins/ProgressPlugin.check"),
|
|
40
|
-
() => require("../schemas/plugins/ProgressPlugin.json"),
|
|
41
|
-
{
|
|
42
|
-
name: "Progress Plugin",
|
|
43
|
-
baseDataPath: "options"
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
|
|
47
38
|
/**
|
|
48
39
|
* @param {number} a a
|
|
49
40
|
* @param {number} b b
|
|
@@ -142,6 +133,18 @@ const progressReporters = new WeakMap();
|
|
|
142
133
|
|
|
143
134
|
const PLUGIN_NAME = "ProgressPlugin";
|
|
144
135
|
|
|
136
|
+
/** @type {Required<Omit<ProgressPluginOptions, "handler">>} */
|
|
137
|
+
const DEFAULT_OPTIONS = {
|
|
138
|
+
profile: false,
|
|
139
|
+
modulesCount: 5000,
|
|
140
|
+
dependenciesCount: 10000,
|
|
141
|
+
modules: true,
|
|
142
|
+
dependencies: true,
|
|
143
|
+
activeModules: false,
|
|
144
|
+
entries: true,
|
|
145
|
+
percentBy: null
|
|
146
|
+
};
|
|
147
|
+
|
|
145
148
|
class ProgressPlugin {
|
|
146
149
|
/**
|
|
147
150
|
* @param {Compiler} compiler the current compiler
|
|
@@ -161,18 +164,21 @@ class ProgressPlugin {
|
|
|
161
164
|
};
|
|
162
165
|
}
|
|
163
166
|
|
|
164
|
-
|
|
165
|
-
options =
|
|
167
|
+
/** @type {ProgressPluginOptions} */
|
|
168
|
+
this.options = options;
|
|
166
169
|
|
|
167
|
-
this.profile = options.profile;
|
|
170
|
+
this.profile = options.profile || DEFAULT_OPTIONS.profile;
|
|
168
171
|
this.handler = options.handler;
|
|
169
|
-
this.modulesCount = options.modulesCount;
|
|
170
|
-
this.dependenciesCount =
|
|
171
|
-
|
|
172
|
-
this.
|
|
173
|
-
this.
|
|
174
|
-
this.
|
|
175
|
-
|
|
172
|
+
this.modulesCount = options.modulesCount || DEFAULT_OPTIONS.modulesCount;
|
|
173
|
+
this.dependenciesCount =
|
|
174
|
+
options.dependenciesCount || DEFAULT_OPTIONS.dependenciesCount;
|
|
175
|
+
this.showEntries = options.entries || DEFAULT_OPTIONS.entries;
|
|
176
|
+
this.showModules = options.modules || DEFAULT_OPTIONS.modules;
|
|
177
|
+
this.showDependencies =
|
|
178
|
+
options.dependencies || DEFAULT_OPTIONS.dependencies;
|
|
179
|
+
this.showActiveModules =
|
|
180
|
+
options.activeModules || DEFAULT_OPTIONS.activeModules;
|
|
181
|
+
this.percentBy = options.percentBy || DEFAULT_OPTIONS.percentBy;
|
|
176
182
|
}
|
|
177
183
|
|
|
178
184
|
/**
|
|
@@ -218,6 +224,18 @@ class ProgressPlugin {
|
|
|
218
224
|
* @returns {void}
|
|
219
225
|
*/
|
|
220
226
|
_applyOnCompiler(compiler, handler) {
|
|
227
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
228
|
+
compiler.validate(
|
|
229
|
+
() => require("../schemas/plugins/ProgressPlugin.json"),
|
|
230
|
+
this.options,
|
|
231
|
+
{
|
|
232
|
+
name: "Progress Plugin",
|
|
233
|
+
baseDataPath: "options"
|
|
234
|
+
},
|
|
235
|
+
(options) => require("../schemas/plugins/ProgressPlugin.check")(options)
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
|
|
221
239
|
const showEntries = this.showEntries;
|
|
222
240
|
const showModules = this.showModules;
|
|
223
241
|
const showDependencies = this.showDependencies;
|
|
@@ -697,15 +715,7 @@ class ProgressPlugin {
|
|
|
697
715
|
}
|
|
698
716
|
}
|
|
699
717
|
|
|
700
|
-
ProgressPlugin.defaultOptions =
|
|
701
|
-
profile: false,
|
|
702
|
-
modulesCount: 5000,
|
|
703
|
-
dependenciesCount: 10000,
|
|
704
|
-
modules: true,
|
|
705
|
-
dependencies: true,
|
|
706
|
-
activeModules: false,
|
|
707
|
-
entries: true
|
|
708
|
-
};
|
|
718
|
+
ProgressPlugin.defaultOptions = DEFAULT_OPTIONS;
|
|
709
719
|
|
|
710
720
|
ProgressPlugin.createDefaultHandler = createDefaultHandler;
|
|
711
721
|
|
package/lib/RuntimeGlobals.js
CHANGED
|
@@ -59,6 +59,11 @@ module.exports.chunkName = "__webpack_require__.cn";
|
|
|
59
59
|
*/
|
|
60
60
|
module.exports.compatGetDefaultExport = "__webpack_require__.n";
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* compile a wasm module from id and hash, returning WebAssembly.Module
|
|
64
|
+
*/
|
|
65
|
+
module.exports.compileWasm = "__webpack_require__.vs";
|
|
66
|
+
|
|
62
67
|
/**
|
|
63
68
|
* create a fake namespace object
|
|
64
69
|
*/
|
|
@@ -82,6 +87,7 @@ module.exports.createScriptUrl = "__webpack_require__.tu";
|
|
|
82
87
|
* merge multiple CSS stylesheets (CSSStyleSheet or string) into one CSS text string
|
|
83
88
|
* Arguments: (sheets: Array<CSSStyleSheet | string> | CSSStyleSheet | string) => string
|
|
84
89
|
*/
|
|
90
|
+
module.exports.cssInjectStyle = "__webpack_require__.is";
|
|
85
91
|
module.exports.cssMergeStyleSheets = "__webpack_require__.mcs";
|
|
86
92
|
|
|
87
93
|
/**
|
package/lib/RuntimeTemplate.js
CHANGED
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
const { equals } = require("./util/ArrayHelpers");
|
|
20
20
|
const compileBooleanMatcher = require("./util/compileBooleanMatcher");
|
|
21
21
|
const memoize = require("./util/memoize");
|
|
22
|
-
const propertyAccess = require("./util/
|
|
22
|
+
const { propertyAccess } = require("./util/property");
|
|
23
23
|
const { forEachRuntime, subtractRuntime } = require("./util/runtime");
|
|
24
24
|
|
|
25
25
|
const getHarmonyImportDependency = memoize(() =>
|
|
@@ -11,7 +11,6 @@ const Compilation = require("./Compilation");
|
|
|
11
11
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
|
12
12
|
const ProgressPlugin = require("./ProgressPlugin");
|
|
13
13
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
|
14
|
-
const createSchemaValidation = require("./util/create-schema-validation");
|
|
15
14
|
const createHash = require("./util/createHash");
|
|
16
15
|
const { dirname, relative } = require("./util/fs");
|
|
17
16
|
const generateDebugId = require("./util/generateDebugId");
|
|
@@ -34,14 +33,6 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
|
34
33
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
35
34
|
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
|
36
35
|
|
|
37
|
-
const validate = createSchemaValidation(
|
|
38
|
-
require("../schemas/plugins/SourceMapDevToolPlugin.check"),
|
|
39
|
-
() => require("../schemas/plugins/SourceMapDevToolPlugin.json"),
|
|
40
|
-
{
|
|
41
|
-
name: "SourceMap DevTool Plugin",
|
|
42
|
-
baseDataPath: "options"
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
36
|
/**
|
|
46
37
|
* @typedef {object} SourceMapTask
|
|
47
38
|
* @property {Source} asset
|
|
@@ -141,8 +132,6 @@ class SourceMapDevToolPlugin {
|
|
|
141
132
|
* @throws {Error} throws error, if got more than 1 arguments
|
|
142
133
|
*/
|
|
143
134
|
constructor(options = {}) {
|
|
144
|
-
validate(options);
|
|
145
|
-
|
|
146
135
|
/** @type {undefined | null | false | string} */
|
|
147
136
|
this.sourceMapFilename = options.filename;
|
|
148
137
|
/** @type {false | TemplatePath} */
|
|
@@ -170,6 +159,19 @@ class SourceMapDevToolPlugin {
|
|
|
170
159
|
* @returns {void}
|
|
171
160
|
*/
|
|
172
161
|
apply(compiler) {
|
|
162
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
163
|
+
compiler.validate(
|
|
164
|
+
() => require("../schemas/plugins/SourceMapDevToolPlugin.json"),
|
|
165
|
+
this.options,
|
|
166
|
+
{
|
|
167
|
+
name: "SourceMap DevTool Plugin",
|
|
168
|
+
baseDataPath: "options"
|
|
169
|
+
},
|
|
170
|
+
(options) =>
|
|
171
|
+
require("../schemas/plugins/SourceMapDevToolPlugin.check")(options)
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
|
|
173
175
|
const outputFs =
|
|
174
176
|
/** @type {OutputFileSystem} */
|
|
175
177
|
(compiler.outputFileSystem);
|
|
@@ -138,10 +138,10 @@ const deprecated = (fn, message, code) => {
|
|
|
138
138
|
/**
|
|
139
139
|
* @param {TemplatePath} path the raw path
|
|
140
140
|
* @param {PathData} data context data
|
|
141
|
-
* @param {AssetInfo
|
|
141
|
+
* @param {AssetInfo=} assetInfo extra info about the asset (will be written to)
|
|
142
142
|
* @returns {string} the interpolated path
|
|
143
143
|
*/
|
|
144
|
-
const
|
|
144
|
+
const interpolate = (path, data, assetInfo) => {
|
|
145
145
|
const chunkGraph = data.chunkGraph;
|
|
146
146
|
|
|
147
147
|
/** @type {Map<string, Replacer>} */
|
|
@@ -392,9 +392,10 @@ class TemplatedPathPlugin {
|
|
|
392
392
|
*/
|
|
393
393
|
apply(compiler) {
|
|
394
394
|
compiler.hooks.compilation.tap(plugin, (compilation) => {
|
|
395
|
-
compilation.hooks.assetPath.tap(plugin,
|
|
395
|
+
compilation.hooks.assetPath.tap(plugin, interpolate);
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
module.exports = TemplatedPathPlugin;
|
|
401
|
+
module.exports.interpolate = interpolate;
|