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
package/lib/RuntimePlugin.js
CHANGED
@@ -34,6 +34,7 @@ const RuntimeIdRuntimeModule = require("./runtime/RuntimeIdRuntimeModule");
|
|
34
34
|
const SystemContextRuntimeModule = require("./runtime/SystemContextRuntimeModule");
|
35
35
|
const ShareRuntimeModule = require("./sharing/ShareRuntimeModule");
|
36
36
|
const StringXor = require("./util/StringXor");
|
37
|
+
const memoize = require("./util/memoize");
|
37
38
|
|
38
39
|
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
39
40
|
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */
|
@@ -42,6 +43,11 @@ const StringXor = require("./util/StringXor");
|
|
42
43
|
/** @typedef {import("./Module")} Module */
|
43
44
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
44
45
|
|
46
|
+
const getJavascriptModulesPlugin = memoize(() =>
|
47
|
+
require("./javascript/JavascriptModulesPlugin")
|
48
|
+
);
|
49
|
+
const getCssModulesPlugin = memoize(() => require("./css/CssModulesPlugin"));
|
50
|
+
|
45
51
|
const GLOBALS_ON_REQUIRE = [
|
46
52
|
RuntimeGlobals.chunkName,
|
47
53
|
RuntimeGlobals.runtimeId,
|
@@ -261,7 +267,7 @@ class RuntimePlugin {
|
|
261
267
|
});
|
262
268
|
compilation.hooks.runtimeRequirementInTree
|
263
269
|
.for(RuntimeGlobals.getChunkScriptFilename)
|
264
|
-
.tap("RuntimePlugin", (chunk, set) => {
|
270
|
+
.tap("RuntimePlugin", (chunk, set, { chunkGraph }) => {
|
265
271
|
if (
|
266
272
|
typeof compilation.outputOptions.chunkFilename === "string" &&
|
267
273
|
/\[(full)?hash(:\d+)?\]/.test(
|
@@ -277,8 +283,8 @@ class RuntimePlugin {
|
|
277
283
|
"javascript",
|
278
284
|
RuntimeGlobals.getChunkScriptFilename,
|
279
285
|
chunk =>
|
280
|
-
|
281
|
-
(
|
286
|
+
getJavascriptModulesPlugin().chunkHasJs(chunk, chunkGraph) &&
|
287
|
+
/** @type {TemplatePath} */ (
|
282
288
|
chunk.filenameTemplate ||
|
283
289
|
(chunk.canBeInitial()
|
284
290
|
? compilation.outputOptions.filename
|
@@ -291,7 +297,7 @@ class RuntimePlugin {
|
|
291
297
|
});
|
292
298
|
compilation.hooks.runtimeRequirementInTree
|
293
299
|
.for(RuntimeGlobals.getChunkCssFilename)
|
294
|
-
.tap("RuntimePlugin", (chunk, set) => {
|
300
|
+
.tap("RuntimePlugin", (chunk, set, { chunkGraph }) => {
|
295
301
|
if (
|
296
302
|
typeof compilation.outputOptions.cssChunkFilename === "string" &&
|
297
303
|
/\[(full)?hash(:\d+)?\]/.test(
|
@@ -307,6 +313,7 @@ class RuntimePlugin {
|
|
307
313
|
"css",
|
308
314
|
RuntimeGlobals.getChunkCssFilename,
|
309
315
|
chunk =>
|
316
|
+
getCssModulesPlugin().chunkHasCss(chunk, chunkGraph) &&
|
310
317
|
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
311
318
|
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
312
319
|
)
|
package/lib/RuntimeTemplate.js
CHANGED
@@ -86,7 +86,7 @@ class RuntimeTemplate {
|
|
86
86
|
*/
|
87
87
|
constructor(compilation, outputOptions, requestShortener) {
|
88
88
|
this.compilation = compilation;
|
89
|
-
this.outputOptions = outputOptions || {};
|
89
|
+
this.outputOptions = /** @type {OutputOptions} */ (outputOptions || {});
|
90
90
|
this.requestShortener = requestShortener;
|
91
91
|
this.globalObject =
|
92
92
|
/** @type {string} */
|
@@ -106,55 +106,47 @@ class RuntimeTemplate {
|
|
106
106
|
}
|
107
107
|
|
108
108
|
supportsConst() {
|
109
|
-
return
|
109
|
+
return this.outputOptions.environment.const;
|
110
110
|
}
|
111
111
|
|
112
112
|
supportsArrowFunction() {
|
113
|
-
return
|
114
|
-
.arrowFunction;
|
113
|
+
return this.outputOptions.environment.arrowFunction;
|
115
114
|
}
|
116
115
|
|
117
116
|
supportsAsyncFunction() {
|
118
|
-
return
|
119
|
-
.asyncFunction;
|
117
|
+
return this.outputOptions.environment.asyncFunction;
|
120
118
|
}
|
121
119
|
|
122
120
|
supportsOptionalChaining() {
|
123
|
-
return
|
124
|
-
.optionalChaining;
|
121
|
+
return this.outputOptions.environment.optionalChaining;
|
125
122
|
}
|
126
123
|
|
127
124
|
supportsForOf() {
|
128
|
-
return
|
125
|
+
return this.outputOptions.environment.forOf;
|
129
126
|
}
|
130
127
|
|
131
128
|
supportsDestructuring() {
|
132
|
-
return
|
133
|
-
.destructuring;
|
129
|
+
return this.outputOptions.environment.destructuring;
|
134
130
|
}
|
135
131
|
|
136
132
|
supportsBigIntLiteral() {
|
137
|
-
return
|
138
|
-
.bigIntLiteral;
|
133
|
+
return this.outputOptions.environment.bigIntLiteral;
|
139
134
|
}
|
140
135
|
|
141
136
|
supportsDynamicImport() {
|
142
|
-
return
|
143
|
-
.dynamicImport;
|
137
|
+
return this.outputOptions.environment.dynamicImport;
|
144
138
|
}
|
145
139
|
|
146
140
|
supportsEcmaScriptModuleSyntax() {
|
147
|
-
return
|
141
|
+
return this.outputOptions.environment.module;
|
148
142
|
}
|
149
143
|
|
150
144
|
supportTemplateLiteral() {
|
151
|
-
return
|
152
|
-
.templateLiteral;
|
145
|
+
return this.outputOptions.environment.templateLiteral;
|
153
146
|
}
|
154
147
|
|
155
148
|
supportNodePrefixForCoreModules() {
|
156
|
-
return
|
157
|
-
.nodePrefixForCoreModules;
|
149
|
+
return this.outputOptions.environment.nodePrefixForCoreModules;
|
158
150
|
}
|
159
151
|
|
160
152
|
/**
|
@@ -315,7 +307,7 @@ class RuntimeTemplate {
|
|
315
307
|
* Add a comment
|
316
308
|
* @param {object} options Information content of the comment
|
317
309
|
* @param {string=} options.request request string used originally
|
318
|
-
* @param {string=} options.chunkName name of the chunk referenced
|
310
|
+
* @param {(string | null)=} options.chunkName name of the chunk referenced
|
319
311
|
* @param {string=} options.chunkReason reason information of the chunk
|
320
312
|
* @param {string=} options.message additional message
|
321
313
|
* @param {string=} options.exportName name of the export
|
@@ -1105,27 +1097,6 @@ class RuntimeTemplate {
|
|
1105
1097
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
1106
1098
|
return `${RuntimeGlobals.makeNamespaceObject}(${exportsArgument});\n`;
|
1107
1099
|
}
|
1108
|
-
|
1109
|
-
/**
|
1110
|
-
* @param {object} options options object
|
1111
|
-
* @param {Module} options.module the module
|
1112
|
-
* @param {RuntimeSpec=} options.runtime runtime
|
1113
|
-
* @param {CodeGenerationResults} options.codeGenerationResults the code generation results
|
1114
|
-
* @returns {string} the url of the asset
|
1115
|
-
*/
|
1116
|
-
assetUrl({ runtime, module, codeGenerationResults }) {
|
1117
|
-
if (!module) {
|
1118
|
-
return "data:,";
|
1119
|
-
}
|
1120
|
-
const codeGen = codeGenerationResults.get(module, runtime);
|
1121
|
-
const data = /** @type {NonNullable<CodeGenerationResult["data"]>} */ (
|
1122
|
-
codeGen.data
|
1123
|
-
);
|
1124
|
-
const url = data.get("url");
|
1125
|
-
if (url) return url.toString();
|
1126
|
-
const assetPath = data.get("assetPathForCss");
|
1127
|
-
return assetPath;
|
1128
|
-
}
|
1129
1100
|
}
|
1130
1101
|
|
1131
1102
|
module.exports = RuntimeTemplate;
|
@@ -236,11 +236,17 @@ class SourceMapDevToolPlugin {
|
|
236
236
|
fileIndex++;
|
237
237
|
return callback();
|
238
238
|
}
|
239
|
+
|
240
|
+
const chunk = fileToChunk.get(file);
|
241
|
+
const sourceMapNamespace = compilation.getPath(this.namespace, {
|
242
|
+
chunk
|
243
|
+
});
|
244
|
+
|
239
245
|
const cacheItem = cache.getItemCache(
|
240
246
|
file,
|
241
247
|
cache.mergeEtags(
|
242
248
|
cache.getLazyHashedEtag(asset.source),
|
243
|
-
|
249
|
+
sourceMapNamespace
|
244
250
|
)
|
245
251
|
);
|
246
252
|
|
@@ -270,11 +276,8 @@ class SourceMapDevToolPlugin {
|
|
270
276
|
/**
|
271
277
|
* Add file to chunk, if not presented there
|
272
278
|
*/
|
273
|
-
if (cachedFile !== file)
|
274
|
-
|
275
|
-
if (chunk !== undefined)
|
276
|
-
chunk.auxiliaryFiles.add(cachedFile);
|
277
|
-
}
|
279
|
+
if (cachedFile !== file && chunk !== undefined)
|
280
|
+
chunk.auxiliaryFiles.add(cachedFile);
|
278
281
|
}
|
279
282
|
|
280
283
|
reportProgress(
|
@@ -326,7 +329,7 @@ class SourceMapDevToolPlugin {
|
|
326
329
|
module,
|
327
330
|
{
|
328
331
|
moduleFilenameTemplate,
|
329
|
-
namespace
|
332
|
+
namespace: sourceMapNamespace
|
330
333
|
},
|
331
334
|
{
|
332
335
|
requestShortener,
|
@@ -162,19 +162,25 @@ const replacePathVariables = (path, data, assetInfo) => {
|
|
162
162
|
if (match) {
|
163
163
|
const ext = mime.extension(match[1]);
|
164
164
|
const emptyReplacer = replacer("", true);
|
165
|
+
// "XXXX" used for `updateHash`, so we don't need it here
|
166
|
+
const contentHash =
|
167
|
+
data.contentHash && !/X+/.test(data.contentHash)
|
168
|
+
? data.contentHash
|
169
|
+
: false;
|
170
|
+
const baseReplacer = contentHash ? replacer(contentHash) : emptyReplacer;
|
165
171
|
|
166
172
|
replacements.set("file", emptyReplacer);
|
167
173
|
replacements.set("query", emptyReplacer);
|
168
174
|
replacements.set("fragment", emptyReplacer);
|
169
175
|
replacements.set("path", emptyReplacer);
|
170
|
-
replacements.set("base",
|
171
|
-
replacements.set("name",
|
176
|
+
replacements.set("base", baseReplacer);
|
177
|
+
replacements.set("name", baseReplacer);
|
172
178
|
replacements.set("ext", replacer(ext ? `.${ext}` : "", true));
|
173
179
|
// Legacy
|
174
180
|
replacements.set(
|
175
181
|
"filebase",
|
176
182
|
deprecated(
|
177
|
-
|
183
|
+
baseReplacer,
|
178
184
|
"[filebase] is now [base]",
|
179
185
|
"DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME"
|
180
186
|
)
|
package/lib/Watching.js
CHANGED
@@ -77,8 +77,8 @@ class Watching {
|
|
77
77
|
}
|
78
78
|
|
79
79
|
/**
|
80
|
-
* @param {ReadonlySet<string
|
81
|
-
* @param {ReadonlySet<string
|
80
|
+
* @param {ReadonlySet<string> | undefined | null} changedFiles changed files
|
81
|
+
* @param {ReadonlySet<string> | undefined | null} removedFiles removed files
|
82
82
|
*/
|
83
83
|
_mergeWithCollected(changedFiles, removedFiles) {
|
84
84
|
if (!changedFiles) return;
|
@@ -56,6 +56,8 @@ const DefaultStatsPrinterPlugin = require("./stats/DefaultStatsPrinterPlugin");
|
|
56
56
|
const { cleverMerge } = require("./util/cleverMerge");
|
57
57
|
|
58
58
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
59
|
+
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
60
|
+
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
59
61
|
/** @typedef {import("./Compiler")} Compiler */
|
60
62
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
61
63
|
/** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
@@ -123,16 +125,16 @@ class WebpackOptionsApply extends OptionsApply {
|
|
123
125
|
const ExternalsPlugin = require("./ExternalsPlugin");
|
124
126
|
new ExternalsPlugin("import", ({ request, dependencyType }, callback) => {
|
125
127
|
if (dependencyType === "url") {
|
126
|
-
if (/^(\/\/|https?:\/\/|#)/.test(request))
|
128
|
+
if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request)))
|
127
129
|
return callback(null, `asset ${request}`);
|
128
130
|
} else if (options.experiments.css && dependencyType === "css-import") {
|
129
|
-
if (/^(\/\/|https?:\/\/|#)/.test(request))
|
131
|
+
if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request)))
|
130
132
|
return callback(null, `css-import ${request}`);
|
131
133
|
} else if (
|
132
134
|
options.experiments.css &&
|
133
|
-
/^(\/\/|https?:\/\/|std:)/.test(request)
|
135
|
+
/^(\/\/|https?:\/\/|std:)/.test(/** @type {string} */ (request))
|
134
136
|
) {
|
135
|
-
if (/^\.css(\?|$)/.test(request))
|
137
|
+
if (/^\.css(\?|$)/.test(/** @type {string} */ (request)))
|
136
138
|
return callback(null, `css-import ${request}`);
|
137
139
|
return callback(null, `import ${request}`);
|
138
140
|
}
|
@@ -143,13 +145,18 @@ class WebpackOptionsApply extends OptionsApply {
|
|
143
145
|
const ExternalsPlugin = require("./ExternalsPlugin");
|
144
146
|
new ExternalsPlugin("module", ({ request, dependencyType }, callback) => {
|
145
147
|
if (dependencyType === "url") {
|
146
|
-
if (/^(\/\/|https?:\/\/|#)/.test(request))
|
148
|
+
if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request)))
|
147
149
|
return callback(null, `asset ${request}`);
|
148
150
|
} else if (options.experiments.css && dependencyType === "css-import") {
|
149
|
-
if (/^(\/\/|https?:\/\/|#)/.test(request))
|
151
|
+
if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request)))
|
150
152
|
return callback(null, `css-import ${request}`);
|
151
|
-
} else if (
|
152
|
-
|
153
|
+
} else if (
|
154
|
+
/^(\/\/|https?:\/\/|std:)/.test(/** @type {string} */ (request))
|
155
|
+
) {
|
156
|
+
if (
|
157
|
+
options.experiments.css &&
|
158
|
+
/^\.css((\?)|$)/.test(/** @type {string} */ (request))
|
159
|
+
)
|
153
160
|
return callback(null, `css-import ${request}`);
|
154
161
|
return callback(null, `module ${request}`);
|
155
162
|
}
|
@@ -160,13 +167,15 @@ class WebpackOptionsApply extends OptionsApply {
|
|
160
167
|
const ExternalsPlugin = require("./ExternalsPlugin");
|
161
168
|
new ExternalsPlugin("module", ({ request, dependencyType }, callback) => {
|
162
169
|
if (dependencyType === "url") {
|
163
|
-
if (/^(\/\/|https?:\/\/|#)/.test(request))
|
170
|
+
if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request)))
|
164
171
|
return callback(null, `asset ${request}`);
|
165
172
|
} else if (dependencyType === "css-import") {
|
166
|
-
if (/^(\/\/|https?:\/\/|#)/.test(request))
|
173
|
+
if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request)))
|
167
174
|
return callback(null, `css-import ${request}`);
|
168
|
-
} else if (
|
169
|
-
|
175
|
+
} else if (
|
176
|
+
/^(\/\/|https?:\/\/|std:)/.test(/** @type {string} */ (request))
|
177
|
+
) {
|
178
|
+
if (/^\.css(\?|$)/.test(/** @type {string} */ (request)))
|
170
179
|
return callback(null, `css-import ${request}`);
|
171
180
|
return callback(null, `module ${request}`);
|
172
181
|
}
|
@@ -488,8 +497,12 @@ class WebpackOptionsApply extends OptionsApply {
|
|
488
497
|
if (options.optimization.realContentHash) {
|
489
498
|
const RealContentHashPlugin = require("./optimize/RealContentHashPlugin");
|
490
499
|
new RealContentHashPlugin({
|
491
|
-
hashFunction:
|
492
|
-
|
500
|
+
hashFunction:
|
501
|
+
/** @type {NonNullable<WebpackOptions["output"]["hashFunction"]>} */
|
502
|
+
(options.output.hashFunction),
|
503
|
+
hashDigest:
|
504
|
+
/** @type {NonNullable<WebpackOptions["output"]["hashDigest"]>} */
|
505
|
+
(options.output.hashDigest)
|
493
506
|
}).apply(compiler);
|
494
507
|
}
|
495
508
|
if (options.optimization.checkWasmTypes) {
|
@@ -587,9 +600,12 @@ class WebpackOptionsApply extends OptionsApply {
|
|
587
600
|
}).apply(compiler);
|
588
601
|
}
|
589
602
|
if (options.optimization.minimize) {
|
590
|
-
for (const minimizer of
|
603
|
+
for (const minimizer of /** @type {(WebpackPluginInstance | WebpackPluginFunction | "...")[]} */ (
|
604
|
+
options.optimization.minimizer
|
605
|
+
)) {
|
591
606
|
if (typeof minimizer === "function") {
|
592
|
-
|
607
|
+
/** @type {WebpackPluginFunction} */
|
608
|
+
(minimizer).call(compiler, compiler);
|
593
609
|
} else if (minimizer !== "..." && minimizer) {
|
594
610
|
minimizer.apply(compiler);
|
595
611
|
}
|
@@ -661,7 +677,9 @@ class WebpackOptionsApply extends OptionsApply {
|
|
661
677
|
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
|
662
678
|
const MemoryWithGcCachePlugin = require("./cache/MemoryWithGcCachePlugin");
|
663
679
|
new MemoryWithGcCachePlugin({
|
664
|
-
maxGenerations:
|
680
|
+
maxGenerations:
|
681
|
+
/** @type {number} */
|
682
|
+
(cacheOptions.maxMemoryGenerations)
|
665
683
|
}).apply(compiler);
|
666
684
|
}
|
667
685
|
if (cacheOptions.memoryCacheUnaffected) {
|
@@ -686,7 +704,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
686
704
|
cacheLocation:
|
687
705
|
/** @type {string} */
|
688
706
|
(cacheOptions.cacheLocation),
|
689
|
-
version: cacheOptions.version,
|
707
|
+
version: /** @type {string} */ (cacheOptions.version),
|
690
708
|
logger: compiler.getInfrastructureLogger(
|
691
709
|
"webpack.cache.PackFileCacheStrategy"
|
692
710
|
),
|
@@ -697,9 +715,12 @@ class WebpackOptionsApply extends OptionsApply {
|
|
697
715
|
compression: cacheOptions.compression,
|
698
716
|
readonly: cacheOptions.readonly
|
699
717
|
}),
|
700
|
-
|
701
|
-
cacheOptions.
|
702
|
-
|
718
|
+
/** @type {number} */
|
719
|
+
(cacheOptions.idleTimeout),
|
720
|
+
/** @type {number} */
|
721
|
+
(cacheOptions.idleTimeoutForInitialStore),
|
722
|
+
/** @type {number} */
|
723
|
+
(cacheOptions.idleTimeoutAfterLargeChanges)
|
703
724
|
).apply(compiler);
|
704
725
|
break;
|
705
726
|
}
|