webpack 5.99.6 → 5.99.8
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/AutomaticPrefetchPlugin.js +21 -22
- package/lib/BannerPlugin.js +31 -35
- package/lib/CleanPlugin.js +5 -3
- package/lib/Compilation.js +21 -15
- package/lib/Compiler.js +2 -1
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextModule.js +1 -1
- package/lib/ContextModuleFactory.js +1 -2
- package/lib/ContextReplacementPlugin.js +7 -4
- package/lib/DefinePlugin.js +2 -2
- package/lib/DelegatedModule.js +18 -8
- package/lib/DelegatedModuleFactoryPlugin.js +9 -7
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllPlugin.js +5 -3
- package/lib/DllReferencePlugin.js +56 -60
- package/lib/DynamicEntryPlugin.js +4 -2
- package/lib/EntryOptionPlugin.js +3 -1
- package/lib/EntryPlugin.js +4 -2
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/EvalDevToolModulePlugin.js +9 -7
- package/lib/EvalSourceMapDevToolPlugin.js +138 -139
- package/lib/ExportsInfo.js +35 -16
- package/lib/ExternalModule.js +6 -5
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FileSystemInfo.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +2 -1
- package/lib/IgnorePlugin.js +6 -4
- package/lib/IgnoreWarningsPlugin.js +4 -2
- package/lib/LibManifestPlugin.js +5 -6
- package/lib/LoaderOptionsPlugin.js +4 -2
- package/lib/LoaderTargetPlugin.js +4 -2
- package/lib/Module.js +19 -12
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +13 -8
- package/lib/NormalModuleReplacementPlugin.js +33 -36
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +4 -2
- package/lib/ProgressPlugin.js +23 -26
- package/lib/RecordIdsPlugin.js +72 -102
- package/lib/RuntimePlugin.js +34 -32
- package/lib/SourceMapDevToolPlugin.js +9 -8
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +3 -1
- package/lib/WebpackError.js +11 -3
- package/lib/WebpackOptionsApply.js +6 -7
- package/lib/asset/AssetGenerator.js +2 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/cache/IdleFileCachePlugin.js +11 -12
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
- package/lib/cache/ResolverCachePlugin.js +8 -6
- package/lib/cli.js +5 -1
- package/lib/config/defaults.js +10 -6
- package/lib/config/normalization.js +14 -8
- package/lib/container/ContainerReferencePlugin.js +24 -26
- package/lib/container/ModuleFederationPlugin.js +2 -1
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssModulesPlugin.js +8 -6
- package/lib/debug/ProfilingPlugin.js +18 -21
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
- package/lib/dependencies/LoaderPlugin.js +5 -3
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -2
- package/lib/hmr/LazyCompilationPlugin.js +17 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
- package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
- package/lib/ids/HashedModuleIdsPlugin.js +4 -2
- package/lib/ids/NamedChunkIdsPlugin.js +4 -2
- package/lib/ids/NamedModuleIdsPlugin.js +4 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
- package/lib/index.js +11 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -2
- package/lib/javascript/JavascriptParser.js +634 -656
- package/lib/json/JsonModulesPlugin.js +4 -4
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +60 -42
- package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/node/nodeConsole.js +3 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
- package/lib/optimize/ConcatenatedModule.js +15 -16
- package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +15 -16
- package/lib/optimize/MinChunkSizePlugin.js +4 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +6 -4
- package/lib/optimize/RealContentHashPlugin.js +4 -2
- package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
- package/lib/optimize/RuntimeChunkPlugin.js +21 -23
- package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
- package/lib/optimize/SplitChunksPlugin.js +9 -7
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- package/lib/rules/BasicEffectRulePlugin.js +1 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +4 -6
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/schemes/DataUriPlugin.js +5 -3
- package/lib/schemes/FileUriPlugin.js +5 -3
- package/lib/schemes/HttpUriPlugin.js +186 -188
- package/lib/serialization/AggregateErrorSerializer.js +42 -0
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/ObjectMiddleware.js +13 -0
- package/lib/sharing/ProvideSharedPlugin.js +6 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
- package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
- package/lib/util/concatenate.js +4 -2
- package/lib/util/createHash.js +3 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
- package/package.json +35 -30
- package/schemas/WebpackOptions.check.d.ts +1 -1
- package/schemas/WebpackOptions.check.js +2 -2
- package/schemas/WebpackOptions.json +267 -26
- package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/DllPlugin.check.d.ts +1 -1
- package/schemas/plugins/DllPlugin.check.js +1 -1
- package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
- package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
- package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
- package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +587 -207
- package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
- package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginParser.json +0 -16
package/lib/ExportsInfo.js
CHANGED
@@ -34,9 +34,18 @@ const RETURNS_TRUE = () => true;
|
|
34
34
|
|
35
35
|
const CIRCULAR = Symbol("circular target");
|
36
36
|
|
37
|
+
/**
|
38
|
+
* @typedef {object} RestoreProvidedDataExports
|
39
|
+
* @property {ExportInfoName} name
|
40
|
+
* @property {ExportInfo["provided"]} provided
|
41
|
+
* @property {ExportInfo["canMangleProvide"]} canMangleProvide
|
42
|
+
* @property {ExportInfo["terminalBinding"]} terminalBinding
|
43
|
+
* @property {RestoreProvidedData | undefined} exportsInfo
|
44
|
+
*/
|
45
|
+
|
37
46
|
class RestoreProvidedData {
|
38
47
|
/**
|
39
|
-
* @param {
|
48
|
+
* @param {RestoreProvidedDataExports[]} exports exports
|
40
49
|
* @param {ExportInfo["provided"]} otherProvided other provided
|
41
50
|
* @param {ExportInfo["canMangleProvide"]} otherCanMangleProvide other can mangle provide
|
42
51
|
* @param {ExportInfo["terminalBinding"]} otherTerminalBinding other terminal binding
|
@@ -78,7 +87,7 @@ makeSerializable(
|
|
78
87
|
"RestoreProvidedData"
|
79
88
|
);
|
80
89
|
|
81
|
-
/** @typedef {Map<
|
90
|
+
/** @typedef {Map<ExportInfoName, ExportInfo>} Exports */
|
82
91
|
/** @typedef {string | string[] | false} UsedName */
|
83
92
|
|
84
93
|
class ExportsInfo {
|
@@ -131,6 +140,7 @@ class ExportsInfo {
|
|
131
140
|
this._sortExports();
|
132
141
|
}
|
133
142
|
if (this._redirectTo !== undefined) {
|
143
|
+
/** @type {Exports} */
|
134
144
|
const map = new Map(
|
135
145
|
Array.from(this._redirectTo.orderedExports, item => [item.name, item])
|
136
146
|
);
|
@@ -160,6 +170,7 @@ class ExportsInfo {
|
|
160
170
|
*/
|
161
171
|
_sortExportsMap(exports) {
|
162
172
|
if (exports.size > 1) {
|
173
|
+
/** @type {string[]} */
|
163
174
|
const namesInOrder = [];
|
164
175
|
for (const entry of exports.values()) {
|
165
176
|
namesInOrder.push(entry.name);
|
@@ -229,7 +240,7 @@ class ExportsInfo {
|
|
229
240
|
}
|
230
241
|
|
231
242
|
/**
|
232
|
-
* @param {
|
243
|
+
* @param {ExportInfoName} name export name
|
233
244
|
* @returns {ExportInfo} export info for this name
|
234
245
|
*/
|
235
246
|
getOwnExportInfo(name) {
|
@@ -242,7 +253,7 @@ class ExportsInfo {
|
|
242
253
|
}
|
243
254
|
|
244
255
|
/**
|
245
|
-
* @param {
|
256
|
+
* @param {ExportInfoName} name export name
|
246
257
|
* @returns {ExportInfo} export info for this name
|
247
258
|
*/
|
248
259
|
getExportInfo(name) {
|
@@ -257,7 +268,7 @@ class ExportsInfo {
|
|
257
268
|
}
|
258
269
|
|
259
270
|
/**
|
260
|
-
* @param {
|
271
|
+
* @param {ExportInfoName} name export name
|
261
272
|
* @returns {ExportInfo} export info for this name
|
262
273
|
*/
|
263
274
|
getReadOnlyExportInfo(name) {
|
@@ -269,7 +280,7 @@ class ExportsInfo {
|
|
269
280
|
}
|
270
281
|
|
271
282
|
/**
|
272
|
-
* @param {
|
283
|
+
* @param {ExportInfoName[]} name export name
|
273
284
|
* @returns {ExportInfo | undefined} export info for this name
|
274
285
|
*/
|
275
286
|
getReadOnlyExportInfoRecursive(name) {
|
@@ -280,7 +291,7 @@ class ExportsInfo {
|
|
280
291
|
}
|
281
292
|
|
282
293
|
/**
|
283
|
-
* @param {
|
294
|
+
* @param {ExportInfoName[]=} name the export name
|
284
295
|
* @returns {ExportsInfo | undefined} the nested exports info
|
285
296
|
*/
|
286
297
|
getNestedExportsInfo(name) {
|
@@ -327,7 +338,8 @@ class ExportsInfo {
|
|
327
338
|
if (targetKey) {
|
328
339
|
exportInfo.setTarget(
|
329
340
|
targetKey,
|
330
|
-
/** @type {ModuleGraphConnection} */
|
341
|
+
/** @type {ModuleGraphConnection} */
|
342
|
+
(targetModule),
|
331
343
|
[exportInfo.name],
|
332
344
|
-1
|
333
345
|
);
|
@@ -552,6 +564,7 @@ class ExportsInfo {
|
|
552
564
|
return true;
|
553
565
|
}
|
554
566
|
}
|
567
|
+
/** @type {string[]} */
|
555
568
|
const array = [];
|
556
569
|
if (!this._exportsAreOrdered) this._sortExports();
|
557
570
|
for (const exportInfo of this._exports.values()) {
|
@@ -604,7 +617,7 @@ class ExportsInfo {
|
|
604
617
|
}
|
605
618
|
|
606
619
|
/**
|
607
|
-
* @param {
|
620
|
+
* @param {ExportInfoName | ExportInfoName[]} name the name of the export
|
608
621
|
* @returns {boolean | undefined | null} if the export is provided
|
609
622
|
*/
|
610
623
|
isExportProvided(name) {
|
@@ -665,7 +678,7 @@ class ExportsInfo {
|
|
665
678
|
}
|
666
679
|
|
667
680
|
/**
|
668
|
-
* @param {
|
681
|
+
* @param {ExportInfoName | ExportInfoName[]} name export name
|
669
682
|
* @param {RuntimeSpec} runtime check usage for this runtime only
|
670
683
|
* @returns {UsageStateType} usage status
|
671
684
|
*/
|
@@ -683,7 +696,7 @@ class ExportsInfo {
|
|
683
696
|
}
|
684
697
|
|
685
698
|
/**
|
686
|
-
* @param {
|
699
|
+
* @param {ExportInfoName | ExportInfoName[]} name the export name
|
687
700
|
* @param {RuntimeSpec} runtime check usage for this runtime only
|
688
701
|
* @returns {UsedName} the used name
|
689
702
|
*/
|
@@ -698,7 +711,7 @@ class ExportsInfo {
|
|
698
711
|
const x = info.getUsedName(name[0], runtime);
|
699
712
|
if (x === false) return false;
|
700
713
|
const arr =
|
701
|
-
/** @type {
|
714
|
+
/** @type {ExportInfoName[]} */
|
702
715
|
(x === name[0] && name.length === 1 ? name : [x]);
|
703
716
|
if (name.length === 1) {
|
704
717
|
return arr;
|
@@ -755,6 +768,7 @@ class ExportsInfo {
|
|
755
768
|
const otherProvided = this._otherExportsInfo.provided;
|
756
769
|
const otherCanMangleProvide = this._otherExportsInfo.canMangleProvide;
|
757
770
|
const otherTerminalBinding = this._otherExportsInfo.terminalBinding;
|
771
|
+
/** @type {RestoreProvidedDataExports[]} */
|
758
772
|
const exports = [];
|
759
773
|
for (const exportInfo of this.orderedExports) {
|
760
774
|
if (
|
@@ -827,19 +841,24 @@ class ExportsInfo {
|
|
827
841
|
/** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */
|
828
842
|
|
829
843
|
/** @typedef {{ connection: ModuleGraphConnection, export: string[], priority: number }} TargetItem */
|
844
|
+
|
830
845
|
/** @typedef {Map<Dependency | undefined, TargetItem>} Target */
|
831
846
|
|
847
|
+
/** @typedef {string} ExportInfoName */
|
848
|
+
/** @typedef {string | null} ExportInfoUsedName */
|
849
|
+
/** @typedef {boolean | null} ExportInfoProvided */
|
850
|
+
|
832
851
|
class ExportInfo {
|
833
852
|
/**
|
834
|
-
* @param {
|
853
|
+
* @param {ExportInfoName} name the original name of the export
|
835
854
|
* @param {ExportInfo=} initFrom init values from this ExportInfo
|
836
855
|
*/
|
837
856
|
constructor(name, initFrom) {
|
838
|
-
/** @type {
|
857
|
+
/** @type {ExportInfoName} */
|
839
858
|
this.name = name;
|
840
859
|
/**
|
841
860
|
* @private
|
842
|
-
* @type {
|
861
|
+
* @type {ExportInfoUsedName}
|
843
862
|
*/
|
844
863
|
this._usedName = initFrom ? initFrom._usedName : null;
|
845
864
|
/**
|
@@ -867,7 +886,7 @@ class ExportInfo {
|
|
867
886
|
* false: it is not provided
|
868
887
|
* null: only the runtime knows if it is provided
|
869
888
|
* undefined: it was not determined if it is provided
|
870
|
-
* @type {
|
889
|
+
* @type {ExportInfoProvided | undefined}
|
871
890
|
*/
|
872
891
|
this.provided = initFrom ? initFrom.provided : undefined;
|
873
892
|
/**
|
package/lib/ExternalModule.js
CHANGED
@@ -28,6 +28,7 @@ const propertyAccess = require("./util/propertyAccess");
|
|
28
28
|
const { register } = require("./util/serialization");
|
29
29
|
|
30
30
|
/** @typedef {import("webpack-sources").Source} Source */
|
31
|
+
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
31
32
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
32
33
|
/** @typedef {import("./Chunk")} Chunk */
|
33
34
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
@@ -58,7 +59,6 @@ const { register } = require("./util/serialization");
|
|
58
59
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
59
60
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
60
61
|
/** @typedef {import("./util/Hash")} Hash */
|
61
|
-
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
62
62
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
63
63
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
64
64
|
|
@@ -215,9 +215,10 @@ const getSourceForImportExternal = (
|
|
215
215
|
};
|
216
216
|
|
217
217
|
/**
|
218
|
-
* @
|
219
|
-
* @param {
|
220
|
-
* @
|
218
|
+
* @template {{ [key: string]: string }} T
|
219
|
+
* @param {keyof T} key key
|
220
|
+
* @param {T[keyof T]} value value
|
221
|
+
* @returns {undefined | T[keyof T]} replaced value
|
221
222
|
*/
|
222
223
|
const importAssertionReplacer = (key, value) => {
|
223
224
|
if (key === "_isLegacyAssert") {
|
@@ -235,7 +236,7 @@ class ModuleExternalInitFragment extends InitFragment {
|
|
235
236
|
* @param {string} request import source
|
236
237
|
* @param {string=} ident recomputed ident
|
237
238
|
* @param {ImportDependencyMeta=} dependencyMeta the dependency meta
|
238
|
-
* @param {
|
239
|
+
* @param {HashFunction=} hashFunction the hash function to use
|
239
240
|
*/
|
240
241
|
constructor(
|
241
242
|
request,
|
package/lib/ExternalsPlugin.js
CHANGED
@@ -10,6 +10,8 @@ const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
|
10
10
|
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "ExternalsPlugin";
|
14
|
+
|
13
15
|
class ExternalsPlugin {
|
14
16
|
/**
|
15
17
|
* @param {string | undefined} type default external type
|
@@ -26,7 +28,7 @@ class ExternalsPlugin {
|
|
26
28
|
* @returns {void}
|
27
29
|
*/
|
28
30
|
apply(compiler) {
|
29
|
-
compiler.hooks.compile.tap(
|
31
|
+
compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
|
30
32
|
new ExternalModuleFactoryPlugin(this.type, this.externals).apply(
|
31
33
|
normalModuleFactory
|
32
34
|
);
|
package/lib/FileSystemInfo.js
CHANGED
@@ -24,7 +24,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
24
24
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
25
25
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
26
26
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
27
|
-
/** @typedef {
|
27
|
+
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
28
28
|
/** @typedef {import("./util/fs").IStats} IStats */
|
29
29
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
30
30
|
/** @typedef {import("./util/fs").PathLike} PathLike */
|
@@ -1058,7 +1058,7 @@ class FileSystemInfo {
|
|
1058
1058
|
* @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
|
1059
1059
|
* @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
|
1060
1060
|
* @param {Logger=} options.logger logger used to log invalid snapshots
|
1061
|
-
* @param {
|
1061
|
+
* @param {HashFunction=} options.hashFunction the hash function to use
|
1062
1062
|
*/
|
1063
1063
|
constructor(
|
1064
1064
|
fs,
|
package/lib/IgnorePlugin.js
CHANGED
@@ -22,6 +22,8 @@ const validate = createSchemaValidation(
|
|
22
22
|
}
|
23
23
|
);
|
24
24
|
|
25
|
+
const PLUGIN_NAME = "IgnorePlugin";
|
26
|
+
|
25
27
|
class IgnorePlugin {
|
26
28
|
/**
|
27
29
|
* @param {IgnorePluginOptions} options IgnorePlugin options
|
@@ -69,8 +71,8 @@ class IgnorePlugin {
|
|
69
71
|
* @returns {void}
|
70
72
|
*/
|
71
73
|
apply(compiler) {
|
72
|
-
compiler.hooks.normalModuleFactory.tap(
|
73
|
-
nmf.hooks.beforeResolve.tap(
|
74
|
+
compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, nmf => {
|
75
|
+
nmf.hooks.beforeResolve.tap(PLUGIN_NAME, resolveData => {
|
74
76
|
const result = this.checkIgnore(resolveData);
|
75
77
|
|
76
78
|
if (
|
@@ -88,8 +90,8 @@ class IgnorePlugin {
|
|
88
90
|
return result;
|
89
91
|
});
|
90
92
|
});
|
91
|
-
compiler.hooks.contextModuleFactory.tap(
|
92
|
-
cmf.hooks.beforeResolve.tap(
|
93
|
+
compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
|
94
|
+
cmf.hooks.beforeResolve.tap(PLUGIN_NAME, this.checkIgnore);
|
93
95
|
});
|
94
96
|
}
|
95
97
|
}
|
@@ -8,6 +8,8 @@
|
|
8
8
|
/** @typedef {import("../declarations/WebpackOptions").IgnoreWarningsNormalized} IgnoreWarningsNormalized */
|
9
9
|
/** @typedef {import("./Compiler")} Compiler */
|
10
10
|
|
11
|
+
const PLUGIN_NAME = "IgnoreWarningsPlugin";
|
12
|
+
|
11
13
|
class IgnoreWarningsPlugin {
|
12
14
|
/**
|
13
15
|
* @param {IgnoreWarningsNormalized} ignoreWarnings conditions to ignore warnings
|
@@ -22,8 +24,8 @@ class IgnoreWarningsPlugin {
|
|
22
24
|
* @returns {void}
|
23
25
|
*/
|
24
26
|
apply(compiler) {
|
25
|
-
compiler.hooks.compilation.tap(
|
26
|
-
compilation.hooks.processWarnings.tap(
|
27
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
28
|
+
compilation.hooks.processWarnings.tap(PLUGIN_NAME, warnings =>
|
27
29
|
warnings.filter(
|
28
30
|
warning =>
|
29
31
|
!this._ignoreWarnings.some(ignore => ignore(warning, compilation))
|
package/lib/LibManifestPlugin.js
CHANGED
@@ -19,8 +19,8 @@ const { dirname, mkdirp } = require("./util/fs");
|
|
19
19
|
/**
|
20
20
|
* @typedef {object} ManifestModuleData
|
21
21
|
* @property {string | number} id
|
22
|
-
* @property {BuildMeta} buildMeta
|
23
|
-
* @property {boolean | string[]
|
22
|
+
* @property {BuildMeta=} buildMeta
|
23
|
+
* @property {boolean | string[]=} exports
|
24
24
|
*/
|
25
25
|
|
26
26
|
/**
|
@@ -33,6 +33,8 @@ const { dirname, mkdirp } = require("./util/fs");
|
|
33
33
|
* @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
|
34
34
|
*/
|
35
35
|
|
36
|
+
const PLUGIN_NAME = "LibManifestPlugin";
|
37
|
+
|
36
38
|
class LibManifestPlugin {
|
37
39
|
/**
|
38
40
|
* @param {LibManifestPluginOptions} options the options
|
@@ -48,10 +50,7 @@ class LibManifestPlugin {
|
|
48
50
|
*/
|
49
51
|
apply(compiler) {
|
50
52
|
compiler.hooks.emit.tapAsync(
|
51
|
-
{
|
52
|
-
name: "LibManifestPlugin",
|
53
|
-
stage: 110
|
54
|
-
},
|
53
|
+
{ name: PLUGIN_NAME, stage: 110 },
|
55
54
|
(compilation, callback) => {
|
56
55
|
const moduleGraph = compilation.moduleGraph;
|
57
56
|
// store used paths to detect issue and output an error. #18200
|
@@ -28,6 +28,8 @@ const validate = createSchemaValidation(
|
|
28
28
|
}
|
29
29
|
);
|
30
30
|
|
31
|
+
const PLUGIN_NAME = "LoaderOptionsPlugin";
|
32
|
+
|
31
33
|
class LoaderOptionsPlugin {
|
32
34
|
/**
|
33
35
|
* @param {LoaderOptionsPluginOptions & MatchObject} options options object
|
@@ -55,9 +57,9 @@ class LoaderOptionsPlugin {
|
|
55
57
|
*/
|
56
58
|
apply(compiler) {
|
57
59
|
const options = this.options;
|
58
|
-
compiler.hooks.compilation.tap(
|
60
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
59
61
|
NormalModule.getCompilationHooks(compilation).loader.tap(
|
60
|
-
|
62
|
+
PLUGIN_NAME,
|
61
63
|
(context, module) => {
|
62
64
|
const resource = module.resource;
|
63
65
|
if (!resource) return;
|
@@ -9,6 +9,8 @@ const NormalModule = require("./NormalModule");
|
|
9
9
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
|
12
|
+
const PLUGIN_NAME = "LoaderTargetPlugin";
|
13
|
+
|
12
14
|
class LoaderTargetPlugin {
|
13
15
|
/**
|
14
16
|
* @param {string} target the target
|
@@ -23,9 +25,9 @@ class LoaderTargetPlugin {
|
|
23
25
|
* @returns {void}
|
24
26
|
*/
|
25
27
|
apply(compiler) {
|
26
|
-
compiler.hooks.compilation.tap(
|
28
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
27
29
|
NormalModule.getCompilationHooks(compilation).loader.tap(
|
28
|
-
|
30
|
+
PLUGIN_NAME,
|
29
31
|
loaderContext => {
|
30
32
|
loaderContext.target = this.target;
|
31
33
|
}
|
package/lib/Module.js
CHANGED
@@ -28,6 +28,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
28
28
|
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
29
29
|
/** @typedef {import("./Dependency")} Dependency */
|
30
30
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
31
|
+
/** @typedef {import("./DependencyTemplate").CssData} CssData */
|
31
32
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
32
33
|
/** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
|
33
34
|
/** @typedef {import("./FileSystemInfo")} FileSystemInfo */
|
@@ -120,19 +121,25 @@ const makeSerializable = require("./util/makeSerializable");
|
|
120
121
|
* @typedef {object} KnownBuildInfo
|
121
122
|
* @property {boolean=} cacheable
|
122
123
|
* @property {boolean=} parsed
|
123
|
-
* @property {string=} moduleArgument
|
124
|
-
* @property {string=} exportsArgument
|
125
124
|
* @property {boolean=} strict
|
126
|
-
* @property {string=}
|
127
|
-
* @property {
|
128
|
-
* @property {
|
129
|
-
* @property {
|
130
|
-
* @property {
|
131
|
-
* @property {
|
132
|
-
* @property {
|
133
|
-
* @property {
|
134
|
-
* @property {
|
135
|
-
* @property {
|
125
|
+
* @property {string=} moduleArgument using in AMD
|
126
|
+
* @property {string=} exportsArgument using in AMD
|
127
|
+
* @property {string=} moduleConcatenationBailout using in CommonJs
|
128
|
+
* @property {boolean=} needCreateRequire using in APIPlugin
|
129
|
+
* @property {string=} resourceIntegrity using in HttpUriPlugin
|
130
|
+
* @property {LazySet<string>=} fileDependencies using in NormalModule
|
131
|
+
* @property {LazySet<string>=} contextDependencies using in NormalModule
|
132
|
+
* @property {LazySet<string>=} missingDependencies using in NormalModule
|
133
|
+
* @property {LazySet<string>=} buildDependencies using in NormalModule
|
134
|
+
* @property {ValueCacheVersions=} valueDependencies using in NormalModule
|
135
|
+
* @property {Record<string, Source>=} assets using in NormalModule
|
136
|
+
* @property {string=} hash using in NormalModule
|
137
|
+
* @property {(Snapshot | null)=} snapshot using in ContextModule
|
138
|
+
* @property {string=} fullContentHash for assets modules
|
139
|
+
* @property {string=} filename for assets modules
|
140
|
+
* @property {Map<string, AssetInfo | undefined>=} assetsInfo for assets modules
|
141
|
+
* @property {boolean=} dataUrl for assets modules
|
142
|
+
* @property {CssData=} cssData for css modules
|
136
143
|
*/
|
137
144
|
|
138
145
|
/** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */
|
@@ -10,10 +10,11 @@ const { DEFAULTS } = require("./config/defaults");
|
|
10
10
|
const createHash = require("./util/createHash");
|
11
11
|
const memoize = require("./util/memoize");
|
12
12
|
|
13
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
|
14
|
+
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
13
15
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
14
16
|
/** @typedef {import("./Module")} Module */
|
15
17
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
16
|
-
/** @typedef {typeof import("./util/Hash")} Hash */
|
17
18
|
|
18
19
|
/** @typedef {string | RegExp | (string | RegExp)[]} Matcher */
|
19
20
|
/** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
@@ -76,7 +77,7 @@ const getBefore = (strFn, token) => () => {
|
|
76
77
|
/**
|
77
78
|
* Returns a function that returns a hash of the string
|
78
79
|
* @param {ReturnStringCallback} strFn the function to get the string
|
79
|
-
* @param {
|
80
|
+
* @param {HashFunction=} hashFunction the hash function to use
|
80
81
|
* @returns {ReturnStringCallback} a function that returns the hash of the string
|
81
82
|
*/
|
82
83
|
const getHash =
|
@@ -117,10 +118,13 @@ const lazyObject = obj => {
|
|
117
118
|
|
118
119
|
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
|
119
120
|
|
121
|
+
/** @typedef {((context: TODO) => string)} ModuleFilenameTemplateFunction */
|
122
|
+
/** @typedef {string | ModuleFilenameTemplateFunction} ModuleFilenameTemplate */
|
123
|
+
|
120
124
|
/**
|
121
125
|
* @param {Module | string} module the module
|
122
|
-
* @param {{ namespace?: string, moduleFilenameTemplate?:
|
123
|
-
* @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?:
|
126
|
+
* @param {{ namespace?: string, moduleFilenameTemplate?: ModuleFilenameTemplate }} options options
|
127
|
+
* @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: HashFunction }} contextInfo context info
|
124
128
|
* @returns {string} the filename
|
125
129
|
*/
|
126
130
|
ModuleFilenameHelpers.createFilename = (
|
@@ -149,6 +149,8 @@ const printExportsInfoToSource = (
|
|
149
149
|
/** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */
|
150
150
|
const caches = new WeakMap();
|
151
151
|
|
152
|
+
const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
|
153
|
+
|
152
154
|
class ModuleInfoHeaderPlugin {
|
153
155
|
/**
|
154
156
|
* @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
|
@@ -163,11 +165,11 @@ class ModuleInfoHeaderPlugin {
|
|
163
165
|
*/
|
164
166
|
apply(compiler) {
|
165
167
|
const { _verbose: verbose } = this;
|
166
|
-
compiler.hooks.compilation.tap(
|
168
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
167
169
|
const javascriptHooks =
|
168
170
|
JavascriptModulesPlugin.getCompilationHooks(compilation);
|
169
171
|
javascriptHooks.renderModulePackage.tap(
|
170
|
-
|
172
|
+
PLUGIN_NAME,
|
171
173
|
(
|
172
174
|
moduleSource,
|
173
175
|
module,
|
@@ -246,16 +248,13 @@ class ModuleInfoHeaderPlugin {
|
|
246
248
|
return cachedSource;
|
247
249
|
}
|
248
250
|
);
|
249
|
-
javascriptHooks.chunkHash.tap(
|
250
|
-
|
251
|
-
(
|
252
|
-
|
253
|
-
hash.update("1");
|
254
|
-
}
|
255
|
-
);
|
251
|
+
javascriptHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
|
252
|
+
hash.update(PLUGIN_NAME);
|
253
|
+
hash.update("1");
|
254
|
+
});
|
256
255
|
const cssHooks = CssModulesPlugin.getCompilationHooks(compilation);
|
257
256
|
cssHooks.renderModulePackage.tap(
|
258
|
-
|
257
|
+
PLUGIN_NAME,
|
259
258
|
(moduleSource, module, { runtimeTemplate }) => {
|
260
259
|
const { requestShortener } = runtimeTemplate;
|
261
260
|
let cacheEntry;
|
@@ -291,8 +290,8 @@ class ModuleInfoHeaderPlugin {
|
|
291
290
|
return cachedSource;
|
292
291
|
}
|
293
292
|
);
|
294
|
-
cssHooks.chunkHash.tap(
|
295
|
-
hash.update(
|
293
|
+
cssHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
|
294
|
+
hash.update(PLUGIN_NAME);
|
296
295
|
hash.update("1");
|
297
296
|
});
|
298
297
|
});
|
package/lib/MultiCompiler.js
CHANGED
@@ -44,6 +44,8 @@ const ArrayQueue = require("./util/ArrayQueue");
|
|
44
44
|
* @property {number=} parallelism how many Compilers are allows to run at the same time in parallel
|
45
45
|
*/
|
46
46
|
|
47
|
+
const CLASS_NAME = "MultiCompiler";
|
48
|
+
|
47
49
|
module.exports = class MultiCompiler {
|
48
50
|
/**
|
49
51
|
* @param {Compiler[] | Record<string, Compiler>} compilers child compilers
|
@@ -92,7 +94,7 @@ module.exports = class MultiCompiler {
|
|
92
94
|
const compilerIndex = index;
|
93
95
|
let compilerDone = false;
|
94
96
|
// eslint-disable-next-line no-loop-func
|
95
|
-
compiler.hooks.done.tap(
|
97
|
+
compiler.hooks.done.tap(CLASS_NAME, stats => {
|
96
98
|
if (!compilerDone) {
|
97
99
|
compilerDone = true;
|
98
100
|
doneCompilers++;
|
@@ -105,7 +107,7 @@ module.exports = class MultiCompiler {
|
|
105
107
|
}
|
106
108
|
});
|
107
109
|
// eslint-disable-next-line no-loop-func
|
108
|
-
compiler.hooks.invalid.tap(
|
110
|
+
compiler.hooks.invalid.tap(CLASS_NAME, () => {
|
109
111
|
if (compilerDone) {
|
110
112
|
compilerDone = false;
|
111
113
|
doneCompilers--;
|
@@ -122,7 +124,7 @@ module.exports = class MultiCompiler {
|
|
122
124
|
* @param {WebpackError} warning warning
|
123
125
|
*/
|
124
126
|
const addWarning = (compiler, warning) => {
|
125
|
-
compiler.hooks.thisCompilation.tap(
|
127
|
+
compiler.hooks.thisCompilation.tap(CLASS_NAME, compilation => {
|
126
128
|
compilation.warnings.push(warning);
|
127
129
|
});
|
128
130
|
};
|
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
/** @typedef {import("./Compiler")} Compiler */
|
9
9
|
|
10
|
+
const PLUGIN_NAME = "NoEmitOnErrorsPlugin";
|
11
|
+
|
10
12
|
class NoEmitOnErrorsPlugin {
|
11
13
|
/**
|
12
14
|
* Apply the plugin
|
@@ -14,11 +16,11 @@ class NoEmitOnErrorsPlugin {
|
|
14
16
|
* @returns {void}
|
15
17
|
*/
|
16
18
|
apply(compiler) {
|
17
|
-
compiler.hooks.shouldEmit.tap(
|
19
|
+
compiler.hooks.shouldEmit.tap(PLUGIN_NAME, compilation => {
|
18
20
|
if (compilation.getStats().hasErrors()) return false;
|
19
21
|
});
|
20
|
-
compiler.hooks.compilation.tap(
|
21
|
-
compilation.hooks.shouldRecord.tap(
|
22
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
23
|
+
compilation.hooks.shouldRecord.tap(PLUGIN_NAME, () => {
|
22
24
|
if (compilation.getStats().hasErrors()) return false;
|
23
25
|
});
|
24
26
|
});
|