webpack 5.92.0 → 5.93.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.

Files changed (32) hide show
  1. package/lib/ContextModule.js +4 -2
  2. package/lib/DefinePlugin.js +1 -1
  3. package/lib/NormalModule.js +6 -1
  4. package/lib/UseStrictPlugin.js +8 -1
  5. package/lib/WebpackOptionsApply.js +5 -0
  6. package/lib/css/CssExportsGenerator.js +18 -21
  7. package/lib/css/CssGenerator.js +3 -11
  8. package/lib/css/CssModulesPlugin.js +17 -17
  9. package/lib/dependencies/CssExportDependency.js +72 -9
  10. package/lib/dependencies/CssLocalIdentifierDependency.js +67 -20
  11. package/lib/dependencies/HarmonyImportSpecifierDependency.js +2 -2
  12. package/lib/esm/ModuleChunkFormatPlugin.js +8 -9
  13. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -0
  14. package/lib/javascript/CommonJsChunkFormatPlugin.js +7 -9
  15. package/lib/javascript/JavascriptModulesPlugin.js +6 -1
  16. package/lib/library/AssignLibraryPlugin.js +1 -1
  17. package/lib/library/EnableLibraryPlugin.js +10 -1
  18. package/lib/library/ExportPropertyLibraryPlugin.js +8 -2
  19. package/lib/library/ModernModuleLibraryPlugin.js +142 -0
  20. package/lib/optimize/ConcatenatedModule.js +69 -18
  21. package/lib/optimize/ModuleConcatenationPlugin.js +2 -0
  22. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -0
  23. package/lib/sharing/ConsumeSharedModule.js +19 -14
  24. package/lib/sharing/ConsumeSharedRuntimeModule.js +104 -137
  25. package/lib/util/conventions.js +2 -2
  26. package/package.json +3 -3
  27. package/schemas/WebpackOptions.check.js +1 -1
  28. package/schemas/WebpackOptions.json +16 -0
  29. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  30. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
  31. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  32. package/types.d.ts +15 -0
@@ -95,63 +95,39 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
95
95
  versionLtRuntimeCode(runtimeTemplate),
96
96
  rangeToStringRuntimeCode(runtimeTemplate),
97
97
  satisfyRuntimeCode(runtimeTemplate),
98
- `var ensureExistence = ${runtimeTemplate.basicFunction("scopeName, key", [
99
- `var scope = ${RuntimeGlobals.shareScopeMap}[scopeName];`,
100
- `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) throw new Error("Shared module " + key + " doesn't exist in shared scope " + scopeName);`,
101
- "return scope;"
98
+ `var exists = ${runtimeTemplate.basicFunction("scope, key", [
99
+ `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key);`
100
+ ])}`,
101
+ `var get = ${runtimeTemplate.basicFunction("entry", [
102
+ "entry.loaded = 1;",
103
+ "return entry.get()"
102
104
  ])};`,
103
- `var findVersion = ${runtimeTemplate.basicFunction("scope, key", [
104
- "var versions = scope[key];",
105
- `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
106
- "a, b",
107
- ["return !a || versionLt(a, b) ? b : a;"]
108
- )}, 0);`,
109
- "return key && versions[key]"
105
+ `var eagerOnly = ${runtimeTemplate.basicFunction("versions", [
106
+ `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
107
+ "filtered, version",
108
+ Template.indent([
109
+ "if (versions[version].eager) {",
110
+ Template.indent(["filtered[version] = versions[version];"]),
111
+ "}",
112
+ "return filtered;"
113
+ ])
114
+ )}, {});`
110
115
  ])};`,
