webpack 5.85.1 → 5.87.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 -2
- package/lib/APIPlugin.js +150 -99
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +35 -17
- package/lib/ChunkGroup.js +11 -6
- package/lib/Compiler.js +4 -3
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +57 -29
- package/lib/ContextModule.js +4 -2
- package/lib/ContextModuleFactory.js +1 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/DllModule.js +6 -0
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/ExternalModule.js +15 -8
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/Module.js +7 -1
- package/lib/ModuleDependencyError.js +4 -2
- package/lib/ModuleDependencyWarning.js +4 -2
- package/lib/ModuleGraph.js +31 -24
- package/lib/ModuleGraphConnection.js +19 -6
- package/lib/ModuleInfoHeaderPlugin.js +9 -2
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +7 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/ProgressPlugin.js +71 -15
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +2 -1
- package/lib/RuntimeTemplate.js +20 -2
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackOptionsApply.js +4 -2
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/config/defaults.js +31 -2
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +13 -6
- package/lib/css/CssModulesPlugin.js +42 -14
- package/lib/css/CssParser.js +12 -0
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
- package/lib/dependencies/ImportParserPlugin.js +25 -1
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -0
- package/lib/javascript/BasicEvaluatedExpression.js +23 -15
- package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
- package/lib/javascript/JavascriptModulesPlugin.js +1 -0
- package/lib/javascript/JavascriptParser.js +118 -58
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/json/JsonData.js +2 -2
- package/lib/json/JsonParser.js +25 -12
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/optimize/AggressiveMergingPlugin.js +8 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
- package/lib/optimize/InnerGraph.js +4 -4
- package/lib/optimize/LimitChunkCountPlugin.js +29 -4
- package/lib/optimize/MangleExportsPlugin.js +1 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
- package/lib/optimize/RealContentHashPlugin.js +80 -30
- package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
- package/lib/optimize/RuntimeChunkPlugin.js +9 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
- package/lib/optimize/SplitChunksPlugin.js +71 -31
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +3 -1
- package/lib/rules/BasicEffectRulePlugin.js +4 -0
- package/lib/rules/BasicMatcherRulePlugin.js +5 -0
- package/lib/rules/RuleSetCompiler.js +3 -3
- package/lib/rules/UseEffectRulePlugin.js +6 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +4 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -1
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +4 -1
- package/lib/runtime/CompatRuntimeModule.js +6 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +4 -1
- package/lib/runtime/CreateScriptRuntimeModule.js +3 -1
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +3 -1
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +4 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +14 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -9
- package/lib/runtime/GetFullHashRuntimeModule.js +3 -2
- package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +3 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +4 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +63 -47
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +4 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +3 -1
- package/lib/runtime/PublicPathRuntimeModule.js +3 -1
- package/lib/runtime/RelativeUrlRuntimeModule.js +4 -1
- package/lib/runtime/RuntimeIdRuntimeModule.js +5 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -1
- package/lib/serialization/BinaryMiddleware.js +143 -1
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/ObjectMiddleware.js +9 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +13 -4
- package/lib/sharing/ProvideSharedDependency.js +11 -0
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +22 -21
- package/lib/sharing/ShareRuntimeModule.js +11 -4
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/sharing/utils.js +32 -5
- package/lib/util/AsyncQueue.js +4 -2
- package/lib/util/ParallelismFactorCalculator.js +10 -0
- package/lib/util/Semaphore.js +1 -1
- package/lib/util/createHash.js +30 -9
- package/lib/util/deprecation.js +10 -3
- package/lib/util/deterministicGrouping.js +50 -11
- package/lib/util/findGraphRoots.js +4 -2
- package/lib/util/memoize.js +3 -3
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +14 -1
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -6
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyParser.js +6 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -3
- package/lib/webpack.js +11 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +14 -15
- package/module.d.ts +1 -0
- package/package.json +4 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +51 -5
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +476 -218
package/lib/webpack.js
CHANGED
@@ -61,7 +61,10 @@ const createMultiCompiler = (childOptions, options) => {
|
|
61
61
|
const createCompiler = rawOptions => {
|
62
62
|
const options = getNormalizedWebpackOptions(rawOptions);
|
63
63
|
applyWebpackOptionsBaseDefaults(options);
|
64
|
-
const compiler = new Compiler(
|
64
|
+
const compiler = new Compiler(
|
65
|
+
/** @type {string} */ (options.context),
|
66
|
+
options
|
67
|
+
);
|
65
68
|
new NodeEnvironmentPlugin({
|
66
69
|
infrastructureLogging: options.infrastructureLogging
|
67
70
|
}).apply(compiler);
|
@@ -69,7 +72,7 @@ const createCompiler = rawOptions => {
|
|
69
72
|
for (const plugin of options.plugins) {
|
70
73
|
if (typeof plugin === "function") {
|
71
74
|
plugin.call(compiler, compiler);
|
72
|
-
} else {
|
75
|
+
} else if (plugin) {
|
73
76
|
plugin.apply(compiler);
|
74
77
|
}
|
75
78
|
}
|
@@ -96,6 +99,11 @@ const createCompiler = rawOptions => {
|
|
96
99
|
* @returns {MultiCompiler} the multi compiler object
|
97
100
|
*/
|
98
101
|
|
102
|
+
/**
|
103
|
+
* @template T
|
104
|
+
* @param {Array<T> | T} options options
|
105
|
+
* @returns {Array<T>} array of options
|
106
|
+
*/
|
99
107
|
const asArray = options =>
|
100
108
|
Array.isArray(options) ? Array.from(options) : [options];
|
101
109
|
|
@@ -117,6 +125,7 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
|
117
125
|
}
|
118
126
|
/** @type {MultiCompiler|Compiler} */
|
119
127
|
let compiler;
|
128
|
+
/** @type {boolean | undefined} */
|
120
129
|
let watch = false;
|
121
130
|
/** @type {WatchOptions|WatchOptions[]} */
|
122
131
|
let watchOptions;
|
@@ -16,6 +16,8 @@ const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
16
16
|
const { getUndoPath } = require("../util/identifier");
|
17
17
|
|
18
18
|
/** @typedef {import("../Chunk")} Chunk */
|
19
|
+
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
20
|
+
/** @typedef {import("../Compilation")} Compilation */
|
19
21
|
|
20
22
|
class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
21
23
|
/**
|
@@ -38,8 +40,9 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
38
40
|
if (options && options.baseUri) {
|
39
41
|
return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
|
40
42
|
}
|
41
|
-
const
|
42
|
-
|
43
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
44
|
+
const outputName = compilation.getPath(
|
45
|
+
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
43
46
|
{
|
44
47
|
chunk,
|
45
48
|
contentHashType: "javascript"
|
@@ -47,7 +50,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
47
50
|
);
|
48
51
|
const rootOutputDir = getUndoPath(
|
49
52
|
outputName,
|
50
|
-
/** @type {string} */ (
|
53
|
+
/** @type {string} */ (compilation.outputOptions.path),
|
51
54
|
false
|
52
55
|
);
|
53
56
|
return `${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
|
@@ -59,16 +62,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
59
62
|
* @returns {string} runtime code
|
60
63
|
*/
|
61
64
|
generate() {
|
62
|
-
const {
|
63
|
-
chunk,
|
64
|
-
chunkGraph,
|
65
|
-
compilation: {
|
66
|
-
runtimeTemplate,
|
67
|
-
outputOptions: { chunkLoadingGlobal, hotUpdateGlobal }
|
68
|
-
},
|
69
|
-
_withCreateScriptUrl: withCreateScriptUrl
|
70
|
-
} = this;
|
71
|
-
const globalObject = runtimeTemplate.globalObject;
|
65
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
72
66
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
73
67
|
const withBaseURI = this.runtimeRequirements.has(RuntimeGlobals.baseURI);
|
74
68
|
const withLoading = this.runtimeRequirements.has(
|
@@ -80,9 +74,12 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
80
74
|
const withHmrManifest = this.runtimeRequirements.has(
|
81
75
|
RuntimeGlobals.hmrDownloadManifest
|
82
76
|
);
|
77
|
+
const globalObject = compilation.runtimeTemplate.globalObject;
|
83
78
|
const chunkLoadingGlobalExpr = `${globalObject}[${JSON.stringify(
|
84
|
-
chunkLoadingGlobal
|
79
|
+
compilation.outputOptions.chunkLoadingGlobal
|
85
80
|
)}]`;
|
81
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
82
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
86
83
|
const hasJsMatcher = compileBooleanMatcher(
|
87
84
|
chunkGraph.getChunkConditionMap(chunk, chunkHasJs)
|
88
85
|
);
|
@@ -91,6 +88,8 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
91
88
|
const stateExpression = withHmr
|
92
89
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_importScripts`
|
93
90
|
: undefined;
|
91
|
+
const runtimeTemplate = compilation.runtimeTemplate;
|
92
|
+
const { _withCreateScriptUrl: withCreateScriptUrl } = this;
|
94
93
|
|
95
94
|
return Template.asString([
|
96
95
|
withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
|
@@ -169,7 +168,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
169
168
|
Template.indent([
|
170
169
|
"var success = false;",
|
171
170
|
`${globalObject}[${JSON.stringify(
|
172
|
-
hotUpdateGlobal
|
171
|
+
compilation.outputOptions.hotUpdateGlobal
|
173
172
|
)}] = ${runtimeTemplate.basicFunction("_, moreModules, runtime", [
|
174
173
|
"for(var moduleId in moreModules) {",
|
175
174
|
Template.indent([
|
package/module.d.ts
CHANGED
@@ -174,6 +174,7 @@ interface ImportMeta {
|
|
174
174
|
exclude?: RegExp;
|
175
175
|
preload?: boolean | number;
|
176
176
|
prefetch?: boolean | number;
|
177
|
+
fetchPriority?: "low" | "high" | "auto";
|
177
178
|
chunkName?: string;
|
178
179
|
exports?: string | string[][];
|
179
180
|
mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.87.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"acorn-import-assertions": "^1.9.0",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
17
|
-
"enhanced-resolve": "^5.
|
17
|
+
"enhanced-resolve": "^5.15.0",
|
18
18
|
"es-module-lexer": "^1.2.1",
|
19
19
|
"eslint-scope": "5.1.1",
|
20
20
|
"events": "^3.2.0",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"loader-runner": "^4.2.0",
|
25
25
|
"mime-types": "^2.1.27",
|
26
26
|
"neo-async": "^2.6.2",
|
27
|
-
"schema-utils": "^3.
|
27
|
+
"schema-utils": "^3.2.0",
|
28
28
|
"tapable": "^2.1.1",
|
29
29
|
"terser-webpack-plugin": "^5.3.7",
|
30
30
|
"watchpack": "^2.4.0",
|
@@ -97,7 +97,7 @@
|
|
97
97
|
"style-loader": "^2.0.0",
|
98
98
|
"terser": "^5.17.0",
|
99
99
|
"toml": "^3.0.0",
|
100
|
-
"tooling": "webpack/tooling#v1.
|
100
|
+
"tooling": "webpack/tooling#v1.23.0",
|
101
101
|
"ts-loader": "^9.4.2",
|
102
102
|
"typescript": "^5.0.4",
|
103
103
|
"url-loader": "^4.1.0",
|