webpack 5.94.0 → 5.96.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 +1 -1
- package/lib/AsyncDependenciesBlock.js +1 -1
- package/lib/BannerPlugin.js +2 -1
- package/lib/Chunk.js +30 -0
- package/lib/ChunkGraph.js +11 -6
- package/lib/ChunkGroup.js +2 -2
- package/lib/CleanPlugin.js +4 -5
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/Compilation.js +71 -48
- package/lib/Compiler.js +7 -5
- package/lib/ConcatenationScope.js +7 -20
- package/lib/ContextModule.js +7 -8
- package/lib/CssModule.js +25 -21
- package/lib/DefinePlugin.js +14 -8
- package/lib/DelegatedModule.js +3 -3
- package/lib/DllModule.js +4 -4
- package/lib/DynamicEntryPlugin.js +29 -22
- package/lib/EnvironmentPlugin.js +3 -2
- package/lib/EvalDevToolModulePlugin.js +5 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -2
- package/lib/ExternalModule.js +118 -99
- package/lib/ExternalModuleFactoryPlugin.js +33 -9
- package/lib/FileSystemInfo.js +12 -8
- package/lib/Generator.js +5 -4
- package/lib/HotModuleReplacementPlugin.js +8 -6
- package/lib/IgnorePlugin.js +19 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/Module.js +9 -8
- package/lib/ModuleSourceTypesConstants.js +100 -0
- package/lib/NormalModule.js +27 -13
- package/lib/NormalModuleFactory.js +38 -22
- package/lib/OptionsApply.js +12 -1
- package/lib/ProgressPlugin.js +50 -10
- package/lib/RawModule.js +3 -4
- package/lib/RuntimeModule.js +3 -4
- package/lib/RuntimePlugin.js +11 -4
- package/lib/RuntimeTemplate.js +13 -42
- package/lib/SourceMapDevToolPlugin.js +10 -7
- package/lib/TemplatedPathPlugin.js +9 -3
- package/lib/Watching.js +2 -2
- package/lib/WebpackOptionsApply.js +42 -21
- package/lib/asset/AssetGenerator.js +347 -194
- package/lib/asset/AssetModulesPlugin.js +2 -1
- package/lib/asset/AssetSourceGenerator.js +82 -27
- package/lib/asset/RawDataUrlModule.js +5 -4
- package/lib/buildChunkGraph.js +79 -62
- package/lib/cache/PackFileCacheStrategy.js +69 -31
- package/lib/cache/ResolverCachePlugin.js +248 -173
- package/lib/config/defaults.js +135 -126
- package/lib/container/ContainerEntryModule.js +3 -4
- package/lib/container/ContainerPlugin.js +8 -0
- package/lib/container/FallbackModule.js +2 -2
- package/lib/container/HoistContainerReferencesPlugin.js +250 -0
- package/lib/container/ModuleFederationPlugin.js +38 -1
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/RemoteRuntimeModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +16 -12
- package/lib/css/CssGenerator.js +22 -16
- package/lib/css/CssLoadingRuntimeModule.js +7 -6
- package/lib/css/CssModulesPlugin.js +122 -77
- package/lib/css/CssParser.js +655 -526
- package/lib/css/walkCssTokens.js +1168 -338
- package/lib/debug/ProfilingPlugin.js +5 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +5 -2
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -6
- package/lib/dependencies/ContextDependency.js +6 -1
- package/lib/dependencies/ContextElementDependency.js +33 -6
- package/lib/dependencies/CssExportDependency.js +3 -3
- package/lib/dependencies/CssLocalIdentifierDependency.js +26 -17
- package/lib/dependencies/CssUrlDependency.js +33 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +39 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +15 -82
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -2
- package/lib/dependencies/ImportParserPlugin.js +9 -7
- package/lib/dependencies/LoaderPlugin.js +19 -0
- package/lib/dependencies/SystemPlugin.js +2 -1
- package/lib/dependencies/URLPlugin.js +7 -1
- package/lib/dependencies/WorkerPlugin.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +4 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +16 -4
- package/lib/hmr/lazyCompilationBackend.js +1 -7
- package/lib/index.js +35 -6
- package/lib/javascript/EnableChunkLoadingPlugin.js +2 -2
- package/lib/javascript/JavascriptGenerator.js +8 -8
- package/lib/javascript/JavascriptModulesPlugin.js +166 -88
- package/lib/javascript/JavascriptParser.js +338 -117
- package/lib/json/JsonGenerator.js +5 -5
- package/lib/library/EnableLibraryPlugin.js +2 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +16 -8
- package/lib/logging/Logger.js +11 -11
- package/lib/logging/createConsoleLogger.js +14 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +3 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +20 -18
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
- package/lib/node/nodeConsole.js +11 -8
- package/lib/optimize/AggressiveSplittingPlugin.js +21 -7
- package/lib/optimize/ConcatenatedModule.js +44 -148
- package/lib/optimize/FlagIncludedChunksPlugin.js +6 -0
- package/lib/optimize/InnerGraphPlugin.js +57 -16
- package/lib/optimize/LimitChunkCountPlugin.js +2 -4
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
- package/lib/optimize/RealContentHashPlugin.js +1 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
- package/lib/rules/RuleSetCompiler.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +2 -2
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +32 -19
- package/lib/serialization/ObjectMiddleware.js +23 -9
- package/lib/serialization/SerializerMiddleware.js +3 -2
- package/lib/serialization/types.js +2 -2
- package/lib/sharing/ConsumeSharedModule.js +2 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
- package/lib/sharing/ProvideSharedModule.js +2 -3
- package/lib/stats/DefaultStatsFactoryPlugin.js +22 -20
- package/lib/stats/StatsFactory.js +12 -12
- package/lib/stats/StatsPrinter.js +7 -7
- package/lib/util/AsyncQueue.js +17 -1
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazySet.js +12 -0
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/cleverMerge.js +48 -24
- package/lib/util/concatenate.js +227 -0
- package/lib/util/create-schema-validation.js +22 -9
- package/lib/util/deprecation.js +86 -28
- package/lib/util/fs.js +10 -10
- package/lib/util/hash/wasm-hash.js +12 -1
- package/lib/util/magicComment.js +21 -0
- package/lib/util/makeSerializable.js +24 -1
- package/lib/util/memoize.js +2 -1
- package/lib/util/runtime.js +10 -1
- package/lib/util/semver.js +130 -23
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +5 -5
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -5
- package/lib/wasm-sync/WebAssemblyGenerator.js +8 -9
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -5
- package/lib/web/FetchCompileAsyncWasmPlugin.js +1 -2
- package/lib/web/FetchCompileWasmPlugin.js +1 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +6 -6
- package/package.json +19 -20
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +12 -2
- package/types.d.ts +817 -269
- package/lib/util/mergeScope.js +0 -76
@@ -5,31 +5,18 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
DEFAULT_EXPORT,
|
10
|
+
NAMESPACE_OBJECT_EXPORT
|
11
|
+
} = require("./util/concatenate");
|
12
|
+
|
8
13
|
/** @typedef {import("./Module")} Module */
|
14
|
+
/** @typedef {import("./optimize/ConcatenatedModule").ConcatenatedModuleInfo} ConcatenatedModuleInfo */
|
15
|
+
/** @typedef {import("./optimize/ConcatenatedModule").ModuleInfo} ModuleInfo */
|
9
16
|
|
10
17
|
const MODULE_REFERENCE_REGEXP =
|
11
18
|
/^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_directImport)?(?:_asiSafe(\d))?__$/;
|
12
19
|
|
13
|
-
const DEFAULT_EXPORT = "__WEBPACK_DEFAULT_EXPORT__";
|
14
|
-
const NAMESPACE_OBJECT_EXPORT = "__WEBPACK_NAMESPACE_OBJECT__";
|
15
|
-
|
16
|
-
/**
|
17
|
-
* @typedef {object} ExternalModuleInfo
|
18
|
-
* @property {number} index
|
19
|
-
* @property {Module} module
|
20
|
-
*/
|
21
|
-
|
22
|
-
/**
|
23
|
-
* @typedef {object} ConcatenatedModuleInfo
|
24
|
-
* @property {number} index
|
25
|
-
* @property {Module} module
|
26
|
-
* @property {Map<string, string>} exportMap mapping from export name to symbol
|
27
|
-
* @property {Map<string, string>} rawExportMap mapping from export name to symbol
|
28
|
-
* @property {string=} namespaceExportSymbol
|
29
|
-
*/
|
30
|
-
|
31
|
-
/** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo} ModuleInfo */
|
32
|
-
|
33
20
|
/**
|
34
21
|
* @typedef {object} ModuleReferenceOptions
|
35
22
|
* @property {string[]} ids the properties/exports of the module
|
package/lib/ContextModule.js
CHANGED
@@ -9,6 +9,7 @@ const { OriginalSource, RawSource } = require("webpack-sources");
|
|
9
9
|
const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
|
10
10
|
const { makeWebpackError } = require("./HookWebpackError");
|
11
11
|
const Module = require("./Module");
|
12
|
+
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
|
12
13
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
13
14
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
14
15
|
const Template = require("./Template");
|
@@ -37,13 +38,13 @@ const makeSerializable = require("./util/makeSerializable");
|
|
37
38
|
/** @typedef {import("./Compilation")} Compilation */
|
38
39
|
/** @typedef {import("./Dependency")} Dependency */
|
39
40
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
41
|
+
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
40
42
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
41
43
|
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
42
44
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
43
45
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
44
46
|
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
45
47
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
46
|
-
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
47
48
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
48
49
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
49
50
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
@@ -62,11 +63,11 @@ const makeSerializable = require("./util/makeSerializable");
|
|
62
63
|
* @property {ContextMode} mode
|
63
64
|
* @property {boolean} recursive
|
64
65
|
* @property {RegExp} regExp
|
65
|
-
* @property {"strict"|boolean=} namespaceObject
|
66
|
+
* @property {("strict" | boolean)=} namespaceObject
|
66
67
|
* @property {string=} addon
|
67
|
-
* @property {string=} chunkName
|
68
|
-
* @property {RegExp=} include
|
69
|
-
* @property {RegExp=} exclude
|
68
|
+
* @property {(string | null)=} chunkName
|
69
|
+
* @property {(RegExp | null)=} include
|
70
|
+
* @property {(RegExp | null)=} exclude
|
70
71
|
* @property {RawChunkGroupOptions=} groupOptions
|
71
72
|
* @property {string=} typePrefix
|
72
73
|
* @property {string=} category
|
@@ -104,8 +105,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
104
105
|
|
105
106
|
const SNAPSHOT_OPTIONS = { timestamp: true };
|
106
107
|
|
107
|
-
const TYPES = new Set(["javascript"]);
|
108
|
-
|
109
108
|
class ContextModule extends Module {
|
110
109
|
/**
|
111
110
|
* @param {ResolveDependencies} resolveDependencies function to get dependencies in this context
|
@@ -160,7 +159,7 @@ class ContextModule extends Module {
|
|
160
159
|
* @returns {SourceTypes} types available (do not mutate)
|
161
160
|
*/
|
162
161
|
getSourceTypes() {
|
163
|
-
return
|
162
|
+
return JS_TYPES;
|
164
163
|
}
|
165
164
|
|
166
165
|
/**
|
package/lib/CssModule.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Alexander
|
3
|
+
Author Alexander Akait @alexander-akait
|
4
4
|
*/
|
5
5
|
|
6
6
|
"use strict";
|
@@ -14,13 +14,13 @@ const makeSerializable = require("./util/makeSerializable");
|
|
14
14
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
15
15
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
16
|
|
17
|
-
/** @typedef {string|undefined} CssLayer */
|
18
|
-
/** @typedef {string|undefined} Supports */
|
19
|
-
/** @typedef {string|undefined} Media */
|
20
|
-
/** @typedef {[CssLayer
|
17
|
+
/** @typedef {string | undefined} CssLayer */
|
18
|
+
/** @typedef {string | undefined} Supports */
|
19
|
+
/** @typedef {string | undefined} Media */
|
20
|
+
/** @typedef {[CssLayer, Supports, Media]} InheritanceItem */
|
21
21
|
/** @typedef {Array<InheritanceItem>} Inheritance */
|
22
22
|
|
23
|
-
/** @typedef {NormalModuleCreateData & { cssLayer: CssLayer
|
23
|
+
/** @typedef {NormalModuleCreateData & { cssLayer: CssLayer, supports: Supports, media: Media, inheritance: Inheritance }} CSSModuleCreateData */
|
24
24
|
|
25
25
|
class CssModule extends NormalModule {
|
26
26
|
/**
|
@@ -127,30 +127,34 @@ class CssModule extends NormalModule {
|
|
127
127
|
static deserialize(context) {
|
128
128
|
const obj = new CssModule({
|
129
129
|
// will be deserialized by Module
|
130
|
-
layer: null,
|
130
|
+
layer: /** @type {EXPECTED_ANY} */ (null),
|
131
131
|
type: "",
|
132
132
|
// will be filled by updateCacheModule
|
133
133
|
resource: "",
|
134
134
|
context: "",
|
135
|
-
request: null,
|
136
|
-
userRequest: null,
|
137
|
-
rawRequest: null,
|
138
|
-
loaders: null,
|
139
|
-
matchResource: null,
|
140
|
-
parser: null,
|
141
|
-
parserOptions: null,
|
142
|
-
generator: null,
|
143
|
-
generatorOptions: null,
|
144
|
-
resolveOptions: null,
|
145
|
-
cssLayer: null,
|
146
|
-
supports: null,
|
147
|
-
media: null,
|
148
|
-
inheritance: null
|
135
|
+
request: /** @type {EXPECTED_ANY} */ (null),
|
136
|
+
userRequest: /** @type {EXPECTED_ANY} */ (null),
|
137
|
+
rawRequest: /** @type {EXPECTED_ANY} */ (null),
|
138
|
+
loaders: /** @type {EXPECTED_ANY} */ (null),
|
139
|
+
matchResource: /** @type {EXPECTED_ANY} */ (null),
|
140
|
+
parser: /** @type {EXPECTED_ANY} */ (null),
|
141
|
+
parserOptions: /** @type {EXPECTED_ANY} */ (null),
|
142
|
+
generator: /** @type {EXPECTED_ANY} */ (null),
|
143
|
+
generatorOptions: /** @type {EXPECTED_ANY} */ (null),
|
144
|
+
resolveOptions: /** @type {EXPECTED_ANY} */ (null),
|
145
|
+
cssLayer: /** @type {EXPECTED_ANY} */ (null),
|
146
|
+
supports: /** @type {EXPECTED_ANY} */ (null),
|
147
|
+
media: /** @type {EXPECTED_ANY} */ (null),
|
148
|
+
inheritance: /** @type {EXPECTED_ANY} */ (null)
|
149
149
|
});
|
150
150
|
obj.deserialize(context);
|
151
151
|
return obj;
|
152
152
|
}
|
153
153
|
|
154
|
+
/**
|
155
|
+
* @param {ObjectDeserializerContext} context context
|
156
|
+
* @returns {TODO} Module
|
157
|
+
*/
|
154
158
|
deserialize(context) {
|
155
159
|
const { read } = context;
|
156
160
|
this.cssLayer = read();
|
package/lib/DefinePlugin.js
CHANGED
@@ -22,9 +22,9 @@ const {
|
|
22
22
|
const createHash = require("./util/createHash");
|
23
23
|
|
24
24
|
/** @typedef {import("estree").Expression} Expression */
|
25
|
-
/** @typedef {import("./Compilation").ValueCacheVersion} ValueCacheVersion */
|
26
25
|
/** @typedef {import("./Compiler")} Compiler */
|
27
26
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
27
|
+
/** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
|
28
28
|
/** @typedef {import("./NormalModule")} NormalModule */
|
29
29
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
30
30
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
@@ -45,6 +45,7 @@ const createHash = require("./util/createHash");
|
|
45
45
|
* @property {string|function(): string=} version
|
46
46
|
*/
|
47
47
|
|
48
|
+
/** @typedef {string | Set<string>} ValueCacheVersion */
|
48
49
|
/** @typedef {function({ module: NormalModule, key: string, readonly version: ValueCacheVersion }): CodeValuePrimitive} GeneratorFn */
|
49
50
|
|
50
51
|
class RuntimeValue {
|
@@ -68,7 +69,7 @@ class RuntimeValue {
|
|
68
69
|
|
69
70
|
/**
|
70
71
|
* @param {JavascriptParser} parser the parser
|
71
|
-
* @param {
|
72
|
+
* @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
|
72
73
|
* @param {string} key the defined key
|
73
74
|
* @returns {CodeValuePrimitive} code
|
74
75
|
*/
|
@@ -107,7 +108,9 @@ class RuntimeValue {
|
|
107
108
|
module: parser.state.module,
|
108
109
|
key,
|
109
110
|
get version() {
|
110
|
-
return
|
111
|
+
return /** @type {ValueCacheVersion} */ (
|
112
|
+
valueCacheVersions.get(VALUE_DEP_PREFIX + key)
|
113
|
+
);
|
111
114
|
}
|
112
115
|
});
|
113
116
|
}
|
@@ -136,7 +139,7 @@ function getObjKeys(properties) {
|
|
136
139
|
/**
|
137
140
|
* @param {any[]|{[k: string]: any}} obj obj
|
138
141
|
* @param {JavascriptParser} parser Parser
|
139
|
-
* @param {
|
142
|
+
* @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
|
140
143
|
* @param {string} key the defined key
|
141
144
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
142
145
|
* @param {Logger} logger the logger object
|
@@ -209,7 +212,7 @@ const stringifyObj = (
|
|
209
212
|
* Convert code to a string that evaluates
|
210
213
|
* @param {CodeValue} code Code to evaluate
|
211
214
|
* @param {JavascriptParser} parser Parser
|
212
|
-
* @param {
|
215
|
+
* @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
|
213
216
|
* @param {string} key the defined key
|
214
217
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
215
218
|
* @param {Logger} logger the logger object
|
@@ -377,7 +380,9 @@ class DefinePlugin {
|
|
377
380
|
* @returns {void}
|
378
381
|
*/
|
379
382
|
const handler = parser => {
|
380
|
-
const mainValue =
|
383
|
+
const mainValue =
|
384
|
+
/** @type {ValueCacheVersion} */
|
385
|
+
(compilation.valueCacheVersions.get(VALUE_DEP_MAIN));
|
381
386
|
parser.hooks.program.tap(PLUGIN_NAME, () => {
|
382
387
|
const buildInfo = /** @type {BuildInfo} */ (
|
383
388
|
parser.state.module.buildInfo
|
@@ -397,7 +402,8 @@ class DefinePlugin {
|
|
397
402
|
/** @type {NonNullable<BuildInfo["valueDependencies"]>} */
|
398
403
|
(buildInfo.valueDependencies).set(
|
399
404
|
VALUE_DEP_PREFIX + key,
|
400
|
-
|
405
|
+
/** @type {ValueCacheVersion} */
|
406
|
+
(compilation.valueCacheVersions.get(VALUE_DEP_PREFIX + key))
|
401
407
|
);
|
402
408
|
};
|
403
409
|
|
@@ -666,7 +672,7 @@ class DefinePlugin {
|
|
666
672
|
const walkDefinitionsForValues = (definitions, prefix) => {
|
667
673
|
for (const key of Object.keys(definitions)) {
|
668
674
|
const code = definitions[key];
|
669
|
-
const version = toCacheVersion(code);
|
675
|
+
const version = /** @type {string} */ (toCacheVersion(code));
|
670
676
|
const name = VALUE_DEP_PREFIX + prefix + key;
|
671
677
|
mainHash.update(`|${prefix}${key}`);
|
672
678
|
const oldVersion = compilation.valueCacheVersions.get(name);
|
package/lib/DelegatedModule.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
9
9
|
const Module = require("./Module");
|
10
|
+
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
|
10
11
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
11
12
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
12
13
|
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
@@ -19,13 +20,13 @@ const makeSerializable = require("./util/makeSerializable");
|
|
19
20
|
/** @typedef {import("./Compilation")} Compilation */
|
20
21
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
21
22
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
23
|
+
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
22
24
|
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
|
23
25
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
24
26
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
25
27
|
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
26
28
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
27
29
|
/** @typedef {import("./Module").SourceContext} SourceContext */
|
28
|
-
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
29
30
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
30
31
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
31
32
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
@@ -40,7 +41,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
40
41
|
/** @typedef {"require" | "object"} Type */
|
41
42
|
/** @typedef {TODO} Data */
|
42
43
|
|
43
|
-
const TYPES = new Set(["javascript"]);
|
44
44
|
const RUNTIME_REQUIREMENTS = new Set([
|
45
45
|
RuntimeGlobals.module,
|
46
46
|
RuntimeGlobals.require
|
@@ -74,7 +74,7 @@ class DelegatedModule extends Module {
|
|
74
74
|
* @returns {SourceTypes} types available (do not mutate)
|
75
75
|
*/
|
76
76
|
getSourceTypes() {
|
77
|
-
return
|
77
|
+
return JS_TYPES;
|
78
78
|
}
|
79
79
|
|
80
80
|
/**
|
package/lib/DllModule.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { RawSource } = require("webpack-sources");
|
9
9
|
const Module = require("./Module");
|
10
|
+
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
|
10
11
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
11
12
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
12
13
|
const makeSerializable = require("./util/makeSerializable");
|
@@ -18,11 +19,11 @@ const makeSerializable = require("./util/makeSerializable");
|
|
18
19
|
/** @typedef {import("./Dependency")} Dependency */
|
19
20
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
20
21
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
22
|
+
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
21
23
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
22
24
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
23
25
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
24
26
|
/** @typedef {import("./Module").SourceContext} SourceContext */
|
25
|
-
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
26
27
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
27
28
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
28
29
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
@@ -32,7 +33,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
32
33
|
/** @typedef {import("./util/Hash")} Hash */
|
33
34
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
34
35
|
|
35
|
-
const TYPES = new Set(["javascript"]);
|
36
36
|
const RUNTIME_REQUIREMENTS = new Set([
|
37
37
|
RuntimeGlobals.require,
|
38
38
|
RuntimeGlobals.module
|
@@ -57,7 +57,7 @@ class DllModule extends Module {
|
|
57
57
|
* @returns {SourceTypes} types available (do not mutate)
|
58
58
|
*/
|
59
59
|
getSourceTypes() {
|
60
|
-
return
|
60
|
+
return JS_TYPES;
|
61
61
|
}
|
62
62
|
|
63
63
|
/**
|
@@ -165,7 +165,7 @@ class DllModule extends Module {
|
|
165
165
|
*/
|
166
166
|
cleanupForCache() {
|
167
167
|
super.cleanupForCache();
|
168
|
-
this.dependencies = undefined;
|
168
|
+
this.dependencies = /** @type {EXPECTED_ANY} */ (undefined);
|
169
169
|
}
|
170
170
|
}
|
171
171
|
|
@@ -9,6 +9,7 @@ const EntryOptionPlugin = require("./EntryOptionPlugin");
|
|
9
9
|
const EntryPlugin = require("./EntryPlugin");
|
10
10
|
const EntryDependency = require("./dependencies/EntryDependency");
|
11
11
|
|
12
|
+
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */
|
12
13
|
/** @typedef {import("../declarations/WebpackOptions").EntryDynamicNormalized} EntryDynamic */
|
13
14
|
/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */
|
14
15
|
/** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */
|
@@ -40,22 +41,27 @@ class DynamicEntryPlugin {
|
|
40
41
|
}
|
41
42
|
);
|
42
43
|
|
43
|
-
compiler.hooks.make.tapPromise(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
.
|
48
|
-
const
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
compiler.hooks.make.tapPromise("DynamicEntryPlugin", compilation =>
|
45
|
+
Promise.resolve(this.entry())
|
46
|
+
.then(entry => {
|
47
|
+
const promises = [];
|
48
|
+
for (const name of Object.keys(entry)) {
|
49
|
+
const desc = entry[name];
|
50
|
+
const options = EntryOptionPlugin.entryDescriptionToOptions(
|
51
|
+
compiler,
|
52
|
+
name,
|
53
|
+
desc
|
54
|
+
);
|
55
|
+
for (const entry of /** @type {NonNullable<EntryDescriptionNormalized["import"]>} */ (
|
56
|
+
desc.import
|
57
|
+
)) {
|
58
|
+
promises.push(
|
59
|
+
new Promise(
|
60
|
+
/**
|
61
|
+
* @param {(value?: any) => void} resolve resolve
|
62
|
+
* @param {(reason?: Error) => void} reject reject
|
63
|
+
*/
|
64
|
+
(resolve, reject) => {
|
59
65
|
compilation.addEntry(
|
60
66
|
this.context,
|
61
67
|
EntryPlugin.createDependency(entry, options),
|
@@ -65,13 +71,14 @@ class DynamicEntryPlugin {
|
|
65
71
|
resolve();
|
66
72
|
}
|
67
73
|
);
|
68
|
-
}
|
69
|
-
)
|
70
|
-
|
74
|
+
}
|
75
|
+
)
|
76
|
+
);
|
71
77
|
}
|
72
|
-
|
73
|
-
|
74
|
-
|
78
|
+
}
|
79
|
+
return Promise.all(promises);
|
80
|
+
})
|
81
|
+
.then(x => {})
|
75
82
|
);
|
76
83
|
}
|
77
84
|
}
|
package/lib/EnvironmentPlugin.js
CHANGED
@@ -13,15 +13,16 @@ const WebpackError = require("./WebpackError");
|
|
13
13
|
|
14
14
|
class EnvironmentPlugin {
|
15
15
|
/**
|
16
|
-
* @param {(string | string[] | Record<string,
|
16
|
+
* @param {(string | string[] | Record<string, any>)[]} keys keys
|
17
17
|
*/
|
18
18
|
constructor(...keys) {
|
19
19
|
if (keys.length === 1 && Array.isArray(keys[0])) {
|
20
|
+
/** @type {string[]} */
|
20
21
|
this.keys = keys[0];
|
21
22
|
this.defaultValues = {};
|
22
23
|
} else if (keys.length === 1 && keys[0] && typeof keys[0] === "object") {
|
23
24
|
this.keys = Object.keys(keys[0]);
|
24
|
-
this.defaultValues = /** @type {Record<string,
|
25
|
+
this.defaultValues = /** @type {Record<string, any>} */ (keys[0]);
|
25
26
|
} else {
|
26
27
|
this.keys = /** @type {string[]} */ (keys);
|
27
28
|
this.defaultValues = {};
|
@@ -57,7 +57,7 @@ class EvalDevToolModulePlugin {
|
|
57
57
|
const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
|
58
58
|
hooks.renderModuleContent.tap(
|
59
59
|
"EvalDevToolModulePlugin",
|
60
|
-
(source, module, { runtimeTemplate, chunkGraph }) => {
|
60
|
+
(source, module, { chunk, runtimeTemplate, chunkGraph }) => {
|
61
61
|
const cacheEntry = cache.get(source);
|
62
62
|
if (cacheEntry !== undefined) return cacheEntry;
|
63
63
|
if (module instanceof ExternalModule) {
|
@@ -65,11 +65,14 @@ class EvalDevToolModulePlugin {
|
|
65
65
|
return source;
|
66
66
|
}
|
67
67
|
const content = source.source();
|
68
|
+
const namespace = compilation.getPath(this.namespace, {
|
69
|
+
chunk
|
70
|
+
});
|
68
71
|
const str = ModuleFilenameHelpers.createFilename(
|
69
72
|
module,
|
70
73
|
{
|
71
74
|
moduleFilenameTemplate: this.moduleFilenameTemplate,
|
72
|
-
namespace
|
75
|
+
namespace
|
73
76
|
},
|
74
77
|
{
|
75
78
|
requestShortener: runtimeTemplate.requestShortener,
|
@@ -77,7 +77,7 @@ class EvalSourceMapDevToolPlugin {
|
|
77
77
|
);
|
78
78
|
hooks.renderModuleContent.tap(
|
79
79
|
"EvalSourceMapDevToolPlugin",
|
80
|
-
(source, m, { runtimeTemplate, chunkGraph }) => {
|
80
|
+
(source, m, { chunk, runtimeTemplate, chunkGraph }) => {
|
81
81
|
const cachedSource = cache.get(source);
|
82
82
|
if (cachedSource !== undefined) {
|
83
83
|
return cachedSource;
|
@@ -113,6 +113,9 @@ class EvalSourceMapDevToolPlugin {
|
|
113
113
|
return result(source);
|
114
114
|
}
|
115
115
|
|
116
|
+
const namespace = compilation.getPath(this.namespace, {
|
117
|
+
chunk
|
118
|
+
});
|
116
119
|
/** @type {SourceMap} */
|
117
120
|
let sourceMap;
|
118
121
|
let content;
|
@@ -143,7 +146,7 @@ class EvalSourceMapDevToolPlugin {
|
|
143
146
|
module,
|
144
147
|
{
|
145
148
|
moduleFilenameTemplate: this.moduleFilenameTemplate,
|
146
|
-
namespace
|
149
|
+
namespace
|
147
150
|
},
|
148
151
|
{
|
149
152
|
requestShortener: runtimeTemplate.requestShortener,
|