111
- `var findSingletonVersionKey = ${runtimeTemplate.basicFunction(
112
- "scope, key",
116
+ `var findLatestVersion = ${runtimeTemplate.basicFunction(
117
+ "scope, key, eager",
113
118
  [
114
- "var versions = scope[key];",
115
- `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
119
+ "var versions = eager ? eagerOnly(scope[key]) : scope[key];",
120
+ `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
116
121
  "a, b",
117
- ["return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;"]
118
- )}, 0);`
119
- ]
120
- )};`,
121
- `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(
122
- "scope, key, version, requiredVersion",
123
- [
124
- `return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"`
125
- ]
126
- )};`,
127
- `var getSingleton = ${runtimeTemplate.basicFunction(
128
- "scope, scopeName, key, requiredVersion",
129
- [
130
- "var version = findSingletonVersionKey(scope, key);",
131
- "return get(scope[key][version]);"
132
- ]
133
- )};`,
134
- `var getSingletonVersion = ${runtimeTemplate.basicFunction(
135
- "scope, scopeName, key, requiredVersion",
136
- [
137
- "var version = findSingletonVersionKey(scope, key);",
138
- "if (!satisfy(requiredVersion, version)) warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));",
139
- "return get(scope[key][version]);"
140
- ]
141
- )};`,
142
- `var getStrictSingletonVersion = ${runtimeTemplate.basicFunction(
143
- "scope, scopeName, key, requiredVersion",
144
- [
145
- "var version = findSingletonVersionKey(scope, key);",
146
- "if (!satisfy(requiredVersion, version)) " +
147
- "throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));",
148
- "return get(scope[key][version]);"
122
+ ["return !a || versionLt(a, b) ? b : a;"]
123
+ )}, 0);`,
124
+ "return key && versions[key];"
149
125
  ]
150
126
  )};`,
151
- `var findValidVersion = ${runtimeTemplate.basicFunction(
152
- "scope, key, requiredVersion",
127
+ `var findSatisfyingVersion = ${runtimeTemplate.basicFunction(
128
+ "scope, key, requiredVersion, eager",
153
129
  [
154
- "var versions = scope[key];",
130
+ "var versions = eager ? eagerOnly(scope[key]) : scope[key];",
155
131
  `var key = Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
156
132
  "a, b",
157
133
  [
@@ -162,136 +138,127 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
162
138
  "return key && versions[key]"
163
139
  ]
164
140
  )};`,
141
+ `var findSingletonVersionKey = ${runtimeTemplate.basicFunction(
142
+ "scope, key, eager",
143
+ [
144
+ "var versions = eager ? eagerOnly(scope[key]) : scope[key];",
145
+ `return Object.keys(versions).reduce(${runtimeTemplate.basicFunction(
146
+ "a, b",
147
+ ["return !a || (!versions[a].loaded && versionLt(a, b)) ? b : a;"]
148
+ )}, 0);`
149
+ ]
150
+ )};`,
151
+ `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(
152
+ "scope, key, version, requiredVersion",
153
+ [
154
+ 'return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"'
155
+ ]
156
+ )};`,
165
157
  `var getInvalidVersionMessage = ${runtimeTemplate.basicFunction(
166
- "scope, scopeName, key, requiredVersion",
158
+ "scope, scopeName, key, requiredVersion, eager",
167
159
  [
168
160
  "var versions = scope[key];",
169
- 'return "No satisfying version (" + rangeToString(requiredVersion) + ") of shared module " + key + " found in shared scope " + scopeName + ".\\n" +',
161
+ 'return "No satisfying version (" + rangeToString(requiredVersion) + ")" + (eager ? " for eager consumption" : "") + " of shared module " + key + " found in shared scope " + scopeName + ".\\n" +',
170
162
  `\t"Available versions: " + Object.keys(versions).map(${runtimeTemplate.basicFunction(
171
163
  "key",
172
164
  ['return key + " from " + versions[key].from;']
173
165
  )}).join(", ");`
174
166
  ]
175
167
  )};`,
176
- `var getValidVersion = ${runtimeTemplate.basicFunction(
177
- "scope, scopeName, key, requiredVersion",
178
- [
179
- "var entry = findValidVersion(scope, key, requiredVersion);",
180
- "if(entry) return get(entry);",
181
- "throw new Error(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));"
182
- ]
183
- )};`,
184
- `var warn = ${
168
+ `var fail = ${runtimeTemplate.basicFunction("msg", [
169
+ "throw new Error(msg);"
170
+ ])}`,
171
+ `var failAsNotExist = ${runtimeTemplate.basicFunction("scopeName, key", [
172
+ 'return fail("Shared module " + key + " doesn\'t exist in shared scope " + scopeName);'
173
+ ])}`,
174
+ `var warn = /*#__PURE__*/ ${
185
175
  compilation.outputOptions.ignoreBrowserWarnings
186
176
  ? runtimeTemplate.basicFunction("", "")
187
177
  : runtimeTemplate.basicFunction("msg", [
188
178
  'if (typeof console !== "undefined" && console.warn) console.warn(msg);'
189
179
  ])
190
180
  };`,
191
- `var warnInvalidVersion = ${runtimeTemplate.basicFunction(
192
- "scope, scopeName, key, requiredVersion",
193
- [
194
- "warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion));"
195
- ]
196
- )};`,
197
- `var get = ${runtimeTemplate.basicFunction("entry", [
198
- "entry.loaded = 1;",
199
- "return entry.get()"
200
- ])};`,
201
181
  `var init = ${runtimeTemplate.returningFunction(
202
182
  Template.asString([
203
- "function(scopeName, a, b, c) {",
183
+ "function(scopeName, key, eager, c, d) {",
204
184
  Template.indent([
205
185
  `var promise = ${RuntimeGlobals.initializeSharing}(scopeName);`,
206
- `if (promise && promise.then) return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c));`,
207
- `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], a, b, c);`
186
+ // if we require eager shared, we expect it to be already loaded before it requested, no need to wait the whole scope loaded.
187
+ "if (promise && promise.then && !eager) { ",
188
+ Template.indent([
189
+ `return promise.then(fn.bind(fn, scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], key, false, c, d));`
190
+ ]),
191
+ "}",
192
+ `return fn(scopeName, ${RuntimeGlobals.shareScopeMap}[scopeName], key, eager, c, d);`
208
193
  ]),
209
194
  "}"
210
195
  ]),
211
196
  "fn"
212
197
  )};`,
213
198
  "",
199
+ `var useFallback = ${runtimeTemplate.basicFunction(
200
+ "scopeName, key, fallback",
201
+ ["return fallback ? fallback() : failAsNotExist(scopeName, key);"]
202
+ )}`,
214
203
  `var load = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
215
- "scopeName, scope, key",
204
+ "scopeName, scope, key, eager, fallback",
216
205
  [
217
- "ensureExistence(scopeName, key);",
218
- "return get(findVersion(scope, key));"
206
+ "if (!exists(scope, key)) return useFallback(scopeName, key, fallback);",
207
+ "return get(findLatestVersion(scope, key, eager));"
219
208
  ]
220
209
  )});`,
221
- `var loadFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
222
- "scopeName, scope, key, fallback",
210
+ `var loadVersion = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
211
+ "scopeName, scope, key, eager, requiredVersion, fallback",
223
212
  [
224
- `return scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) ? get(findVersion(scope, key)) : fallback();`
213
+ "if (!exists(scope, key)) return useFallback(scopeName, key, fallback);",
214
+ "var satisfyingVersion = findSatisfyingVersion(scope, key, requiredVersion, eager);",
215
+ "if (satisfyingVersion) return get(satisfyingVersion);",
216
+ "warn(getInvalidVersionMessage(scope, scopeName, key, requiredVersion, eager))",
217
+ "return get(findLatestVersion(scope, key, eager));"
225
218
  ]
226
219
  )});`,
