webpack 5.107.0 → 5.107.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.
- package/lib/BannerPlugin.js +3 -4
- package/lib/Chunk.js +21 -25
- package/lib/ChunkGroup.js +57 -15
- package/lib/Compilation.js +33 -11
- package/lib/Compiler.js +27 -3
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/EvalSourceMapDevToolPlugin.js +0 -1
- package/lib/ExportsInfo.js +30 -34
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +2 -1
- package/lib/Module.js +1 -1
- package/lib/ModuleNotFoundError.js +10 -0
- package/lib/ModuleSourceTypeConstants.js +24 -22
- package/lib/MultiCompiler.js +14 -0
- package/lib/NormalModule.js +531 -53
- package/lib/NormalModuleFactory.js +38 -26
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RuntimePlugin.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +335 -57
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +22 -4
- package/lib/asset/AssetBytesGenerator.js +6 -6
- package/lib/asset/AssetGenerator.js +14 -14
- package/lib/asset/AssetModulesPlugin.js +3 -7
- package/lib/asset/AssetSourceGenerator.js +6 -6
- package/lib/buildChunkGraph.js +24 -2
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/css/CssModulesPlugin.js +2 -2
- package/lib/dependencies/CommonJsImportsParserPlugin.js +108 -1
- package/lib/dependencies/CssUrlDependency.js +3 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +21 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +8 -9
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -14
- package/lib/dependencies/HtmlInlineStyleDependency.js +17 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +265 -65
- package/lib/dependencies/HtmlSourceDependency.js +21 -2
- package/lib/dependencies/WorkerPlugin.js +18 -4
- package/lib/hmr/LazyCompilationPlugin.js +104 -0
- package/lib/html/HtmlGenerator.js +81 -33
- package/lib/html/HtmlModulesPlugin.js +87 -28
- package/lib/html/walkHtmlTokens.js +641 -125
- package/lib/index.js +2 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -2
- package/lib/javascript/JavascriptParser.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +30 -24
- package/lib/node/NodeWatchFileSystem.js +37 -22
- package/lib/optimize/ConcatenatedModule.js +3 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +1 -2
- package/lib/optimize/SplitChunksPlugin.js +4 -4
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -8
- package/lib/sharing/ProvideSharedPlugin.js +4 -4
- package/lib/util/fs.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -2
- package/package.json +5 -5
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +11 -9
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +472 -149
|
@@ -69,7 +69,7 @@ const {
|
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
/** @typedef {Pick<RuleSetRule, "type" | "sideEffects" | "parser" | "generator" | "resolve" | "layer" | "extractSourceMap">} ModuleSettings */
|
|
72
|
-
/** @typedef {
|
|
72
|
+
/** @typedef {NormalModuleCreateData & { settings: ModuleSettings }} CreateData */
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Defines the resolve data type used by this module.
|
|
@@ -82,7 +82,7 @@ const {
|
|
|
82
82
|
* @property {ImportAttributes=} attributes
|
|
83
83
|
* @property {ModuleDependency[]} dependencies
|
|
84
84
|
* @property {string} dependencyType
|
|
85
|
-
* @property {CreateData} createData
|
|
85
|
+
* @property {Partial<CreateData>} createData
|
|
86
86
|
* @property {FileSystemDependencies} fileDependencies
|
|
87
87
|
* @property {FileSystemDependencies} missingDependencies
|
|
88
88
|
* @property {FileSystemDependencies} contextDependencies
|
|
@@ -324,7 +324,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
324
324
|
/** @typedef {import("./html/HtmlParser")} HtmlParser */
|
|
325
325
|
/** @typedef {import("../declarations/WebpackOptions").EmptyParserOptions} HtmlParserOptions */
|
|
326
326
|
/** @typedef {import("./html/HtmlGenerator")} HtmlGenerator */
|
|
327
|
-
/** @typedef {import("../declarations/WebpackOptions").
|
|
327
|
+
/** @typedef {import("../declarations/WebpackOptions").HtmlGeneratorOptions} HtmlGeneratorOptions */
|
|
328
328
|
|
|
329
329
|
/* eslint-disable jsdoc/type-formatting */
|
|
330
330
|
/**
|
|
@@ -339,8 +339,8 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
339
339
|
* [ASSET_MODULE_TYPE_RESOURCE, AssetParser, EmptyParserOptions, AssetGenerator, AssetGeneratorOptions],
|
|
340
340
|
* [ASSET_MODULE_TYPE_SOURCE, AssetSourceParser, EmptyParserOptions, AssetSourceGenerator, EmptyGeneratorOptions],
|
|
341
341
|
* [ASSET_MODULE_TYPE_BYTES, AssetBytesParser, EmptyParserOptions, AssetBytesGenerator, EmptyGeneratorOptions],
|
|
342
|
-
* [WEBASSEMBLY_MODULE_TYPE_ASYNC, AsyncWebAssemblyParser, EmptyParserOptions, Generator,
|
|
343
|
-
* [WEBASSEMBLY_MODULE_TYPE_SYNC, WebAssemblyParser, EmptyParserOptions, Generator,
|
|
342
|
+
* [WEBASSEMBLY_MODULE_TYPE_ASYNC, AsyncWebAssemblyParser, EmptyParserOptions, Generator, EmptyGeneratorOptions],
|
|
343
|
+
* [WEBASSEMBLY_MODULE_TYPE_SYNC, WebAssemblyParser, EmptyParserOptions, Generator, EmptyGeneratorOptions],
|
|
344
344
|
* [CSS_MODULE_TYPE, CssParser, CssParserOptions, CssGenerator, CssGeneratorOptions],
|
|
345
345
|
* [CSS_MODULE_TYPE_AUTO, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
346
346
|
* [CSS_MODULE_TYPE_MODULE, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
@@ -366,6 +366,18 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
366
366
|
* @typedef {T extends [infer Head extends [string, ...unknown[]], ...infer Tail extends [string, ...unknown[]][]] ? Record<Head[0], SyncBailHook<ExtractTupleElements<Head, A>, R extends number ? Head[R] : R>> & RecordFactoryFromTuple<Tail, A, R> : unknown } RecordFactoryFromTuple
|
|
367
367
|
*/
|
|
368
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Maps each tuple in `T` to a record from its `[0]` key to its `[I]` value.
|
|
371
|
+
* @template {unknown[]} T
|
|
372
|
+
* @template {number} I
|
|
373
|
+
* @typedef {T extends [infer Head extends [string, ...unknown[]], ...infer Tail extends [string, ...unknown[]][]] ? Record<Head[0], I extends keyof Head ? Head[I] : never> & TupleToTypeMap<Tail, I> : unknown } TupleToTypeMap
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
/** @typedef {TupleToTypeMap<ParsersAndGeneratorsByTypes, 1>} ParserByType */
|
|
377
|
+
/** @typedef {TupleToTypeMap<ParsersAndGeneratorsByTypes, 2>} ParserOptionsByType */
|
|
378
|
+
/** @typedef {TupleToTypeMap<ParsersAndGeneratorsByTypes, 3>} GeneratorByType */
|
|
379
|
+
/** @typedef {TupleToTypeMap<ParsersAndGeneratorsByTypes, 4>} GeneratorOptionsByType */
|
|
380
|
+
|
|
369
381
|
class NormalModuleFactory extends ModuleFactory {
|
|
370
382
|
/**
|
|
371
383
|
* Creates an instance of NormalModuleFactory.
|
|
@@ -493,7 +505,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
493
505
|
// Ignored
|
|
494
506
|
if (result === false) return callback();
|
|
495
507
|
|
|
496
|
-
const createData =
|
|
508
|
+
const createData =
|
|
509
|
+
/** @type {CreateData} */
|
|
510
|
+
(resolveData.createData);
|
|
497
511
|
|
|
498
512
|
this.hooks.createModule.callAsync(
|
|
499
513
|
createData,
|
|
@@ -506,18 +520,12 @@ class NormalModuleFactory extends ModuleFactory {
|
|
|
506
520
|
|
|
507
521
|
// TODO webpack 6 make it required and move javascript/wasm/asset properties to own module
|
|
508
522
|
createdModule = this.hooks.createModuleClass
|
|
509
|
-
.for(
|
|
510
|
-
/** @type {ModuleSettings} */
|
|
511
|
-
(createData.settings).type
|
|
512
|
-
)
|
|
523
|
+
.for(createData.settings.type)
|
|
513
524
|
.call(createData, resolveData);
|
|
514
525
|
|
|
515
526
|
if (!createdModule) {
|
|
516
527
|
createdModule = /** @type {Module} */ (
|
|
517
|
-
new NormalModule(
|
|
518
|
-
/** @type {NormalModuleCreateData} */
|
|
519
|
-
(createData)
|
|
520
|
-
)
|
|
528
|
+
new NormalModule(createData)
|
|
521
529
|
);
|
|
522
530
|
}
|
|
523
531
|
}
|
|
@@ -1405,9 +1413,10 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1405
1413
|
|
|
1406
1414
|
/**
|
|
1407
1415
|
* Returns parser.
|
|
1408
|
-
* @
|
|
1416
|
+
* @template {string} T
|
|
1417
|
+
* @param {T} type type
|
|
1409
1418
|
* @param {ParserOptions} parserOptions parser options
|
|
1410
|
-
* @returns {
|
|
1419
|
+
* @returns {ParserByType[T]} parser
|
|
1411
1420
|
*/
|
|
1412
1421
|
getParser(type, parserOptions = EMPTY_PARSER_OPTIONS) {
|
|
1413
1422
|
let cache = this.parserCache.get(type);
|
|
@@ -1424,14 +1433,15 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1424
1433
|
cache.set(parserOptions, parser);
|
|
1425
1434
|
}
|
|
1426
1435
|
|
|
1427
|
-
return parser;
|
|
1436
|
+
return /** @type {ParserByType[T]} */ (parser);
|
|
1428
1437
|
}
|
|
1429
1438
|
|
|
1430
1439
|
/**
|
|
1431
1440
|
* Creates a parser from the provided type.
|
|
1432
|
-
* @
|
|
1441
|
+
* @template {string} T
|
|
1442
|
+
* @param {T} type type
|
|
1433
1443
|
* @param {ParserOptions} parserOptions parser options
|
|
1434
|
-
* @returns {
|
|
1444
|
+
* @returns {ParserByType[T]} parser
|
|
1435
1445
|
*/
|
|
1436
1446
|
createParser(type, parserOptions = {}) {
|
|
1437
1447
|
parserOptions = mergeGlobalOptions(
|
|
@@ -1444,14 +1454,15 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1444
1454
|
throw new Error(`No parser registered for ${type}`);
|
|
1445
1455
|
}
|
|
1446
1456
|
this.hooks.parser.for(type).call(parser, parserOptions);
|
|
1447
|
-
return parser;
|
|
1457
|
+
return /** @type {ParserByType[T]} */ (parser);
|
|
1448
1458
|
}
|
|
1449
1459
|
|
|
1450
1460
|
/**
|
|
1451
1461
|
* Returns generator.
|
|
1452
|
-
* @
|
|
1462
|
+
* @template {string} T
|
|
1463
|
+
* @param {T} type type of generator
|
|
1453
1464
|
* @param {GeneratorOptions} generatorOptions generator options
|
|
1454
|
-
* @returns {
|
|
1465
|
+
* @returns {GeneratorByType[T]} generator
|
|
1455
1466
|
*/
|
|
1456
1467
|
getGenerator(type, generatorOptions = EMPTY_GENERATOR_OPTIONS) {
|
|
1457
1468
|
let cache = this.generatorCache.get(type);
|
|
@@ -1468,14 +1479,15 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1468
1479
|
cache.set(generatorOptions, generator);
|
|
1469
1480
|
}
|
|
1470
1481
|
|
|
1471
|
-
return generator;
|
|
1482
|
+
return /** @type {GeneratorByType[T]} */ (generator);
|
|
1472
1483
|
}
|
|
1473
1484
|
|
|
1474
1485
|
/**
|
|
1475
1486
|
* Creates a generator.
|
|
1476
|
-
* @
|
|
1487
|
+
* @template {string} T
|
|
1488
|
+
* @param {T} type type of generator
|
|
1477
1489
|
* @param {GeneratorOptions} generatorOptions generator options
|
|
1478
|
-
* @returns {
|
|
1490
|
+
* @returns {GeneratorByType[T]} generator
|
|
1479
1491
|
*/
|
|
1480
1492
|
createGenerator(type, generatorOptions = {}) {
|
|
1481
1493
|
generatorOptions = mergeGlobalOptions(
|
|
@@ -1490,7 +1502,7 @@ If changing the source code is not an option there is also a resolve options cal
|
|
|
1490
1502
|
throw new Error(`No generator registered for ${type}`);
|
|
1491
1503
|
}
|
|
1492
1504
|
this.hooks.generator.for(type).call(generator, generatorOptions);
|
|
1493
|
-
return generator;
|
|
1505
|
+
return /** @type {GeneratorByType[T]} */ (generator);
|
|
1494
1506
|
}
|
|
1495
1507
|
|
|
1496
1508
|
/**
|
package/lib/ProgressPlugin.js
CHANGED
|
@@ -150,7 +150,7 @@ const createReportBar = (name, color) => {
|
|
|
150
150
|
* Creates a default handler.
|
|
151
151
|
* @param {boolean | null | undefined} profile need profile
|
|
152
152
|
* @param {Logger} logger logger
|
|
153
|
-
* @param {ProgressBarOptions | false} progressBar render bar
|
|
153
|
+
* @param {ProgressBarOptions | false=} progressBar render bar
|
|
154
154
|
* @returns {HandlerFn} default handler
|
|
155
155
|
*/
|
|
156
156
|
const createDefaultHandler = (profile, logger, progressBar) => {
|