webpack 5.105.4 → 5.106.1
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 +3 -6
- package/lib/BannerPlugin.js +13 -13
- package/lib/Chunk.js +25 -0
- package/lib/ChunkGraph.js +8 -4
- package/lib/CleanPlugin.js +23 -20
- package/lib/CompatibilityPlugin.js +1 -1
- package/lib/Compilation.js +34 -11
- package/lib/Compiler.js +59 -1
- package/lib/CssModule.js +17 -2
- package/lib/Dependency.js +1 -1
- package/lib/DllPlugin.js +17 -17
- package/lib/DllReferencePlugin.js +20 -18
- package/lib/DotenvPlugin.js +29 -27
- package/lib/ExternalModule.js +39 -6
- package/lib/FileSystemInfo.js +3 -1
- package/lib/IgnorePlugin.js +12 -11
- package/lib/LoaderOptionsPlugin.js +17 -15
- package/lib/ManifestPlugin.js +27 -25
- package/lib/Module.js +69 -7
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleParseError.js +1 -1
- package/lib/ModuleTypeConstants.js +1 -1
- package/lib/NormalModule.js +7 -3
- package/lib/NormalModuleFactory.js +20 -1
- package/lib/ProgressPlugin.js +39 -29
- package/lib/RuntimeGlobals.js +6 -0
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +13 -11
- package/lib/TemplatedPathPlugin.js +4 -3
- package/lib/WatchIgnorePlugin.js +15 -13
- package/lib/WebpackOptionsApply.js +4 -4
- package/lib/asset/AssetModulesPlugin.js +50 -29
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +27 -13
- package/lib/config/normalization.js +3 -2
- package/lib/container/ContainerPlugin.js +46 -42
- package/lib/container/ContainerReferencePlugin.js +42 -26
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +17 -13
- package/lib/css/CssGenerator.js +306 -192
- package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
- package/lib/css/CssLoadingRuntimeModule.js +1 -4
- package/lib/css/CssModulesPlugin.js +197 -98
- package/lib/css/CssParser.js +243 -134
- package/lib/css/walkCssTokens.js +115 -12
- package/lib/debug/ProfilingPlugin.js +16 -13
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
- package/lib/dependencies/CommonJsExportsDependency.js +1 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
- package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
- package/lib/dependencies/CommonJsRequireDependency.js +42 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +211 -88
- package/lib/dependencies/CssIcssImportDependency.js +13 -70
- package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
- package/lib/dependencies/HarmonyExportExpressionDependency.js +35 -5
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +21 -8
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
- package/lib/dependencies/ImportContextDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +16 -2
- package/lib/dependencies/ImportMetaPlugin.js +39 -29
- package/lib/dependencies/ImportParserPlugin.js +4 -5
- package/lib/dependencies/ImportPhase.js +65 -22
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
- package/lib/ids/HashedModuleIdsPlugin.js +21 -23
- package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
- package/lib/javascript/JavascriptModulesPlugin.js +38 -12
- package/lib/javascript/JavascriptParser.js +5 -3
- package/lib/json/JsonModulesPlugin.js +28 -21
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +35 -13
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
- package/lib/optimize/ConcatenatedModule.js +4 -3
- package/lib/optimize/InnerGraphPlugin.js +11 -5
- package/lib/optimize/LimitChunkCountPlugin.js +22 -18
- package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
- package/lib/optimize/MinChunkSizePlugin.js +20 -16
- package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +20 -11
- package/lib/schemes/VirtualUrlPlugin.js +77 -30
- package/lib/serialization/FileMiddleware.js +7 -7
- package/lib/sharing/ConsumeSharedPlugin.js +32 -25
- package/lib/sharing/ProvideSharedPlugin.js +29 -25
- package/lib/util/{propertyName.js → property.js} +26 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
- package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
- package/lib/web/JsonpTemplatePlugin.js +1 -0
- package/lib/webpack.js +34 -4
- package/package.json +18 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +82 -22
- 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/optimize/LimitChunkCountPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
- package/types.d.ts +511 -114
- package/lib/util/create-schema-validation.js +0 -41
- package/lib/util/propertyAccess.js +0 -30
package/README.md
CHANGED
|
@@ -164,18 +164,15 @@ or are automatically applied via regex from your webpack configuration.
|
|
|
164
164
|
| Name | Status | Install Size | Description |
|
|
165
165
|
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- |
|
|
166
166
|
| <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/html5/html5-original.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
|
|
167
|
-
|
|
|
168
|
-
| <a href="https://github.com/webdiscus/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular |
|
|
167
|
+
| <a href="https://github.com/webdiscus/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug-npm] | ![pug-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular |
|
|
169
168
|
| <a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/markdown/markdown-original.svg"></a> | ![md-npm] | ![md-size] | Compiles Markdown to HTML |
|
|
170
169
|
| <a href="https://github.com/posthtml/posthtml-loader"><img width="48" height="48" src="https://posthtml.github.io/posthtml/logo.svg"></a> | ![posthtml-npm] | ![posthtml-size] | Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml) |
|
|
171
170
|
| <a href="https://github.com/pcardune/handlebars-loader"><img width="48" height="48" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/handlebars/handlebars-original.svg"></a> | ![hbs-npm] | ![hbs-size] | Compiles Handlebars to HTML |
|
|
172
171
|
|
|
173
172
|
[html-npm]: https://img.shields.io/npm/v/html-loader.svg
|
|
174
173
|
[html-size]: https://packagephobia.com/badge?p=html-loader
|
|
175
|
-
[pug-npm]: https://img.shields.io/npm/v/pug-loader.svg
|
|
176
|
-
[pug-size]: https://packagephobia.com/badge?p
|
|
177
|
-
[pug3-npm]: https://img.shields.io/npm/v/@webdiscus/pug-loader.svg
|
|
178
|
-
[pug3-size]: https://packagephobia.com/badge?p=@webdiscus/pug-loader
|
|
174
|
+
[pug-npm]: https://img.shields.io/npm/v/@webdiscus/pug-loader.svg
|
|
175
|
+
[pug-size]: https://packagephobia.com/badge?p=@webdiscus/pug-loader
|
|
179
176
|
[jade-npm]: https://img.shields.io/npm/v/jade-loader.svg
|
|
180
177
|
[jade-size]: https://packagephobia.com/badge?p=jade-loader
|
|
181
178
|
[md-npm]: https://img.shields.io/npm/v/markdown-loader.svg
|
package/lib/BannerPlugin.js
CHANGED
|
@@ -9,10 +9,10 @@ const { ConcatSource } = require("webpack-sources");
|
|
|
9
9
|
const Compilation = require("./Compilation");
|
|
10
10
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
|
11
11
|
const Template = require("./Template");
|
|
12
|
-
const createSchemaValidation = require("./util/create-schema-validation");
|
|
13
12
|
|
|
14
13
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
15
14
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
|
|
15
|
+
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
|
|
16
16
|
/** @typedef {import("./Compilation").PathData} PathData */
|
|
17
17
|
/** @typedef {import("./Compiler")} Compiler */
|
|
18
18
|
/** @typedef {import("./Chunk")} Chunk */
|
|
@@ -20,16 +20,6 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
20
20
|
|
|
21
21
|
/** @typedef {(data: { hash?: string, chunk: Chunk, filename: string }) => string} BannerFunction */
|
|
22
22
|
|
|
23
|
-
const validate = createSchemaValidation(
|
|
24
|
-
/** @type {((value: typeof import("../schemas/plugins/BannerPlugin.json")) => boolean)} */
|
|
25
|
-
(require("../schemas/plugins/BannerPlugin.check")),
|
|
26
|
-
() => require("../schemas/plugins/BannerPlugin.json"),
|
|
27
|
-
{
|
|
28
|
-
name: "Banner Plugin",
|
|
29
|
-
baseDataPath: "options"
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
|
|
33
23
|
/**
|
|
34
24
|
* @param {string} str string to wrap
|
|
35
25
|
* @returns {string} wrapped string
|
|
@@ -59,8 +49,7 @@ class BannerPlugin {
|
|
|
59
49
|
};
|
|
60
50
|
}
|
|
61
51
|
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
/** @type {BannerPluginOptions} */
|
|
64
53
|
this.options = options;
|
|
65
54
|
|
|
66
55
|
const bannerOption = options.banner;
|
|
@@ -85,6 +74,17 @@ class BannerPlugin {
|
|
|
85
74
|
* @returns {void}
|
|
86
75
|
*/
|
|
87
76
|
apply(compiler) {
|
|
77
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
78
|
+
compiler.validate(
|
|
79
|
+
() => require("../schemas/plugins/BannerPlugin.json"),
|
|
80
|
+
this.options,
|
|
81
|
+
{
|
|
82
|
+
name: "Banner Plugin",
|
|
83
|
+
baseDataPath: "options"
|
|
84
|
+
},
|
|
85
|
+
(options) => require("../schemas/plugins/BannerPlugin.check")(options)
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
88
|
const options = this.options;
|
|
89
89
|
const banner = this.banner;
|
|
90
90
|
const matchObject = ModuleFilenameHelpers.matchObject.bind(
|
package/lib/Chunk.js
CHANGED
|
@@ -124,6 +124,10 @@ class Chunk {
|
|
|
124
124
|
|
|
125
125
|
// TODO remove in webpack 6
|
|
126
126
|
// BACKWARD-COMPAT START
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated
|
|
129
|
+
* @returns {Module | undefined} entry module
|
|
130
|
+
*/
|
|
127
131
|
get entryModule() {
|
|
128
132
|
const entryModules = [
|
|
129
133
|
...ChunkGraph.getChunkGraphForChunk(
|
|
@@ -144,6 +148,7 @@ class Chunk {
|
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
/**
|
|
151
|
+
* @deprecated
|
|
147
152
|
* @returns {boolean} true, if the chunk contains an entry module
|
|
148
153
|
*/
|
|
149
154
|
hasEntryModule() {
|
|
@@ -157,6 +162,7 @@ class Chunk {
|
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
/**
|
|
165
|
+
* @deprecated
|
|
160
166
|
* @param {Module} module the module
|
|
161
167
|
* @returns {boolean} true, if the chunk could be added
|
|
162
168
|
*/
|
|
@@ -172,6 +178,7 @@ class Chunk {
|
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
/**
|
|
181
|
+
* @deprecated
|
|
175
182
|
* @param {Module} module the module
|
|
176
183
|
* @returns {void}
|
|
177
184
|
*/
|
|
@@ -184,6 +191,7 @@ class Chunk {
|
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
/**
|
|
194
|
+
* @deprecated
|
|
187
195
|
* @returns {number} the number of module which are contained in this chunk
|
|
188
196
|
*/
|
|
189
197
|
getNumberOfModules() {
|
|
@@ -194,6 +202,10 @@ class Chunk {
|
|
|
194
202
|
).getNumberOfChunkModules(this);
|
|
195
203
|
}
|
|
196
204
|
|
|
205
|
+
/**
|
|
206
|
+
* @deprecated
|
|
207
|
+
* @returns {Iterable<Module>} modules
|
|
208
|
+
*/
|
|
197
209
|
get modulesIterable() {
|
|
198
210
|
const chunkGraph = ChunkGraph.getChunkGraphForChunk(
|
|
199
211
|
this,
|
|
@@ -207,6 +219,7 @@ class Chunk {
|
|
|
207
219
|
}
|
|
208
220
|
|
|
209
221
|
/**
|
|
222
|
+
* @deprecated
|
|
210
223
|
* @param {Chunk} otherChunk the chunk to compare with
|
|
211
224
|
* @returns {-1 | 0 | 1} the comparison result
|
|
212
225
|
*/
|
|
@@ -220,6 +233,7 @@ class Chunk {
|
|
|
220
233
|
}
|
|
221
234
|
|
|
222
235
|
/**
|
|
236
|
+
* @deprecated
|
|
223
237
|
* @param {Module} module the module
|
|
224
238
|
* @returns {boolean} true, if the chunk contains the module
|
|
225
239
|
*/
|
|
@@ -232,6 +246,7 @@ class Chunk {
|
|
|
232
246
|
}
|
|
233
247
|
|
|
234
248
|
/**
|
|
249
|
+
* @deprecated
|
|
235
250
|
* @returns {Module[]} the modules for this chunk
|
|
236
251
|
*/
|
|
237
252
|
getModules() {
|
|
@@ -243,6 +258,7 @@ class Chunk {
|
|
|
243
258
|
}
|
|
244
259
|
|
|
245
260
|
/**
|
|
261
|
+
* @deprecated
|
|
246
262
|
* @returns {void}
|
|
247
263
|
*/
|
|
248
264
|
remove() {
|
|
@@ -256,6 +272,7 @@ class Chunk {
|
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
/**
|
|
275
|
+
* @deprecated
|
|
259
276
|
* @param {Module} module the module
|
|
260
277
|
* @param {Chunk} otherChunk the target chunk
|
|
261
278
|
* @returns {void}
|
|
@@ -271,6 +288,7 @@ class Chunk {
|
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
/**
|
|
291
|
+
* @deprecated
|
|
274
292
|
* @param {Chunk} otherChunk the other chunk
|
|
275
293
|
* @returns {boolean} true, if the specified chunk has been integrated
|
|
276
294
|
*/
|
|
@@ -289,6 +307,7 @@ class Chunk {
|
|
|
289
307
|
}
|
|
290
308
|
|
|
291
309
|
/**
|
|
310
|
+
* @deprecated
|
|
292
311
|
* @param {Chunk} otherChunk the other chunk
|
|
293
312
|
* @returns {boolean} true, if chunks could be integrated
|
|
294
313
|
*/
|
|
@@ -302,6 +321,7 @@ class Chunk {
|
|
|
302
321
|
}
|
|
303
322
|
|
|
304
323
|
/**
|
|
324
|
+
* @deprecated
|
|
305
325
|
* @returns {boolean} true, if this chunk contains no module
|
|
306
326
|
*/
|
|
307
327
|
isEmpty() {
|
|
@@ -314,6 +334,7 @@ class Chunk {
|
|
|
314
334
|
}
|
|
315
335
|
|
|
316
336
|
/**
|
|
337
|
+
* @deprecated
|
|
317
338
|
* @returns {number} total size of all modules in this chunk
|
|
318
339
|
*/
|
|
319
340
|
modulesSize() {
|
|
@@ -326,6 +347,7 @@ class Chunk {
|
|
|
326
347
|
}
|
|
327
348
|
|
|
328
349
|
/**
|
|
350
|
+
* @deprecated
|
|
329
351
|
* @param {ChunkSizeOptions} options options object
|
|
330
352
|
* @returns {number} total size of this chunk
|
|
331
353
|
*/
|
|
@@ -339,6 +361,7 @@ class Chunk {
|
|
|
339
361
|
}
|
|
340
362
|
|
|
341
363
|
/**
|
|
364
|
+
* @deprecated
|
|
342
365
|
* @param {Chunk} otherChunk the other chunk
|
|
343
366
|
* @param {ChunkSizeOptions} options options object
|
|
344
367
|
* @returns {number} total size of the chunk or false if the chunk can't be integrated
|
|
@@ -353,6 +376,7 @@ class Chunk {
|
|
|
353
376
|
}
|
|
354
377
|
|
|
355
378
|
/**
|
|
379
|
+
* @deprecated
|
|
356
380
|
* @param {ModuleFilterPredicate} filterFn function used to filter modules
|
|
357
381
|
* @returns {ChunkModuleMaps} module map information
|
|
358
382
|
*/
|
|
@@ -398,6 +422,7 @@ class Chunk {
|
|
|
398
422
|
}
|
|
399
423
|
|
|
400
424
|
/**
|
|
425
|
+
* @deprecated
|
|
401
426
|
* @param {ModuleFilterPredicate} filterFn predicate function used to filter modules
|
|
402
427
|
* @param {ChunkFilterPredicate=} filterChunkFn predicate function used to filter chunks
|
|
403
428
|
* @returns {boolean} return true if module exists in graph
|
package/lib/ChunkGraph.js
CHANGED
|
@@ -1846,6 +1846,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1846
1846
|
|
|
1847
1847
|
// TODO remove in webpack 6
|
|
1848
1848
|
/**
|
|
1849
|
+
* @deprecated
|
|
1849
1850
|
* @param {Module} module the module
|
|
1850
1851
|
* @param {string} deprecateMessage message for the deprecation message
|
|
1851
1852
|
* @param {string} deprecationCode code for the deprecation
|
|
@@ -1878,7 +1879,9 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1878
1879
|
}
|
|
1879
1880
|
|
|
1880
1881
|
// TODO remove in webpack 6
|
|
1882
|
+
// BACKWARD-COMPAT START
|
|
1881
1883
|
/**
|
|
1884
|
+
* @deprecated
|
|
1882
1885
|
* @param {Module} module the module
|
|
1883
1886
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
1884
1887
|
* @returns {void}
|
|
@@ -1887,8 +1890,8 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1887
1890
|
chunkGraphForModuleMap.set(module, chunkGraph);
|
|
1888
1891
|
}
|
|
1889
1892
|
|
|
1890
|
-
// TODO remove in webpack 6
|
|
1891
1893
|
/**
|
|
1894
|
+
* @deprecated
|
|
1892
1895
|
* @param {Module} module the module
|
|
1893
1896
|
* @returns {void}
|
|
1894
1897
|
*/
|
|
@@ -1896,8 +1899,8 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1896
1899
|
chunkGraphForModuleMap.delete(module);
|
|
1897
1900
|
}
|
|
1898
1901
|
|
|
1899
|
-
// TODO remove in webpack 6
|
|
1900
1902
|
/**
|
|
1903
|
+
* @deprecated
|
|
1901
1904
|
* @param {Chunk} chunk the chunk
|
|
1902
1905
|
* @param {string} deprecateMessage message for the deprecation message
|
|
1903
1906
|
* @param {string} deprecationCode code for the deprecation
|
|
@@ -1929,8 +1932,8 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1929
1932
|
return newFn(chunk);
|
|
1930
1933
|
}
|
|
1931
1934
|
|
|
1932
|
-
// TODO remove in webpack 6
|
|
1933
1935
|
/**
|
|
1936
|
+
* @deprecated
|
|
1934
1937
|
* @param {Chunk} chunk the chunk
|
|
1935
1938
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
1936
1939
|
* @returns {void}
|
|
@@ -1939,14 +1942,15 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1939
1942
|
chunkGraphForChunkMap.set(chunk, chunkGraph);
|
|
1940
1943
|
}
|
|
1941
1944
|
|
|
1942
|
-
// TODO remove in webpack 6
|
|
1943
1945
|
/**
|
|
1946
|
+
* @deprecated
|
|
1944
1947
|
* @param {Chunk} chunk the chunk
|
|
1945
1948
|
* @returns {void}
|
|
1946
1949
|
*/
|
|
1947
1950
|
static clearChunkGraphForChunk(chunk) {
|
|
1948
1951
|
chunkGraphForChunkMap.delete(chunk);
|
|
1949
1952
|
}
|
|
1953
|
+
// BACKWARD-COMPAT END
|
|
1950
1954
|
}
|
|
1951
1955
|
|
|
1952
1956
|
// TODO remove in webpack 6
|
package/lib/CleanPlugin.js
CHANGED
|
@@ -9,7 +9,6 @@ const path = require("path");
|
|
|
9
9
|
const asyncLib = require("neo-async");
|
|
10
10
|
const { SyncBailHook } = require("tapable");
|
|
11
11
|
const Compilation = require("./Compilation");
|
|
12
|
-
const createSchemaValidation = require("./util/create-schema-validation");
|
|
13
12
|
const { join } = require("./util/fs");
|
|
14
13
|
const processAsyncTree = require("./util/processAsyncTree");
|
|
15
14
|
|
|
@@ -33,21 +32,6 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
33
32
|
* @returns {boolean | undefined} true, if the path should be kept
|
|
34
33
|
*/
|
|
35
34
|
|
|
36
|
-
const validate = createSchemaValidation(
|
|
37
|
-
undefined,
|
|
38
|
-
() => {
|
|
39
|
-
const { definitions } = require("../schemas/WebpackOptions.json");
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
definitions,
|
|
43
|
-
oneOf: [{ $ref: "#/definitions/CleanOptions" }]
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "Clean Plugin",
|
|
48
|
-
baseDataPath: "options"
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
35
|
const _10sec = 10 * 1000;
|
|
52
36
|
|
|
53
37
|
/**
|
|
@@ -368,9 +352,8 @@ class CleanPlugin {
|
|
|
368
352
|
|
|
369
353
|
/** @param {CleanOptions} options options */
|
|
370
354
|
constructor(options = {}) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
this.options = { dry: false, ...options };
|
|
355
|
+
/** @type {CleanOptions} */
|
|
356
|
+
this.options = options;
|
|
374
357
|
}
|
|
375
358
|
|
|
376
359
|
/**
|
|
@@ -379,8 +362,28 @@ class CleanPlugin {
|
|
|
379
362
|
* @returns {void}
|
|
380
363
|
*/
|
|
381
364
|
apply(compiler) {
|
|
382
|
-
|
|
365
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
366
|
+
compiler.validate(
|
|
367
|
+
() => {
|
|
368
|
+
const { definitions } = require("../schemas/WebpackOptions.json");
|
|
369
|
+
|
|
370
|
+
return {
|
|
371
|
+
definitions,
|
|
372
|
+
oneOf: [{ $ref: "#/definitions/CleanOptions" }]
|
|
373
|
+
};
|
|
374
|
+
},
|
|
375
|
+
this.options,
|
|
376
|
+
{
|
|
377
|
+
name: "Clean Plugin",
|
|
378
|
+
baseDataPath: "options"
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
const { keep } = this.options;
|
|
383
384
|
|
|
385
|
+
/** @type {boolean} */
|
|
386
|
+
const dry = this.options.dry || false;
|
|
384
387
|
/** @type {KeepFn} */
|
|
385
388
|
const keepFn =
|
|
386
389
|
typeof keep === "function"
|
package/lib/Compilation.js
CHANGED
|
@@ -122,6 +122,8 @@ const { isSourceEqual } = require("./util/source");
|
|
|
122
122
|
/** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
|
|
123
123
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
|
|
124
124
|
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
|
125
|
+
/** @typedef {import("./NormalModule")} NormalModule */
|
|
126
|
+
/** @typedef {import("./NormalModule").AnyLoaderContext} AnyLoaderContext */
|
|
125
127
|
/** @typedef {import("./NormalModule").ParserOptions} ParserOptions */
|
|
126
128
|
/** @typedef {import("./NormalModule").GeneratorOptions} GeneratorOptions */
|
|
127
129
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
@@ -347,6 +349,7 @@ const { isSourceEqual } = require("./util/source");
|
|
|
347
349
|
* @property {HashWithLengthFunction=} contentHashWithLength
|
|
348
350
|
* @property {boolean=} noChunkHash
|
|
349
351
|
* @property {string=} url
|
|
352
|
+
* @property {string=} local
|
|
350
353
|
* @property {PrepareIdFunction=} prepareId
|
|
351
354
|
*/
|
|
352
355
|
|
|
@@ -1038,6 +1041,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1038
1041
|
/** @type {SyncHook<[StatsPrinter, NormalizedStatsOptions]>} */
|
|
1039
1042
|
statsPrinter: new SyncHook(["statsPrinter", "options"]),
|
|
1040
1043
|
|
|
1044
|
+
/**
|
|
1045
|
+
* @deprecated
|
|
1046
|
+
* @returns {SyncHook<[AnyLoaderContext, NormalModule]>} normal module loader hook
|
|
1047
|
+
*/
|
|
1041
1048
|
get normalModuleLoader() {
|
|
1042
1049
|
return getNormalModuleLoader();
|
|
1043
1050
|
}
|
|
@@ -1245,6 +1252,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1245
1252
|
/** @type {FileSystemDependencies} */
|
|
1246
1253
|
this.buildDependencies = new LazySet();
|
|
1247
1254
|
// TODO webpack 6 remove
|
|
1255
|
+
/**
|
|
1256
|
+
* @deprecated
|
|
1257
|
+
* @type {{ add: (item: string) => FileSystemDependencies }}
|
|
1258
|
+
*/
|
|
1248
1259
|
this.compilationDependencies = {
|
|
1249
1260
|
add: util.deprecate(
|
|
1250
1261
|
/**
|
|
@@ -3263,7 +3274,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3263
3274
|
chunkGraphInit.set(entrypoint, (modulesList = []));
|
|
3264
3275
|
}
|
|
3265
3276
|
for (const module of includedModules) {
|
|
3266
|
-
this.
|
|
3277
|
+
this.assignDepths([module]);
|
|
3267
3278
|
modulesList.push(module);
|
|
3268
3279
|
}
|
|
3269
3280
|
}
|
|
@@ -4165,7 +4176,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4165
4176
|
}
|
|
4166
4177
|
|
|
4167
4178
|
/**
|
|
4168
|
-
* @param {Set<Module>} modules module to assign depth
|
|
4179
|
+
* @param {Module[] | Set<Module>} modules module to assign depth
|
|
4169
4180
|
* @returns {void}
|
|
4170
4181
|
*/
|
|
4171
4182
|
assignDepths(modules) {
|
|
@@ -4486,24 +4497,34 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4486
4497
|
|
|
4487
4498
|
this.logger.time("hashing: sort chunks");
|
|
4488
4499
|
/*
|
|
4489
|
-
*
|
|
4490
|
-
*
|
|
4491
|
-
*
|
|
4492
|
-
*
|
|
4493
|
-
*
|
|
4494
|
-
*
|
|
4495
|
-
*
|
|
4496
|
-
*
|
|
4500
|
+
* Chunks are hashed in 4 categories, in this order:
|
|
4501
|
+
* 1. Async chunks - no hash dependencies on other chunks
|
|
4502
|
+
* 2. Non-entry initial chunks (e.g. shared split chunks) - no hash
|
|
4503
|
+
* dependencies on other chunks, but runtime chunks may read their
|
|
4504
|
+
* hashes via GetChunkFilenameRuntimeModule (dependentHash)
|
|
4505
|
+
* 3. Runtime chunks - may use hashes of async and non-entry initial
|
|
4506
|
+
* chunks (via GetChunkFilenameRuntimeModule). Ordered by references
|
|
4507
|
+
* between each other (for async entrypoints)
|
|
4508
|
+
* 4. Entry chunks - may depend on runtimeChunk.hash (via
|
|
4509
|
+
* createChunkHashHandler for ESM/CJS entry importing runtime)
|
|
4510
|
+
*
|
|
4511
|
+
* This ordering ensures all hash dependencies flow in one direction:
|
|
4512
|
+
* async/initial → runtime → entry, with no circular dependencies.
|
|
4513
|
+
* Chunks within each category are sorted by id for determinism.
|
|
4497
4514
|
*/
|
|
4498
4515
|
/** @type {Chunk[]} */
|
|
4499
4516
|
const unorderedRuntimeChunks = [];
|
|
4500
4517
|
/** @type {Chunk[]} */
|
|
4501
4518
|
const initialChunks = [];
|
|
4502
4519
|
/** @type {Chunk[]} */
|
|
4520
|
+
const entryChunks = [];
|
|
4521
|
+
/** @type {Chunk[]} */
|
|
4503
4522
|
const asyncChunks = [];
|
|
4504
4523
|
for (const c of this.chunks) {
|
|
4505
4524
|
if (c.hasRuntime()) {
|
|
4506
4525
|
unorderedRuntimeChunks.push(c);
|
|
4526
|
+
} else if (chunkGraph.getNumberOfEntryModules(c) > 0) {
|
|
4527
|
+
entryChunks.push(c);
|
|
4507
4528
|
} else if (c.canBeInitial()) {
|
|
4508
4529
|
initialChunks.push(c);
|
|
4509
4530
|
} else {
|
|
@@ -4511,6 +4532,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4511
4532
|
}
|
|
4512
4533
|
}
|
|
4513
4534
|
unorderedRuntimeChunks.sort(byId);
|
|
4535
|
+
entryChunks.sort(byId);
|
|
4514
4536
|
initialChunks.sort(byId);
|
|
4515
4537
|
asyncChunks.sort(byId);
|
|
4516
4538
|
|
|
@@ -4682,8 +4704,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
4682
4704
|
this.logger.timeAggregate("hashing: hash chunks");
|
|
4683
4705
|
};
|
|
4684
4706
|
for (const chunk of asyncChunks) processChunk(chunk);
|
|
4685
|
-
for (const chunk of runtimeChunks) processChunk(chunk);
|
|
4686
4707
|
for (const chunk of initialChunks) processChunk(chunk);
|
|
4708
|
+
for (const chunk of runtimeChunks) processChunk(chunk);
|
|
4709
|
+
for (const chunk of entryChunks) processChunk(chunk);
|
|
4687
4710
|
if (errors.length > 0) {
|
|
4688
4711
|
errors.sort(
|
|
4689
4712
|
compareSelect((err) => err.module, compareModulesByIdentifier)
|
package/lib/Compiler.js
CHANGED
|
@@ -30,6 +30,7 @@ const WebpackError = require("./WebpackError");
|
|
|
30
30
|
const { Logger } = require("./logging/Logger");
|
|
31
31
|
const { dirname, join, mkdirp } = require("./util/fs");
|
|
32
32
|
const { makePathsRelative } = require("./util/identifier");
|
|
33
|
+
const memoize = require("./util/memoize");
|
|
33
34
|
const { isSourceEqual } = require("./util/source");
|
|
34
35
|
const webpack = require(".");
|
|
35
36
|
|
|
@@ -61,6 +62,9 @@ const webpack = require(".");
|
|
|
61
62
|
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
|
62
63
|
/** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */
|
|
63
64
|
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
|
|
65
|
+
/** @typedef {import("schema-utils").validate} Validate */
|
|
66
|
+
/** @typedef {import("schema-utils").Schema} Schema */
|
|
67
|
+
/** @typedef {import("schema-utils").ValidationErrorConfiguration} ValidationErrorConfiguration */
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* @typedef {object} CompilationParams
|
|
@@ -155,6 +159,8 @@ const includesHash = (filename, hashes) => {
|
|
|
155
159
|
return filename.includes(hashes);
|
|
156
160
|
};
|
|
157
161
|
|
|
162
|
+
const getValidate = memoize(() => require("schema-utils").validate);
|
|
163
|
+
|
|
158
164
|
class Compiler {
|
|
159
165
|
/**
|
|
160
166
|
* @param {string} context the compilation path
|
|
@@ -226,6 +232,8 @@ class Compiler {
|
|
|
226
232
|
// TODO the following hooks are weirdly located here
|
|
227
233
|
// TODO move them for webpack 5
|
|
228
234
|
/** @type {SyncHook<[]>} */
|
|
235
|
+
validate: new SyncHook([]),
|
|
236
|
+
/** @type {SyncHook<[]>} */
|
|
229
237
|
environment: new SyncHook([]),
|
|
230
238
|
/** @type {SyncHook<[]>} */
|
|
231
239
|
afterEnvironment: new SyncHook([]),
|
|
@@ -510,7 +518,6 @@ class Compiler {
|
|
|
510
518
|
if (logger) logger.time("beginIdle");
|
|
511
519
|
this.idle = true;
|
|
512
520
|
this.cache.beginIdle();
|
|
513
|
-
this.idle = true;
|
|
514
521
|
if (logger) logger.timeEnd("beginIdle");
|
|
515
522
|
this.running = false;
|
|
516
523
|
if (err) {
|
|
@@ -1408,6 +1415,57 @@ ${other}`);
|
|
|
1408
1415
|
this.cache.shutdown(callback);
|
|
1409
1416
|
});
|
|
1410
1417
|
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Schema validation function with optional pre-compiled check
|
|
1421
|
+
* @template {EXPECTED_OBJECT | EXPECTED_OBJECT[]} [T=EXPECTED_OBJECT]
|
|
1422
|
+
* @param {Schema | (() => Schema)} schema schema
|
|
1423
|
+
* @param {T} value value
|
|
1424
|
+
* @param {ValidationErrorConfiguration=} options options
|
|
1425
|
+
* @param {((value: T) => boolean)=} check options
|
|
1426
|
+
*/
|
|
1427
|
+
validate(schema, value, options, check) {
|
|
1428
|
+
// Avoid validation at all when disabled
|
|
1429
|
+
if (this.options.validate === false) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* @returns {Schema} schema
|
|
1435
|
+
*/
|
|
1436
|
+
const getSchema = () => {
|
|
1437
|
+
if (typeof schema === "function") {
|
|
1438
|
+
return schema();
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
return schema;
|
|
1442
|
+
};
|
|
1443
|
+
|
|
1444
|
+
// // If we have precompiled schema let's use it
|
|
1445
|
+
if (check) {
|
|
1446
|
+
if (!check(value)) {
|
|
1447
|
+
getValidate()(
|
|
1448
|
+
getSchema(),
|
|
1449
|
+
/** @type {EXPECTED_OBJECT | EXPECTED_OBJECT[]} */
|
|
1450
|
+
(value),
|
|
1451
|
+
options
|
|
1452
|
+
);
|
|
1453
|
+
require("util").deprecate(
|
|
1454
|
+
() => {},
|
|
1455
|
+
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
|
1456
|
+
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
|
|
1457
|
+
)();
|
|
1458
|
+
}
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// Otherwise let's standard validation
|
|
1463
|
+
getValidate()(
|
|
1464
|
+
getSchema(),
|
|
1465
|
+
/** @type {EXPECTED_OBJECT | EXPECTED_OBJECT[]} */ (value),
|
|
1466
|
+
options
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1411
1469
|
}
|
|
1412
1470
|
|
|
1413
1471
|
module.exports = Compiler;
|
package/lib/CssModule.js
CHANGED
|
@@ -13,6 +13,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
13
13
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
14
14
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
15
15
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
|
+
/** @typedef {import("../declarations/WebpackOptions").CssParserExportType} CssParserExportType */
|
|
16
17
|
|
|
17
18
|
/** @typedef {string | undefined} CssLayer */
|
|
18
19
|
/** @typedef {string | undefined} Supports */
|
|
@@ -20,7 +21,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
20
21
|
/** @typedef {[CssLayer, Supports, Media]} InheritanceItem */
|
|
21
22
|
/** @typedef {InheritanceItem[]} Inheritance */
|
|
22
23
|
|
|
23
|
-
/** @typedef {NormalModuleCreateData & { cssLayer: CssLayer, supports: Supports, media: Media, inheritance?: Inheritance }} CSSModuleCreateData */
|
|
24
|
+
/** @typedef {NormalModuleCreateData & { cssLayer: CssLayer, supports: Supports, media: Media, inheritance?: Inheritance, exportType?: CssParserExportType }} CSSModuleCreateData */
|
|
24
25
|
|
|
25
26
|
class CssModule extends NormalModule {
|
|
26
27
|
/**
|
|
@@ -38,6 +39,8 @@ class CssModule extends NormalModule {
|
|
|
38
39
|
this.media = options.media;
|
|
39
40
|
/** @type {CSSModuleCreateData['inheritance']} */
|
|
40
41
|
this.inheritance = options.inheritance;
|
|
42
|
+
/** @type {CSSModuleCreateData['exportType']} */
|
|
43
|
+
this.exportType = options.exportType;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -69,6 +72,10 @@ class CssModule extends NormalModule {
|
|
|
69
72
|
identifier += `|${inheritance.join("|")}`;
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
if (this.exportType) {
|
|
76
|
+
identifier += `|${this.exportType}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
// We generate extra code for HMR, so we need to invalidate the module
|
|
73
80
|
if (this.hot) {
|
|
74
81
|
identifier += `|${this.hot}`;
|
|
@@ -98,6 +105,10 @@ class CssModule extends NormalModule {
|
|
|
98
105
|
identifier += ` (media: ${this.media})`;
|
|
99
106
|
}
|
|
100
107
|
|
|
108
|
+
if (this.exportType) {
|
|
109
|
+
identifier += ` (exportType: ${this.exportType})`;
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
return identifier;
|
|
102
113
|
}
|
|
103
114
|
|
|
@@ -115,6 +126,7 @@ class CssModule extends NormalModule {
|
|
|
115
126
|
this.supports = m.supports;
|
|
116
127
|
this.media = m.media;
|
|
117
128
|
this.inheritance = m.inheritance;
|
|
129
|
+
this.exportType = m.exportType;
|
|
118
130
|
}
|
|
119
131
|
|
|
120
132
|
/**
|
|
@@ -126,6 +138,7 @@ class CssModule extends NormalModule {
|
|
|
126
138
|
write(this.supports);
|
|
127
139
|
write(this.media);
|
|
128
140
|
write(this.inheritance);
|
|
141
|
+
write(this.exportType);
|
|
129
142
|
super.serialize(context);
|
|
130
143
|
}
|
|
131
144
|
|
|
@@ -155,7 +168,8 @@ class CssModule extends NormalModule {
|
|
|
155
168
|
supports: /** @type {EXPECTED_ANY} */ (null),
|
|
156
169
|
media: /** @type {EXPECTED_ANY} */ (null),
|
|
157
170
|
inheritance: /** @type {EXPECTED_ANY} */ (null),
|
|
158
|
-
extractSourceMap: /** @type {EXPECTED_ANY} */ (null)
|
|
171
|
+
extractSourceMap: /** @type {EXPECTED_ANY} */ (null),
|
|
172
|
+
exportType: /** @type {EXPECTED_ANY} */ (null)
|
|
159
173
|
});
|
|
160
174
|
obj.deserialize(context);
|
|
161
175
|
return obj;
|
|
@@ -170,6 +184,7 @@ class CssModule extends NormalModule {
|
|
|
170
184
|
this.supports = read();
|
|
171
185
|
this.media = read();
|
|
172
186
|
this.inheritance = read();
|
|
187
|
+
this.exportType = read();
|
|
173
188
|
super.deserialize(context);
|
|
174
189
|
}
|
|
175
190
|
}
|
package/lib/Dependency.js
CHANGED
|
@@ -87,7 +87,7 @@ const memoize = require("./util/memoize");
|
|
|
87
87
|
|
|
88
88
|
/** @typedef {(moduleGraphConnection: ModuleGraphConnection, runtime: RuntimeSpec) => ConnectionState} GetConditionFn */
|
|
89
89
|
|
|
90
|
-
const TRANSITIVE = Symbol("transitive");
|
|
90
|
+
const TRANSITIVE = /** @type {symbol} */ (Symbol("transitive"));
|
|
91
91
|
|
|
92
92
|
const getIgnoredModule = memoize(() => {
|
|
93
93
|
const RawModule = require("./RawModule");
|