227
- `var loadVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
228
- "scopeName, scope, key, version",
220
+ `var loadStrictVersion = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
221
+ "scopeName, scope, key, eager, requiredVersion, fallback",
229
222
  [
230
- "ensureExistence(scopeName, key);",
231
- "return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));"
223
+ "if (!exists(scope, key)) return useFallback(scopeName, key, fallback);",
224
+ "var satisfyingVersion = findSatisfyingVersion(scope, key, requiredVersion, eager);",
225
+ "if (satisfyingVersion) return get(satisfyingVersion);",
226
+ "if (fallback) return fallback();",
227
+ "fail(getInvalidVersionMessage(scope, scopeName, key, requiredVersion, eager));"
232
228
  ]
233
229
  )});`,
234
230
  `var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
235
- "scopeName, scope, key",
236
- [
237
- "ensureExistence(scopeName, key);",
238
- "return getSingleton(scope, scopeName, key);"
239
- ]
240
- )});`,
241
- `var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
242
- "scopeName, scope, key, version",
243
- [
244
- "ensureExistence(scopeName, key);",
245
- "return getSingletonVersion(scope, scopeName, key, version);"
246
- ]
247
- )});`,
248
- `var loadStrictVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
249
- "scopeName, scope, key, version",
231
+ "scopeName, scope, key, eager, fallback",
250
232
  [
251
- "ensureExistence(scopeName, key);",
252
- "return getValidVersion(scope, scopeName, key, version);"
253
- ]
254
- )});`,
255
- `var loadStrictSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
256
- "scopeName, scope, key, version",
257
- [
258
- "ensureExistence(scopeName, key);",
259
- "return getStrictSingletonVersion(scope, scopeName, key, version);"
260
- ]
261
- )});`,
262
- `var loadVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
263
- "scopeName, scope, key, version, fallback",
264
- [
265
- `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
266
- "return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));"
267
- ]
268
- )});`,
269
- `var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
270
- "scopeName, scope, key, fallback",
271
- [
272
- `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
273
- "return getSingleton(scope, scopeName, key);"
274
- ]
275
- )});`,
276
- `var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
277
- "scopeName, scope, key, version, fallback",
278
- [
279
- `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
280
- "return getSingletonVersion(scope, scopeName, key, version);"
233
+ "if (!exists(scope, key)) return useFallback(scopeName, key, fallback);",
234
+ "var version = findSingletonVersionKey(scope, key, eager);",
235
+ "return get(scope[key][version]);"
281
236
  ]
282
237
  )});`,
283
- `var loadStrictVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
284
- "scopeName, scope, key, version, fallback",
238
+ `var loadSingletonVersion = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
239
+ "scopeName, scope, key, eager, requiredVersion, fallback",
285
240
  [
286
- `var entry = scope && ${RuntimeGlobals.hasOwnProperty}(scope, key) && findValidVersion(scope, key, version);`,
287
- `return entry ? get(entry) : fallback();`
241
+ "if (!exists(scope, key)) return useFallback(scopeName, key, fallback);",
242
+ "var version = findSingletonVersionKey(scope, key, eager);",
243
+ "if (!satisfy(requiredVersion, version)) {",
244
+ Template.indent([
245
+ "warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));"
246
+ ]),
247
+ "}",
248
+ "return get(scope[key][version]);"
288
249
  ]
289
250
  )});`,
290
- `var loadStrictSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
291
- "scopeName, scope, key, version, fallback",
251
+ `var loadStrictSingletonVersion = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
252
+ "scopeName, scope, key, eager, requiredVersion, fallback",
292
253
  [
293
- `if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
294
- "return getStrictSingletonVersion(scope, scopeName, key, version);"
254
+ "if (!exists(scope, key)) return useFallback(scopeName, key, fallback);",
255
+ "var version = findSingletonVersionKey(scope, key, eager);",
256
+ "if (!satisfy(requiredVersion, version)) {",
257
+ Template.indent([
258
+ "fail(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));"
259
+ ]),
260
+ "}",
261
+ "return get(scope[key][version]);"
295
262
  ]
