webpack 5.90.3 → 5.92.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +5 -5
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +14 -6
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -1
- package/lib/Cache.js +8 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +7 -4
- package/lib/ChunkGraph.js +52 -25
- package/lib/ChunkGroup.js +23 -17
- package/lib/CleanPlugin.js +8 -6
- package/lib/Compilation.js +295 -120
- package/lib/Compiler.js +223 -87
- package/lib/ConcatenationScope.js +3 -3
- package/lib/ConditionalInitFragment.js +4 -5
- package/lib/ContextModule.js +95 -41
- package/lib/ContextModuleFactory.js +4 -2
- package/lib/ContextReplacementPlugin.js +3 -2
- package/lib/DefinePlugin.js +18 -6
- package/lib/Dependency.js +12 -10
- package/lib/DependencyTemplate.js +17 -7
- package/lib/DllModule.js +1 -0
- package/lib/DllReferencePlugin.js +7 -3
- package/lib/EntryOptionPlugin.js +4 -1
- package/lib/EntryPlugin.js +6 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +11 -0
- package/lib/ExportsInfo.js +23 -8
- package/lib/ExternalModule.js +160 -35
- package/lib/ExternalModuleFactoryPlugin.js +37 -2
- package/lib/FileSystemInfo.js +69 -42
- package/lib/FlagDependencyExportsPlugin.js +21 -7
- package/lib/Generator.js +4 -4
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +108 -45
- package/lib/IgnorePlugin.js +4 -1
- package/lib/InitFragment.js +5 -3
- package/lib/LibManifestPlugin.js +17 -9
- package/lib/Module.js +41 -14
- package/lib/ModuleFactory.js +3 -3
- package/lib/ModuleFilenameHelpers.js +30 -17
- package/lib/ModuleGraph.js +60 -31
- package/lib/ModuleGraphConnection.js +2 -1
- package/lib/MultiCompiler.js +62 -9
- package/lib/NodeStuffPlugin.js +14 -3
- package/lib/NormalModule.js +13 -13
- package/lib/NormalModuleFactory.js +18 -9
- package/lib/NormalModuleReplacementPlugin.js +5 -1
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/ProgressPlugin.js +1 -1
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +2 -1
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/ResolverFactory.js +6 -4
- package/lib/RuntimeModule.js +4 -4
- package/lib/RuntimePlugin.js +1 -0
- package/lib/RuntimeTemplate.js +124 -52
- package/lib/SourceMapDevToolPlugin.js +4 -1
- package/lib/Stats.js +11 -4
- package/lib/Template.js +5 -5
- package/lib/TemplatedPathPlugin.js +48 -7
- package/lib/Watching.js +67 -60
- package/lib/WebpackError.js +6 -6
- package/lib/WebpackOptionsApply.js +18 -5
- package/lib/asset/AssetGenerator.js +15 -0
- package/lib/asset/RawDataUrlModule.js +3 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
- package/lib/buildChunkGraph.js +120 -67
- package/lib/cache/IdleFileCachePlugin.js +8 -3
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +51 -18
- package/lib/cache/ResolverCachePlugin.js +22 -14
- package/lib/cache/getLazyHashedEtag.js +2 -2
- package/lib/cli.js +5 -5
- package/lib/config/browserslistTargetHandler.js +7 -1
- package/lib/config/defaults.js +108 -34
- package/lib/config/normalization.js +3 -1
- package/lib/config/target.js +18 -11
- package/lib/container/ContainerEntryDependency.js +2 -1
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerPlugin.js +14 -10
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +12 -3
- package/lib/css/CssExportsGenerator.js +68 -25
- package/lib/css/CssGenerator.js +34 -6
- package/lib/css/CssLoadingRuntimeModule.js +217 -98
- package/lib/css/CssModulesPlugin.js +238 -107
- package/lib/css/CssParser.js +24 -15
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +28 -3
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
- package/lib/dependencies/CommonJsExportsDependency.js +13 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
- package/lib/dependencies/ContextDependencyHelpers.js +49 -29
- package/lib/dependencies/ContextElementDependency.js +8 -1
- package/lib/dependencies/CssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
- package/lib/dependencies/CssUrlDependency.js +10 -7
- package/lib/dependencies/ExportsInfoDependency.js +5 -4
- package/lib/dependencies/ExternalModuleDependency.js +4 -2
- package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
- package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
- package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
- package/lib/dependencies/HarmonyImportDependency.js +28 -12
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
- package/lib/dependencies/ImportDependency.js +9 -2
- package/lib/dependencies/ImportEagerDependency.js +4 -2
- package/lib/dependencies/ImportMetaContextDependency.js +7 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
- package/lib/dependencies/ImportMetaPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +15 -5
- package/lib/dependencies/ImportWeakDependency.js +4 -2
- package/lib/dependencies/LoaderDependency.js +2 -1
- package/lib/dependencies/LoaderImportDependency.js +2 -1
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/ModuleDependency.js +4 -5
- package/lib/dependencies/PureExpressionDependency.js +64 -47
- package/lib/dependencies/RequireContextPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
- package/lib/dependencies/RequireEnsureDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +7 -4
- package/lib/dependencies/WorkerDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -1
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +6 -6
- package/lib/ids/NamedChunkIdsPlugin.js +1 -1
- package/lib/ids/NamedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/index.js +11 -0
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +0 -1
- package/lib/javascript/JavascriptModulesPlugin.js +174 -17
- package/lib/javascript/JavascriptParser.js +204 -71
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/javascript/StartupHelpers.js +22 -5
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +3 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +2 -2
- package/lib/library/SystemLibraryPlugin.js +2 -2
- package/lib/library/UmdLibraryPlugin.js +33 -12
- package/lib/logging/Logger.js +27 -2
- package/lib/logging/createConsoleLogger.js +13 -9
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeEnvironmentPlugin.js +14 -8
- package/lib/node/NodeTemplatePlugin.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +37 -26
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/nodeConsole.js +24 -1
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +140 -121
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/InnerGraph.js +8 -3
- package/lib/optimize/InnerGraphPlugin.js +36 -13
- package/lib/optimize/LimitChunkCountPlugin.js +1 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
- package/lib/optimize/RealContentHashPlugin.js +3 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/RuntimeChunkPlugin.js +6 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
- package/lib/optimize/SplitChunksPlugin.js +10 -10
- package/lib/performance/SizeLimitsPlugin.js +13 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
- package/lib/rules/RuleSetCompiler.js +9 -7
- package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +4 -4
- package/lib/serialization/FileMiddleware.js +4 -3
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
- package/lib/serialization/ObjectMiddleware.js +8 -5
- package/lib/serialization/PlainObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +19 -0
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +17 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
- package/lib/sharing/ProvideSharedPlugin.js +13 -6
- package/lib/sharing/resolveMatchedConfigs.js +3 -3
- package/lib/sharing/utils.js +13 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/stats/StatsPrinter.js +6 -6
- package/lib/util/ArrayQueue.js +14 -21
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Queue.js +8 -2
- package/lib/util/SortableSet.js +16 -4
- package/lib/util/StackedCacheMap.js +26 -0
- package/lib/util/TupleQueue.js +8 -2
- package/lib/util/WeakTupleMap.js +57 -13
- package/lib/util/binarySearchBounds.js +1 -1
- package/lib/util/cleverMerge.js +26 -13
- package/lib/util/comparators.js +37 -15
- package/lib/util/conventions.js +129 -0
- package/lib/util/createHash.js +3 -5
- package/lib/util/deprecation.js +3 -3
- package/lib/util/deterministicGrouping.js +2 -2
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +383 -69
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +5 -5
- package/lib/util/mergeScope.js +79 -0
- package/lib/util/runtime.js +2 -17
- package/lib/util/semver.js +3 -0
- package/lib/util/smartGrouping.js +3 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyParser.js +7 -4
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
- package/lib/webpack.js +19 -6
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
- package/package.json +40 -39
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +97 -8
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +5 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/types.d.ts +1826 -639
@@ -56,7 +56,7 @@ const {
|
|
56
56
|
/** @typedef {Partial<NormalModuleCreateData & {settings: ModuleSettings}>} CreateData */
|
57
57
|
|
58
58
|
/**
|
59
|
-
* @typedef {
|
59
|
+
* @typedef {object} ResolveData
|
60
60
|
* @property {ModuleFactoryCreateData["contextInfo"]} contextInfo
|
61
61
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
62
62
|
* @property {string} context
|
@@ -72,7 +72,7 @@ const {
|
|
72
72
|
*/
|
73
73
|
|
74
74
|
/**
|
75
|
-
* @typedef {
|
75
|
+
* @typedef {object} ResourceData
|
76
76
|
* @property {string} resource
|
77
77
|
* @property {string=} path
|
78
78
|
* @property {string=} query
|
@@ -83,7 +83,7 @@ const {
|
|
83
83
|
/** @typedef {ResourceData & { data: Record<string, any> }} ResourceDataWithData */
|
84
84
|
|
85
85
|
/**
|
86
|
-
* @typedef {
|
86
|
+
* @typedef {object} ParsedLoaderRequest
|
87
87
|
* @property {string} loader loader
|
88
88
|
* @property {string|undefined} options options
|
89
89
|
*/
|
@@ -227,7 +227,16 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
227
227
|
new BasicMatcherRulePlugin("issuer"),
|
228
228
|
new BasicMatcherRulePlugin("compiler"),
|
229
229
|
new BasicMatcherRulePlugin("issuerLayer"),
|
230
|
-
new ObjectMatcherRulePlugin(
|
230
|
+
new ObjectMatcherRulePlugin(
|
231
|
+
"assert",
|
232
|
+
"assertions",
|
233
|
+
value => value && /** @type {any} */ (value)._isLegacyAssert !== undefined
|
234
|
+
),
|
235
|
+
new ObjectMatcherRulePlugin(
|
236
|
+
"with",
|
237
|
+
"assertions",
|
238
|
+
value => value && !(/** @type {any} */ (value)._isLegacyAssert)
|
239
|
+
),
|
231
240
|
new ObjectMatcherRulePlugin("descriptionData"),
|
232
241
|
new BasicEffectRulePlugin("type"),
|
233
242
|
new BasicEffectRulePlugin("sideEffects"),
|
@@ -240,12 +249,12 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
240
249
|
|
241
250
|
class NormalModuleFactory extends ModuleFactory {
|
242
251
|
/**
|
243
|
-
* @param {
|
252
|
+
* @param {object} param params
|
244
253
|
* @param {string=} param.context context
|
245
254
|
* @param {InputFileSystem} param.fs file system
|
246
255
|
* @param {ResolverFactory} param.resolverFactory resolverFactory
|
247
256
|
* @param {ModuleOptions} param.options options
|
248
|
-
* @param {
|
257
|
+
* @param {object=} param.associatedObjectForCache an object to which the cache will be attached
|
249
258
|
* @param {boolean=} param.layers enable layers
|
250
259
|
*/
|
251
260
|
constructor({
|
@@ -268,7 +277,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
268
277
|
resolveInScheme: new HookMap(
|
269
278
|
() => new AsyncSeriesBailHook(["resourceData", "resolveData"])
|
270
279
|
),
|
271
|
-
/** @type {AsyncSeriesBailHook<[ResolveData], Module>} */
|
280
|
+
/** @type {AsyncSeriesBailHook<[ResolveData], Module | undefined>} */
|
272
281
|
factorize: new AsyncSeriesBailHook(["resolveData"]),
|
273
282
|
/** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
274
283
|
beforeResolve: new AsyncSeriesBailHook(["resolveData"]),
|
@@ -308,9 +317,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
308
317
|
this.fs = fs;
|
309
318
|
this._globalParserOptions = options.parser;
|
310
319
|
this._globalGeneratorOptions = options.generator;
|
311
|
-
/** @type {Map<string, WeakMap<
|
320
|
+
/** @type {Map<string, WeakMap<object, Parser>>} */
|
312
321
|
this.parserCache = new Map();
|
313
|
-
/** @type {Map<string, WeakMap<
|
322
|
+
/** @type {Map<string, WeakMap<object, Generator>>} */
|
314
323
|
this.generatorCache = new Map();
|
315
324
|
/** @type {Set<Module>} */
|
316
325
|
this._restoredUnsafeCacheEntries = new Set();
|
@@ -8,6 +8,8 @@
|
|
8
8
|
const { join, dirname } = require("./util/fs");
|
9
9
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
|
+
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
12
|
+
|
11
13
|
/** @typedef {function(import("./NormalModuleFactory").ResolveData): void} ModuleReplacer */
|
12
14
|
|
13
15
|
class NormalModuleReplacementPlugin {
|
@@ -49,7 +51,9 @@ class NormalModuleReplacementPlugin {
|
|
49
51
|
if (typeof newResource === "function") {
|
50
52
|
newResource(result);
|
51
53
|
} else {
|
52
|
-
const fs =
|
54
|
+
const fs =
|
55
|
+
/** @type {InputFileSystem} */
|
56
|
+
(compiler.inputFileSystem);
|
53
57
|
if (
|
54
58
|
newResource.startsWith("/") ||
|
55
59
|
(newResource.length > 1 && newResource[1] === ":")
|
package/lib/Parser.js
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Authors Ivan Kopeykin @vankop
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/** @typedef {import("./Compiler")} Compiler */
|
9
|
+
/** @typedef {import("./config/target").PlatformTargetProperties} PlatformTargetProperties */
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Should be used only for "target === false" or
|
13
|
+
* when you want to overwrite platform target properties
|
14
|
+
*/
|
15
|
+
class PlatformPlugin {
|
16
|
+
/**
|
17
|
+
* @param {Partial<PlatformTargetProperties>} platform target properties
|
18
|
+
*/
|
19
|
+
constructor(platform) {
|
20
|
+
/** @type {Partial<PlatformTargetProperties>} */
|
21
|
+
this.platform = platform;
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Apply the plugin
|
26
|
+
* @param {Compiler} compiler the compiler instance
|
27
|
+
* @returns {void}
|
28
|
+
*/
|
29
|
+
apply(compiler) {
|
30
|
+
compiler.hooks.environment.tap("PlatformPlugin", () => {
|
31
|
+
compiler.platform = {
|
32
|
+
...compiler.platform,
|
33
|
+
...this.platform
|
34
|
+
};
|
35
|
+
});
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
module.exports = PlatformPlugin;
|
package/lib/ProgressPlugin.js
CHANGED
@@ -21,7 +21,7 @@ const { contextify } = require("./util/identifier");
|
|
21
21
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
22
22
|
|
23
23
|
/**
|
24
|
-
* @typedef {
|
24
|
+
* @typedef {object} CountsData
|
25
25
|
* @property {number} modulesCount modules count
|
26
26
|
* @property {number} dependenciesCount dependencies count
|
27
27
|
*/
|
package/lib/ProvidePlugin.js
CHANGED
@@ -59,7 +59,9 @@ class ProvidePlugin {
|
|
59
59
|
*/
|
60
60
|
const handler = (parser, parserOptions) => {
|
61
61
|
Object.keys(definitions).forEach(name => {
|
62
|
-
const request =
|
62
|
+
const request =
|
63
|
+
/** @type {string[]} */
|
64
|
+
([]).concat(definitions[name]);
|
63
65
|
const splittedName = name.split(".");
|
64
66
|
if (splittedName.length > 0) {
|
65
67
|
splittedName.slice(1).forEach((_, i) => {
|
package/lib/RawModule.js
CHANGED
@@ -19,6 +19,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
19
19
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
20
20
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
21
21
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
22
|
+
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
22
23
|
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
23
24
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
24
25
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
@@ -36,7 +37,7 @@ class RawModule extends Module {
|
|
36
37
|
* @param {string} source source code
|
37
38
|
* @param {string} identifier unique identifier
|
38
39
|
* @param {string=} readableIdentifier readable identifier
|
39
|
-
* @param {
|
40
|
+
* @param {ReadOnlyRuntimeRequirements=} runtimeRequirements runtime requirements needed for the source code
|
40
41
|
*/
|
41
42
|
constructor(source, identifier, readableIdentifier, runtimeRequirements) {
|
42
43
|
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
package/lib/RecordIdsPlugin.js
CHANGED
@@ -13,28 +13,28 @@ const identifierUtils = require("./util/identifier");
|
|
13
13
|
/** @typedef {import("./Module")} Module */
|
14
14
|
|
15
15
|
/**
|
16
|
-
* @typedef {
|
16
|
+
* @typedef {object} RecordsChunks
|
17
17
|
* @property {Record<string, number>=} byName
|
18
18
|
* @property {Record<string, number>=} bySource
|
19
19
|
* @property {number[]=} usedIds
|
20
20
|
*/
|
21
21
|
|
22
22
|
/**
|
23
|
-
* @typedef {
|
23
|
+
* @typedef {object} RecordsModules
|
24
24
|
* @property {Record<string, number>=} byIdentifier
|
25
25
|
* @property {Record<string, number>=} bySource
|
26
26
|
* @property {number[]=} usedIds
|
27
27
|
*/
|
28
28
|
|
29
29
|
/**
|
30
|
-
* @typedef {
|
30
|
+
* @typedef {object} Records
|
31
31
|
* @property {RecordsChunks=} chunks
|
32
32
|
* @property {RecordsModules=} modules
|
33
33
|
*/
|
34
34
|
|
35
35
|
class RecordIdsPlugin {
|
36
36
|
/**
|
37
|
-
* @param {
|
37
|
+
* @param {object} options Options object
|
38
38
|
* @param {boolean=} options.portableIds true, when ids need to be portable
|
39
39
|
*/
|
40
40
|
constructor(options) {
|
package/lib/ResolverFactory.js
CHANGED
@@ -22,7 +22,7 @@ const {
|
|
22
22
|
|
23
23
|
/** @typedef {WebpackResolveOptions & {dependencyType?: string, resolveToContext?: boolean }} ResolveOptionsWithDependencyType */
|
24
24
|
/**
|
25
|
-
* @typedef {
|
25
|
+
* @typedef {object} WithOptions
|
26
26
|
* @property {function(Partial<ResolveOptionsWithDependencyType>): ResolverWithOptions} withOptions create a resolver with additional/different options
|
27
27
|
*/
|
28
28
|
|
@@ -61,13 +61,15 @@ const convertToResolveOptions = resolveOptionsWithDepType => {
|
|
61
61
|
);
|
62
62
|
|
63
63
|
return removeOperations(
|
64
|
-
resolveByProperty(options, "byDependency", dependencyType)
|
64
|
+
resolveByProperty(options, "byDependency", dependencyType),
|
65
|
+
// Keep the `unsafeCache` because it can be a `Proxy`
|
66
|
+
["unsafeCache"]
|
65
67
|
);
|
66
68
|
};
|
67
69
|
|
68
70
|
/**
|
69
|
-
* @typedef {
|
70
|
-
* @property {WeakMap<
|
71
|
+
* @typedef {object} ResolverCache
|
72
|
+
* @property {WeakMap<object, ResolverWithOptions>} direct
|
71
73
|
* @property {Map<string, ResolverWithOptions>} stringified
|
72
74
|
*/
|
73
75
|
|
package/lib/RuntimeModule.js
CHANGED
@@ -47,7 +47,7 @@ class RuntimeModule extends Module {
|
|
47
47
|
this.chunkGraph = undefined;
|
48
48
|
this.fullHash = false;
|
49
49
|
this.dependentHash = false;
|
50
|
-
/** @type {string | undefined} */
|
50
|
+
/** @type {string | undefined | null} */
|
51
51
|
this._cachedGeneratedCode = undefined;
|
52
52
|
}
|
53
53
|
|
@@ -113,9 +113,9 @@ class RuntimeModule extends Module {
|
|
113
113
|
if (this.fullHash || this.dependentHash) {
|
114
114
|
// Do not use getGeneratedCode here, because i. e. compilation hash might be not
|
115
115
|
// ready at this point. We will cache it later instead.
|
116
|
-
hash.update(this.generate());
|
116
|
+
hash.update(/** @type {string} */ (this.generate()));
|
117
117
|
} else {
|
118
|
-
hash.update(this.getGeneratedCode());
|
118
|
+
hash.update(/** @type {string} */ (this.getGeneratedCode()));
|
119
119
|
}
|
120
120
|
} catch (err) {
|
121
121
|
hash.update(/** @type {Error} */ (err).message);
|
@@ -179,7 +179,7 @@ class RuntimeModule extends Module {
|
|
179
179
|
*/
|
180
180
|
getGeneratedCode() {
|
181
181
|
if (this._cachedGeneratedCode) {
|
182
|
-
return
|
182
|
+
return this._cachedGeneratedCode;
|
183
183
|
}
|
184
184
|
return (this._cachedGeneratedCode = this.generate());
|
185
185
|
}
|
package/lib/RuntimePlugin.js
CHANGED
@@ -60,6 +60,7 @@ const GLOBALS_ON_REQUIRE = [
|
|
60
60
|
RuntimeGlobals.publicPath,
|
61
61
|
RuntimeGlobals.baseURI,
|
62
62
|
RuntimeGlobals.relativeUrl,
|
63
|
+
// TODO webpack 6 - rename to nonce, because we use it for CSS too
|
63
64
|
RuntimeGlobals.scriptNonce,
|
64
65
|
RuntimeGlobals.uncaughtErrorHandler,
|
65
66
|
RuntimeGlobals.asyncModule,
|