webpack 5.102.1 → 5.104.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 +121 -134
- package/hot/dev-server.js +18 -3
- package/hot/emitter-event-target.js +7 -0
- package/hot/lazy-compilation-node.js +45 -29
- package/hot/lazy-compilation-universal.js +18 -0
- package/hot/lazy-compilation-web.js +15 -5
- package/hot/load-http.js +7 -0
- package/hot/only-dev-server.js +19 -4
- package/lib/APIPlugin.js +6 -0
- package/lib/Chunk.js +1 -1
- package/lib/ChunkGraph.js +9 -7
- package/lib/ChunkGroup.js +8 -5
- package/lib/CleanPlugin.js +6 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +28 -2
- package/lib/Compilation.js +58 -21
- package/lib/Compiler.js +3 -3
- package/lib/ConcatenationScope.js +0 -15
- package/lib/ContextModule.js +6 -3
- package/lib/ContextModuleFactory.js +6 -4
- package/lib/CssModule.js +6 -1
- package/lib/DefinePlugin.js +45 -14
- package/lib/DelegatedModule.js +7 -4
- package/lib/Dependency.js +8 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllModule.js +6 -3
- package/lib/DotenvPlugin.js +462 -0
- package/lib/EnvironmentPlugin.js +19 -16
- package/lib/EvalSourceMapDevToolPlugin.js +16 -0
- package/lib/ExportsInfo.js +6 -2
- package/lib/ExternalModule.js +28 -35
- package/lib/ExternalModuleFactoryPlugin.js +11 -9
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +1 -1
- package/lib/Generator.js +10 -7
- package/lib/HookWebpackError.js +33 -4
- package/lib/HotModuleReplacementPlugin.js +22 -0
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +27 -15
- package/lib/ModuleBuildError.js +1 -1
- package/lib/ModuleError.js +1 -1
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +29 -13
- package/lib/ModuleGraphConnection.js +2 -2
- package/lib/ModuleSourceTypeConstants.js +189 -0
- package/lib/ModuleTypeConstants.js +1 -4
- package/lib/ModuleWarning.js +1 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/NodeStuffPlugin.js +424 -116
- package/lib/NormalModule.js +23 -20
- package/lib/NormalModuleFactory.js +7 -10
- package/lib/Parser.js +1 -1
- package/lib/RawModule.js +7 -4
- package/lib/RuntimeGlobals.js +22 -4
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +27 -6
- package/lib/RuntimeTemplate.js +120 -57
- package/lib/SourceMapDevToolPlugin.js +26 -1
- package/lib/Template.js +17 -6
- package/lib/TemplatedPathPlugin.js +5 -6
- package/lib/WebpackError.js +0 -1
- package/lib/WebpackOptionsApply.js +67 -15
- package/lib/asset/AssetBytesGenerator.js +16 -12
- package/lib/asset/AssetGenerator.js +31 -26
- package/lib/asset/AssetSourceGenerator.js +16 -12
- package/lib/asset/RawDataUrlModule.js +6 -3
- package/lib/buildChunkGraph.js +4 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -5
- package/lib/cli.js +2 -43
- package/lib/config/browserslistTargetHandler.js +24 -0
- package/lib/config/defaults.js +226 -61
- package/lib/config/normalization.js +4 -3
- package/lib/config/target.js +11 -0
- package/lib/container/ContainerEntryModule.js +6 -3
- package/lib/container/FallbackModule.js +6 -3
- package/lib/container/RemoteModule.js +1 -3
- package/lib/css/CssGenerator.js +304 -76
- package/lib/css/CssLoadingRuntimeModule.js +14 -4
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +72 -67
- package/lib/css/CssParser.js +1726 -732
- package/lib/css/walkCssTokens.js +128 -11
- package/lib/dependencies/CachedConstDependency.js +24 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
- package/lib/dependencies/CommonJsPlugin.js +12 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +3 -1
- package/lib/dependencies/CssIcssExportDependency.js +389 -12
- package/lib/dependencies/CssIcssImportDependency.js +114 -51
- package/lib/dependencies/CssIcssSymbolDependency.js +31 -33
- package/lib/dependencies/CssImportDependency.js +17 -6
- package/lib/dependencies/CssUrlDependency.js +3 -2
- package/lib/dependencies/DynamicExports.js +7 -7
- package/lib/dependencies/ExternalModuleDependency.js +7 -4
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -2
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +96 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +35 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -9
- package/lib/dependencies/HarmonyExports.js +4 -4
- package/lib/dependencies/HarmonyImportDependency.js +28 -27
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
- package/lib/dependencies/ImportDependency.js +8 -2
- package/lib/dependencies/ImportEagerDependency.js +6 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaPlugin.js +154 -9
- package/lib/dependencies/ImportParserPlugin.js +21 -23
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportWeakDependency.js +6 -3
- package/lib/dependencies/LocalModulesHelpers.js +3 -3
- package/lib/dependencies/ModuleDependency.js +5 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -4
- package/lib/hmr/HotModuleReplacement.runtime.js +2 -1
- package/lib/hmr/LazyCompilationPlugin.js +5 -3
- package/lib/ids/IdHelpers.js +20 -8
- package/lib/index.js +6 -0
- package/lib/javascript/ChunkHelpers.js +16 -5
- package/lib/javascript/JavascriptGenerator.js +105 -104
- package/lib/javascript/JavascriptModulesPlugin.js +80 -37
- package/lib/javascript/JavascriptParser.js +161 -44
- package/lib/json/JsonGenerator.js +5 -4
- package/lib/json/JsonParser.js +9 -2
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/AmdLibraryPlugin.js +4 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +41 -23
- package/lib/library/SystemLibraryPlugin.js +8 -1
- package/lib/library/UmdLibraryPlugin.js +2 -2
- package/lib/logging/Logger.js +5 -4
- package/lib/logging/createConsoleLogger.js +2 -2
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
- package/lib/optimize/ConcatenatedModule.js +208 -167
- package/lib/optimize/ModuleConcatenationPlugin.js +5 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +60 -46
- package/lib/rules/RuleSetCompiler.js +1 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
- package/lib/schemes/HttpUriPlugin.js +78 -7
- package/lib/serialization/AggregateErrorSerializer.js +1 -2
- package/lib/serialization/ObjectMiddleware.js +0 -2
- package/lib/serialization/SingleItemMiddleware.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +5 -3
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +15 -9
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +8 -5
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/util/StringXor.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +2 -2
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/comparators.js +54 -76
- package/lib/util/compileBooleanMatcher.js +78 -6
- package/lib/util/createHash.js +20 -199
- package/lib/util/deprecation.js +1 -1
- package/lib/util/deterministicGrouping.js +6 -3
- package/lib/util/fs.js +75 -75
- package/lib/util/hash/BatchedHash.js +10 -9
- package/lib/util/hash/BulkUpdateHash.js +138 -0
- package/lib/util/hash/DebugHash.js +75 -0
- package/lib/util/hash/hash-digest.js +216 -0
- package/lib/util/identifier.js +82 -17
- package/lib/util/internalSerializables.js +2 -6
- package/lib/util/runtime.js +3 -3
- package/lib/util/source.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +3 -2
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +11 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +9 -6
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +11 -6
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +6 -2
- package/lib/web/FetchCompileWasmPlugin.js +0 -2
- package/lib/webpack.js +85 -82
- package/module.d.ts +5 -0
- package/package.json +34 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +160 -101
- package/schemas/plugins/{css/CssAutoParserOptions.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- 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/json/JsonModulesPluginParser.check.js +1 -1
- package/types.d.ts +771 -436
- package/lib/ModuleSourceTypesConstants.js +0 -123
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -250
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +0 -112
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
package/lib/NormalModule.js
CHANGED
|
@@ -79,7 +79,8 @@ const memoize = require("./util/memoize");
|
|
|
79
79
|
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
|
|
80
80
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
|
81
81
|
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
|
82
|
-
/** @typedef {import("./
|
|
82
|
+
/** @typedef {import("./Module").SourceType} SourceType */
|
|
83
|
+
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
|
83
84
|
/** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
|
|
84
85
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
85
86
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
@@ -96,7 +97,6 @@ const memoize = require("./util/memoize");
|
|
|
96
97
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
97
98
|
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
98
99
|
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
99
|
-
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule["extractSourceMap"]} ExtractSourceMapOptions */
|
|
100
100
|
/**
|
|
101
101
|
* @template T
|
|
102
102
|
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook
|
|
@@ -255,7 +255,7 @@ makeSerializable(
|
|
|
255
255
|
* @property {Generator} generator the generator used
|
|
256
256
|
* @property {GeneratorOptions=} generatorOptions the options of the generator used
|
|
257
257
|
* @property {ResolveOptions=} resolveOptions options used for resolving requests from this module
|
|
258
|
-
* @property {boolean
|
|
258
|
+
* @property {boolean} extractSourceMap enable/disable extracting source map
|
|
259
259
|
*/
|
|
260
260
|
|
|
261
261
|
/**
|
|
@@ -353,34 +353,36 @@ class NormalModule extends Module {
|
|
|
353
353
|
super(type, context || getContext(resource), layer);
|
|
354
354
|
|
|
355
355
|
// Info from Factory
|
|
356
|
-
/** @type {
|
|
356
|
+
/** @type {NormalModuleCreateData['request']} */
|
|
357
357
|
this.request = request;
|
|
358
|
-
/** @type {
|
|
358
|
+
/** @type {NormalModuleCreateData['userRequest']} */
|
|
359
359
|
this.userRequest = userRequest;
|
|
360
|
-
/** @type {
|
|
360
|
+
/** @type {NormalModuleCreateData['rawRequest']} */
|
|
361
361
|
this.rawRequest = rawRequest;
|
|
362
362
|
/** @type {boolean} */
|
|
363
363
|
this.binary = /^(asset|webassembly)\b/.test(type);
|
|
364
|
-
/** @type {
|
|
364
|
+
/** @type {NormalModuleCreateData['parser'] | undefined} */
|
|
365
365
|
this.parser = parser;
|
|
366
|
-
/** @type {
|
|
366
|
+
/** @type {NormalModuleCreateData['parserOptions']} */
|
|
367
367
|
this.parserOptions = parserOptions;
|
|
368
|
-
/** @type {
|
|
368
|
+
/** @type {NormalModuleCreateData['generator'] | undefined} */
|
|
369
369
|
this.generator = generator;
|
|
370
|
-
/** @type {
|
|
370
|
+
/** @type {NormalModuleCreateData['generatorOptions']} */
|
|
371
371
|
this.generatorOptions = generatorOptions;
|
|
372
|
-
/** @type {
|
|
372
|
+
/** @type {NormalModuleCreateData['resource']} */
|
|
373
373
|
this.resource = resource;
|
|
374
|
+
/** @type {NormalModuleCreateData['resourceResolveData']} */
|
|
374
375
|
this.resourceResolveData = resourceResolveData;
|
|
375
|
-
/** @type {
|
|
376
|
+
/** @type {NormalModuleCreateData['matchResource']} */
|
|
376
377
|
this.matchResource = matchResource;
|
|
377
|
-
/** @type {
|
|
378
|
+
/** @type {NormalModuleCreateData['loaders']} */
|
|
378
379
|
this.loaders = loaders;
|
|
379
380
|
if (resolveOptions !== undefined) {
|
|
380
381
|
// already declared in super class
|
|
382
|
+
/** @type {NormalModuleCreateData['resolveOptions']} */
|
|
381
383
|
this.resolveOptions = resolveOptions;
|
|
382
384
|
}
|
|
383
|
-
/** @type {
|
|
385
|
+
/** @type {NormalModuleCreateData['extractSourceMap']} */
|
|
384
386
|
this.extractSourceMap = extractSourceMap;
|
|
385
387
|
|
|
386
388
|
// Info from Build
|
|
@@ -393,7 +395,7 @@ class NormalModule extends Module {
|
|
|
393
395
|
this._source = null;
|
|
394
396
|
/**
|
|
395
397
|
* @private
|
|
396
|
-
* @type {Map<
|
|
398
|
+
* @type {Map<undefined | SourceType, number> | undefined}
|
|
397
399
|
*/
|
|
398
400
|
this._sourceSizes = undefined;
|
|
399
401
|
/**
|
|
@@ -487,6 +489,7 @@ class NormalModule extends Module {
|
|
|
487
489
|
this.context = m.context;
|
|
488
490
|
this.matchResource = m.matchResource;
|
|
489
491
|
this.loaders = m.loaders;
|
|
492
|
+
this.extractSourceMap = m.extractSourceMap;
|
|
490
493
|
}
|
|
491
494
|
|
|
492
495
|
/**
|
|
@@ -697,7 +700,8 @@ class NormalModule extends Module {
|
|
|
697
700
|
options = parseJson(options);
|
|
698
701
|
} catch (err) {
|
|
699
702
|
throw new Error(
|
|
700
|
-
`Cannot parse string options: ${/** @type {Error} */ (err).message}
|
|
703
|
+
`Cannot parse string options: ${/** @type {Error} */ (err).message}`,
|
|
704
|
+
{ cause: err }
|
|
701
705
|
);
|
|
702
706
|
}
|
|
703
707
|
} else {
|
|
@@ -1305,7 +1309,7 @@ class NormalModule extends Module {
|
|
|
1305
1309
|
/** @type {undefined | Set<string>} */
|
|
1306
1310
|
let nonAbsoluteDependencies;
|
|
1307
1311
|
/**
|
|
1308
|
-
* @param {
|
|
1312
|
+
* @param {FileSystemDependencies} deps deps
|
|
1309
1313
|
*/
|
|
1310
1314
|
const checkDependencies = (deps) => {
|
|
1311
1315
|
for (const dep of deps) {
|
|
@@ -1721,7 +1725,6 @@ class NormalModule extends Module {
|
|
|
1721
1725
|
write(this._lastSuccessfulBuildMeta);
|
|
1722
1726
|
write(this._forceBuild);
|
|
1723
1727
|
write(this._codeGeneratorData);
|
|
1724
|
-
write(this.extractSourceMap);
|
|
1725
1728
|
super.serialize(context);
|
|
1726
1729
|
}
|
|
1727
1730
|
|
|
@@ -1746,7 +1749,8 @@ class NormalModule extends Module {
|
|
|
1746
1749
|
parserOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
1747
1750
|
generator: /** @type {EXPECTED_ANY} */ (null),
|
|
1748
1751
|
generatorOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
1749
|
-
resolveOptions: /** @type {EXPECTED_ANY} */ (null)
|
|
1752
|
+
resolveOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
1753
|
+
extractSourceMap: /** @type {EXPECTED_ANY} */ (null)
|
|
1750
1754
|
});
|
|
1751
1755
|
obj.deserialize(context);
|
|
1752
1756
|
return obj;
|
|
@@ -1762,7 +1766,6 @@ class NormalModule extends Module {
|
|
|
1762
1766
|
this._lastSuccessfulBuildMeta = read();
|
|
1763
1767
|
this._forceBuild = read();
|
|
1764
1768
|
this._codeGeneratorData = read();
|
|
1765
|
-
this.extractSourceMap = read();
|
|
1766
1769
|
super.deserialize(context);
|
|
1767
1770
|
}
|
|
1768
1771
|
}
|
|
@@ -38,6 +38,7 @@ const {
|
|
|
38
38
|
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
39
39
|
/** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
|
40
40
|
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
41
|
+
/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
|
|
41
42
|
/** @typedef {import("./Generator")} Generator */
|
|
42
43
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
|
|
43
44
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
|
@@ -61,7 +62,7 @@ const {
|
|
|
61
62
|
* @typedef {import("./Compiler").Callback<T>} Callback
|
|
62
63
|
*/
|
|
63
64
|
|
|
64
|
-
/** @typedef {Pick<RuleSetRule,
|
|
65
|
+
/** @typedef {Pick<RuleSetRule, "type" | "sideEffects" | "parser" | "generator" | "resolve" | "layer" | "extractSourceMap">} ModuleSettings */
|
|
65
66
|
/** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -74,9 +75,9 @@ const {
|
|
|
74
75
|
* @property {ModuleDependency[]} dependencies
|
|
75
76
|
* @property {string} dependencyType
|
|
76
77
|
* @property {CreateData} createData
|
|
77
|
-
* @property {
|
|
78
|
-
* @property {
|
|
79
|
-
* @property {
|
|
78
|
+
* @property {FileSystemDependencies} fileDependencies
|
|
79
|
+
* @property {FileSystemDependencies} missingDependencies
|
|
80
|
+
* @property {FileSystemDependencies} contextDependencies
|
|
80
81
|
* @property {Module=} ignoredModule
|
|
81
82
|
* @property {boolean} cacheable allow to use the unsafe cache
|
|
82
83
|
*/
|
|
@@ -296,14 +297,10 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
296
297
|
|
|
297
298
|
/** @typedef {import("./css/CssParser")} CssParser */
|
|
298
299
|
/** @typedef {import("../declarations/WebpackOptions").CssParserOptions} CssParserOptions */
|
|
299
|
-
/** @typedef {import("../declarations/WebpackOptions").CssAutoParserOptions} CssAutoParserOptions */
|
|
300
|
-
/** @typedef {import("../declarations/WebpackOptions").CssGlobalParserOptions} CssGlobalParserOptions */
|
|
301
300
|
/** @typedef {import("../declarations/WebpackOptions").CssModuleParserOptions} CssModuleParserOptions */
|
|
302
301
|
/** @typedef {import("./css/CssGenerator")} CssGenerator */
|
|
303
302
|
/** @typedef {import("../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
|
|
304
|
-
/** @typedef {import("../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
|
305
303
|
/** @typedef {import("../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
|
306
|
-
/** @typedef {import("../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
|
307
304
|
|
|
308
305
|
/**
|
|
309
306
|
* @typedef {[
|
|
@@ -319,9 +316,9 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
|
319
316
|
* [WEBASSEMBLY_MODULE_TYPE_ASYNC, AsyncWebAssemblyParser, EmptyParserOptions, Generator, EmptyParserOptions],
|
|
320
317
|
* [WEBASSEMBLY_MODULE_TYPE_SYNC, WebAssemblyParser, EmptyParserOptions, Generator, EmptyParserOptions],
|
|
321
318
|
* [CSS_MODULE_TYPE, CssParser, CssParserOptions, CssGenerator, CssGeneratorOptions],
|
|
322
|
-
* [CSS_MODULE_TYPE_AUTO, CssParser,
|
|
319
|
+
* [CSS_MODULE_TYPE_AUTO, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
323
320
|
* [CSS_MODULE_TYPE_MODULE, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
324
|
-
* [CSS_MODULE_TYPE_GLOBAL, CssParser,
|
|
321
|
+
* [CSS_MODULE_TYPE_GLOBAL, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
|
|
325
322
|
* [string, Parser, ParserOptions, Generator, GeneratorOptions],
|
|
326
323
|
* ]} ParsersAndGeneratorsByTypes
|
|
327
324
|
*/
|
package/lib/Parser.js
CHANGED
package/lib/RawModule.js
CHANGED
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
|
9
9
|
const Module = require("./Module");
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
JAVASCRIPT_TYPE,
|
|
12
|
+
JAVASCRIPT_TYPES
|
|
13
|
+
} = require("./ModuleSourceTypeConstants");
|
|
11
14
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
|
12
15
|
const makeSerializable = require("./util/makeSerializable");
|
|
13
16
|
|
|
@@ -49,7 +52,7 @@ class RawModule extends Module {
|
|
|
49
52
|
* @returns {SourceTypes} types available (do not mutate)
|
|
50
53
|
*/
|
|
51
54
|
getSourceTypes() {
|
|
52
|
-
return
|
|
55
|
+
return JAVASCRIPT_TYPES;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
/**
|
|
@@ -122,11 +125,11 @@ class RawModule extends Module {
|
|
|
122
125
|
const sources = new Map();
|
|
123
126
|
if (this.useSourceMap || this.useSimpleSourceMap) {
|
|
124
127
|
sources.set(
|
|
125
|
-
|
|
128
|
+
JAVASCRIPT_TYPE,
|
|
126
129
|
new OriginalSource(this.sourceStr, this.identifier())
|
|
127
130
|
);
|
|
128
131
|
} else {
|
|
129
|
-
sources.set(
|
|
132
|
+
sources.set(JAVASCRIPT_TYPE, new RawSource(this.sourceStr));
|
|
130
133
|
}
|
|
131
134
|
return { sources, runtimeRequirements: this.runtimeRequirements };
|
|
132
135
|
}
|
package/lib/RuntimeGlobals.js
CHANGED
|
@@ -78,11 +78,29 @@ module.exports.createScript = "__webpack_require__.ts";
|
|
|
78
78
|
*/
|
|
79
79
|
module.exports.createScriptUrl = "__webpack_require__.tu";
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* merge multiple CSS stylesheets (CSSStyleSheet or string) into one CSS text string
|
|
83
|
+
* Arguments: (sheets: Array<CSSStyleSheet | string> | CSSStyleSheet | string) => string
|
|
84
|
+
*/
|
|
85
|
+
module.exports.cssMergeStyleSheets = "__webpack_require__.mcs";
|
|
86
|
+
|
|
81
87
|
/**
|
|
82
88
|
* The current scope when getting a module from a remote
|
|
83
89
|
*/
|
|
84
90
|
module.exports.currentRemoteGetScope = "__webpack_require__.R";
|
|
85
91
|
|
|
92
|
+
/**
|
|
93
|
+
* resolve async transitive dependencies for deferred module
|
|
94
|
+
*/
|
|
95
|
+
module.exports.deferredModuleAsyncTransitiveDependencies =
|
|
96
|
+
"__webpack_require__.zT";
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* the internal symbol for getting the async transitive dependencies for deferred module
|
|
100
|
+
*/
|
|
101
|
+
module.exports.deferredModuleAsyncTransitiveDependenciesSymbol =
|
|
102
|
+
"__webpack_require__.zS";
|
|
103
|
+
|
|
86
104
|
/**
|
|
87
105
|
* the exported property define getters function
|
|
88
106
|
*/
|
|
@@ -258,14 +276,14 @@ module.exports.loadScript = "__webpack_require__.l";
|
|
|
258
276
|
module.exports.makeDeferredNamespaceObject = "__webpack_require__.z";
|
|
259
277
|
|
|
260
278
|
/**
|
|
261
|
-
*
|
|
279
|
+
* define compatibility on export
|
|
262
280
|
*/
|
|
263
|
-
module.exports.
|
|
281
|
+
module.exports.makeNamespaceObject = "__webpack_require__.r";
|
|
264
282
|
|
|
265
283
|
/**
|
|
266
|
-
*
|
|
284
|
+
* make a optimized deferred namespace object
|
|
267
285
|
*/
|
|
268
|
-
module.exports.
|
|
286
|
+
module.exports.makeOptimizedDeferredNamespaceObject = "__webpack_require__.zO";
|
|
269
287
|
|
|
270
288
|
/**
|
|
271
289
|
* the internal module object
|
package/lib/RuntimeModule.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const { RawSource } = require("webpack-sources");
|
|
9
9
|
const OriginalSource = require("webpack-sources").OriginalSource;
|
|
10
10
|
const Module = require("./Module");
|
|
11
|
-
const { RUNTIME_TYPES } = require("./
|
|
11
|
+
const { RUNTIME_TYPES } = require("./ModuleSourceTypeConstants");
|
|
12
12
|
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
|
13
13
|
|
|
14
14
|
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
package/lib/RuntimePlugin.js
CHANGED
|
@@ -24,7 +24,10 @@ const GetTrustedTypesPolicyRuntimeModule = require("./runtime/GetTrustedTypesPol
|
|
|
24
24
|
const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule");
|
|
25
25
|
const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule");
|
|
26
26
|
const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
|
|
27
|
-
const
|
|
27
|
+
const {
|
|
28
|
+
MakeDeferredNamespaceObjectRuntimeModule,
|
|
29
|
+
MakeOptimizedDeferredNamespaceObjectRuntimeModule
|
|
30
|
+
} = require("./runtime/MakeDeferredNamespaceObjectRuntime");
|
|
28
31
|
const MakeNamespaceObjectRuntimeModule = require("./runtime/MakeNamespaceObjectRuntimeModule");
|
|
29
32
|
const NonceRuntimeModule = require("./runtime/NonceRuntimeModule");
|
|
30
33
|
const OnChunksLoadedRuntimeModule = require("./runtime/OnChunksLoadedRuntimeModule");
|
|
@@ -78,6 +81,7 @@ const GLOBALS_ON_REQUIRE = [
|
|
|
78
81
|
RuntimeGlobals.loadScript,
|
|
79
82
|
RuntimeGlobals.systemContext,
|
|
80
83
|
RuntimeGlobals.onChunksLoaded,
|
|
84
|
+
RuntimeGlobals.makeOptimizedDeferredNamespaceObject,
|
|
81
85
|
RuntimeGlobals.makeDeferredNamespaceObject
|
|
82
86
|
];
|
|
83
87
|
|
|
@@ -96,11 +100,11 @@ const TREE_DEPENDENCIES = {
|
|
|
96
100
|
RuntimeGlobals.makeNamespaceObject,
|
|
97
101
|
RuntimeGlobals.require
|
|
98
102
|
],
|
|
103
|
+
[RuntimeGlobals.makeOptimizedDeferredNamespaceObject]: [
|
|
104
|
+
RuntimeGlobals.require
|
|
105
|
+
],
|
|
99
106
|
[RuntimeGlobals.makeDeferredNamespaceObject]: [
|
|
100
|
-
RuntimeGlobals.definePropertyGetters,
|
|
101
|
-
RuntimeGlobals.makeNamespaceObject,
|
|
102
107
|
RuntimeGlobals.createFakeNamespaceObject,
|
|
103
|
-
RuntimeGlobals.hasOwnProperty,
|
|
104
108
|
RuntimeGlobals.require
|
|
105
109
|
],
|
|
106
110
|
[RuntimeGlobals.initializeSharing]: [RuntimeGlobals.shareScopeMap],
|
|
@@ -190,12 +194,23 @@ class RuntimePlugin {
|
|
|
190
194
|
);
|
|
191
195
|
return true;
|
|
192
196
|
});
|
|
197
|
+
compilation.hooks.runtimeRequirementInTree
|
|
198
|
+
.for(RuntimeGlobals.makeOptimizedDeferredNamespaceObject)
|
|
199
|
+
.tap("RuntimePlugin", (chunk, runtimeRequirement) => {
|
|
200
|
+
compilation.addRuntimeModule(
|
|
201
|
+
chunk,
|
|
202
|
+
new MakeOptimizedDeferredNamespaceObjectRuntimeModule(
|
|
203
|
+
runtimeRequirement.has(RuntimeGlobals.asyncModule)
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
return true;
|
|
207
|
+
});
|
|
193
208
|
compilation.hooks.runtimeRequirementInTree
|
|
194
209
|
.for(RuntimeGlobals.makeDeferredNamespaceObject)
|
|
195
210
|
.tap("RuntimePlugin", (chunk, runtimeRequirement) => {
|
|
196
211
|
compilation.addRuntimeModule(
|
|
197
212
|
chunk,
|
|
198
|
-
new
|
|
213
|
+
new MakeDeferredNamespaceObjectRuntimeModule(
|
|
199
214
|
runtimeRequirement.has(RuntimeGlobals.asyncModule)
|
|
200
215
|
)
|
|
201
216
|
);
|
|
@@ -238,7 +253,13 @@ class RuntimePlugin {
|
|
|
238
253
|
|
|
239
254
|
if (publicPath === "auto") {
|
|
240
255
|
const module = new AutoPublicPathRuntimeModule();
|
|
241
|
-
if (
|
|
256
|
+
if (
|
|
257
|
+
scriptType !== "module" &&
|
|
258
|
+
!outputOptions.environment.globalThis
|
|
259
|
+
) {
|
|
260
|
+
set.add(RuntimeGlobals.global);
|
|
261
|
+
}
|
|
262
|
+
|
|
242
263
|
compilation.addRuntimeModule(chunk, module);
|
|
243
264
|
} else {
|
|
244
265
|
const module = new PublicPathRuntimeModule(publicPath);
|