296
263
  )});`,
297
264
  "var installedModules = {};",
@@ -10,7 +10,7 @@
10
10
  /**
11
11
  * @param {string} input input
12
12
  * @param {CssGeneratorExportsConvention | undefined} convention convention
13
- * @returns {Set<string>} results
13
+ * @returns {string[]} results
14
14
  */
15
15
  exports.cssExportConvention = (input, convention) => {
16
16
  const set = new Set();
@@ -42,7 +42,7 @@ exports.cssExportConvention = (input, convention) => {
42
42
  }
43
43
  }
44
44
  }
45
- return set;
45
+ return Array.from(set);
46
46
  };
47
47
 
48
48
  // Copy from css-loader
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.92.0",
3
+ "version": "5.93.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",
@@ -38,7 +38,7 @@
38
38
  "devDependencies": {
39
39
  "@babel/core": "^7.24.7",
40
40
  "@babel/preset-react": "^7.24.7",
41
- "@eslint/js": "^9.4.0",
41
+ "@eslint/js": "^9.5.0",
42
42
  "@types/glob-to-regexp": "^0.4.4",
43
43
  "@types/jest": "^29.5.11",
44
44
  "@types/mime-types": "^2.1.4",
@@ -56,7 +56,7 @@
56
56
  "date-fns": "^3.2.0",
57
57
  "es5-ext": "^0.10.53",
58
58
  "es6-promise-polyfill": "^1.2.0",
59
- "eslint": "^9.4.0",
59
+ "eslint": "^9.5.0",
60
60
  "eslint-config-prettier": "^9.1.0",
61
61
  "eslint-plugin-jest": "^28.6.0",
62
62
  "eslint-plugin-jsdoc": "^48.2.9",