webpack 5.66.0 → 5.69.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (97) hide show
  1. package/README.md +1 -1
  2. package/lib/APIPlugin.js +33 -0
  3. package/lib/Cache.js +1 -1
  4. package/lib/CacheFacade.js +2 -2
  5. package/lib/ChunkGraph.js +1 -2
  6. package/lib/CleanPlugin.js +1 -1
  7. package/lib/Compilation.js +14 -9
  8. package/lib/Compiler.js +57 -3
  9. package/lib/ContextModule.js +21 -17
  10. package/lib/DelegatedModule.js +1 -1
  11. package/lib/DependencyTemplates.js +1 -1
  12. package/lib/DllModule.js +1 -1
  13. package/lib/EvalDevToolModulePlugin.js +16 -1
  14. package/lib/EvalSourceMapDevToolPlugin.js +18 -1
  15. package/lib/ExportsInfo.js +4 -4
  16. package/lib/ExternalModule.js +1 -1
  17. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  18. package/lib/FileSystemInfo.js +29 -25
  19. package/lib/HookWebpackError.js +1 -1
  20. package/lib/Module.js +1 -3
  21. package/lib/MultiCompiler.js +1 -1
  22. package/lib/MultiWatching.js +1 -1
  23. package/lib/NormalModule.js +6 -4
  24. package/lib/NormalModuleFactory.js +25 -27
  25. package/lib/ProgressPlugin.js +1 -1
  26. package/lib/RawModule.js +1 -1
  27. package/lib/RuntimeGlobals.js +18 -0
  28. package/lib/RuntimeModule.js +1 -1
  29. package/lib/RuntimePlugin.js +28 -3
  30. package/lib/RuntimeTemplate.js +1 -1
  31. package/lib/TemplatedPathPlugin.js +48 -23
  32. package/lib/Watching.js +1 -1
  33. package/lib/WebpackOptionsApply.js +1 -1
  34. package/lib/asset/AssetGenerator.js +65 -26
  35. package/lib/asset/AssetModulesPlugin.js +3 -0
  36. package/lib/asset/RawDataUrlModule.js +8 -5
  37. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
  38. package/lib/buildChunkGraph.js +1 -1
  39. package/lib/cache/ResolverCachePlugin.js +1 -1
  40. package/lib/cli.js +44 -3
  41. package/lib/config/defaults.js +30 -7
  42. package/lib/config/normalization.js +5 -0
  43. package/lib/container/ContainerEntryModule.js +4 -2
  44. package/lib/container/FallbackModule.js +4 -4
  45. package/lib/container/RemoteModule.js +4 -2
  46. package/lib/css/CssExportsGenerator.js +139 -0
  47. package/lib/css/CssGenerator.js +3 -0
  48. package/lib/css/CssLoadingRuntimeModule.js +201 -154
  49. package/lib/css/CssModulesPlugin.js +22 -4
  50. package/lib/debug/ProfilingPlugin.js +15 -14
  51. package/lib/dependencies/ContextElementDependency.js +8 -2
  52. package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
  53. package/lib/dependencies/ExportsInfoDependency.js +6 -0
  54. package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
  55. package/lib/dependencies/ImportMetaPlugin.js +22 -3
  56. package/lib/dependencies/LoaderPlugin.js +2 -2
  57. package/lib/hmr/LazyCompilationPlugin.js +45 -21
  58. package/lib/hmr/lazyCompilationBackend.js +1 -1
  59. package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
  60. package/lib/ids/HashedModuleIdsPlugin.js +9 -12
  61. package/lib/ids/IdHelpers.js +24 -10
  62. package/lib/ids/NamedModuleIdsPlugin.js +6 -9
  63. package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
  64. package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
  65. package/lib/ids/SyncModuleIdsPlugin.js +140 -0
  66. package/lib/index.js +10 -0
  67. package/lib/javascript/JavascriptModulesPlugin.js +27 -2
  68. package/lib/javascript/StartupHelpers.js +3 -2
  69. package/lib/library/AssignLibraryPlugin.js +8 -2
  70. package/lib/node/NodeTargetPlugin.js +1 -0
  71. package/lib/optimize/ConcatenatedModule.js +11 -5
  72. package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
  73. package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
  74. package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
  75. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
  76. package/lib/schemes/HttpUriPlugin.js +32 -11
  77. package/lib/serialization/FileMiddleware.js +44 -9
  78. package/lib/sharing/ConsumeSharedModule.js +4 -2
  79. package/lib/sharing/ProvideSharedModule.js +4 -2
  80. package/lib/sharing/utils.js +1 -1
  81. package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
  82. package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
  83. package/lib/util/ArrayHelpers.js +18 -4
  84. package/lib/util/AsyncQueue.js +1 -1
  85. package/lib/util/compileBooleanMatcher.js +1 -1
  86. package/lib/util/deterministicGrouping.js +1 -1
  87. package/lib/util/identifier.js +65 -44
  88. package/lib/util/nonNumericOnlyHash.js +22 -0
  89. package/lib/util/semver.js +17 -10
  90. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
  91. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
  92. package/package.json +14 -21
  93. package/schemas/WebpackOptions.check.js +1 -1
  94. package/schemas/WebpackOptions.json +47 -6
  95. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  96. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  97. package/types.d.ts +207 -60
@@ -12,9 +12,11 @@ const Generator = require("../Generator");
12
12
  const RuntimeGlobals = require("../RuntimeGlobals");
13
13
  const createHash = require("../util/createHash");
14
14
  const { makePathsRelative } = require("../util/identifier");
15
+ const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
15
16
 
16
17
  /** @typedef {import("webpack-sources").Source} Source */
17
18
  /** @typedef {import("../../declarations/WebpackOptions").AssetGeneratorOptions} AssetGeneratorOptions */
19
+ /** @typedef {import("../../declarations/WebpackOptions").AssetModuleOutputPath} AssetModuleOutputPath */
18
20
  /** @typedef {import("../../declarations/WebpackOptions").RawPublicPath} RawPublicPath */
19
21
  /** @typedef {import("../Compilation")} Compilation */
20
22
  /** @typedef {import("../Compiler")} Compiler */
@@ -74,6 +76,41 @@ const mergeRelatedInfo = (a, b) => {
74
76
  return result;
75
77
  };
76
78
 
79
+ const encodeDataUri = (encoding, source) => {
80
+ let encodedContent;
81
+
82
+ switch (encoding) {
83
+ case "base64": {
84
+ encodedContent = source.buffer().toString("base64");
85
+ break;
86
+ }
87
+ case false: {
88
+ const content = source.source();
89
+
90
+ if (typeof content !== "string") {
91
+ encodedContent = content.toString("utf-8");
92
+ }
93
+
94
+ encodedContent = encodeURIComponent(encodedContent).replace(
95
+ /[!'()*]/g,
96
+ character => "%" + character.codePointAt(0).toString(16)
97
+ );
98
+ break;
99
+ }
100
+ default:
101
+ throw new Error(`Unsupported encoding '${encoding}'`);
102
+ }
103
+
104
+ return encodedContent;
105
+ };
106
+
107
+ const decodeDataUriContent = (encoding, content) => {
108
+ const isBase64 = encoding === "base64";
109
+ return isBase64
110
+ ? Buffer.from(content, "base64")
111
+ : Buffer.from(decodeURIComponent(content), "ascii");
112
+ };
113
+
77
114
  const JS_TYPES = new Set(["javascript"]);
78
115
  const JS_AND_ASSET_TYPES = new Set(["javascript", "asset"]);
79
116
 
@@ -82,13 +119,15 @@ class AssetGenerator extends Generator {
82
119
  * @param {AssetGeneratorOptions["dataUrl"]=} dataUrlOptions the options for the data url
83
120
  * @param {string=} filename override for output.assetModuleFilename
84
121
  * @param {RawPublicPath=} publicPath override for output.assetModulePublicPath
122
+ * @param {AssetModuleOutputPath=} outputPath the output path for the emitted file which is not included in the runtime import
85
123
  * @param {boolean=} emit generate output asset
86
124
  */
87
- constructor(dataUrlOptions, filename, publicPath, emit) {
125
+ constructor(dataUrlOptions, filename, publicPath, outputPath, emit) {
88
126
  super();
89
127
  this.dataUrlOptions = dataUrlOptions;
90
128
  this.filename = filename;
91
129
  this.publicPath = publicPath;
130
+ this.outputPath = outputPath;
92
131
  this.emit = emit;
93
132
  }
94
133
 
@@ -158,33 +197,18 @@ class AssetGenerator extends Generator {
158
197
  }
159
198
 
160
199
  let encodedContent;
200
+
161
201
  if (
162
202
  module.resourceResolveData &&
163
- module.resourceResolveData.encoding === encoding
203
+ module.resourceResolveData.encoding === encoding &&
204
+ decodeDataUriContent(
205
+ module.resourceResolveData.encoding,
206
+ module.resourceResolveData.encodedContent
207
+ ).equals(originalSource.buffer())
164
208
  ) {
165
209
  encodedContent = module.resourceResolveData.encodedContent;
166
210
  } else {
167
- switch (encoding) {
168
- case "base64": {
169
- encodedContent = originalSource.buffer().toString("base64");
170
- break;
171
- }
172
- case false: {
173
- const content = originalSource.source();
174
-
175
- if (typeof content !== "string") {
176
- encodedContent = content.toString("utf-8");
177
- }
178
-
179
- encodedContent = encodeURIComponent(encodedContent).replace(
180
- /[!'()*]/g,
181
- character => "%" + character.codePointAt(0).toString(16)
182
- );
183
- break;
184
- }
185
- default:
186
- throw new Error(`Unsupported encoding '${encoding}'`);
187
- }
211
+ encodedContent = encodeDataUri(encoding, originalSource);
188
212
  }
189
213
 
190
214
  encodedSource = `data:${mimeType}${
@@ -192,7 +216,7 @@ class AssetGenerator extends Generator {
192
216
  },${encodedContent}`;
193
217
  }
194
218
  const data = getData();
195
- data.set("url", encodedSource);
219
+ data.set("url", Buffer.from(encodedSource));
196
220
  return new RawSource(
197
221
  `${RuntimeGlobals.module}.exports = ${JSON.stringify(
198
222
  encodedSource
@@ -209,8 +233,8 @@ class AssetGenerator extends Generator {
209
233
  const fullHash = /** @type {string} */ (
210
234
  hash.digest(runtimeTemplate.outputOptions.hashDigest)
211
235
  );
212
- const contentHash = fullHash.slice(
213
- 0,
236
+ const contentHash = nonNumericOnlyHash(
237
+ fullHash,
214
238
  runtimeTemplate.outputOptions.hashDigestLength
215
239
  );
216
240
  module.buildInfo.fullContentHash = fullHash;
@@ -256,6 +280,21 @@ class AssetGenerator extends Generator {
256
280
  sourceFilename,
257
281
  ...assetInfo
258
282
  };
283
+ if (this.outputPath) {
284
+ const { path: outputPath, info } =
285
+ runtimeTemplate.compilation.getAssetPathWithInfo(
286
+ this.outputPath,
287
+ {
288
+ module,
289
+ runtime,
290
+ filename: sourceFilename,
291
+ chunkGraph,
292
+ contentHash
293
+ }
294
+ );
295
+ assetInfo = mergeAssetInfo(assetInfo, info);
296
+ filename = path.posix.join(outputPath, filename);
297
+ }
259
298
  module.buildInfo.filename = filename;
260
299
  module.buildInfo.assetInfo = assetInfo;
261
300
  if (getData) {
@@ -137,9 +137,11 @@ class AssetModulesPlugin {
137
137
 
138
138
  let filename = undefined;
139
139
  let publicPath = undefined;
140
+ let outputPath = undefined;
140
141
  if (type !== "asset/inline") {
141
142
  filename = generatorOptions.filename;
142
143
  publicPath = generatorOptions.publicPath;
144
+ outputPath = generatorOptions.outputPath;
143
145
  }
144
146
 
145
147
  const AssetGenerator = getAssetGenerator();
@@ -148,6 +150,7 @@ class AssetModulesPlugin {
148
150
  dataUrl,
149
151
  filename,
150
152
  publicPath,
153
+ outputPath,
151
154
  generatorOptions.emit !== false
152
155
  );
153
156
  });
@@ -33,6 +33,7 @@ class RawDataUrlModule extends Module {
33
33
  constructor(url, identifier, readableIdentifier) {
34
34
  super("asset/raw-data-url", null);
35
35
  this.url = url;
36
+ this.urlBuffer = url ? Buffer.from(url) : undefined;
36
37
  this.identifierStr = identifier || this.url;
37
38
  this.readableIdentifierStr = readableIdentifier || this.identifierStr;
38
39
  }
@@ -56,6 +57,7 @@ class RawDataUrlModule extends Module {
56
57
  * @returns {number} the estimated size of the module (must be non-zero)
57
58
  */
58
59
  size(type) {
60
+ if (this.url === undefined) this.url = this.urlBuffer.toString();
59
61
  return Math.max(1, this.url.length);
60
62
  }
61
63
 
@@ -69,7 +71,7 @@ class RawDataUrlModule extends Module {
69
71
 
70
72
  /**
71
73
  * @param {NeedBuildContext} context context info
72
- * @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
74
+ * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
73
75
  * @returns {void}
74
76
  */
75
77
  needBuild(context, callback) {
@@ -97,13 +99,14 @@ class RawDataUrlModule extends Module {
97
99
  * @returns {CodeGenerationResult} result
98
100
  */
99
101
  codeGeneration(context) {
102
+ if (this.url === undefined) this.url = this.urlBuffer.toString();
100
103
  const sources = new Map();
101
104
  sources.set(
102
105
  "javascript",
103
106
  new RawSource(`module.exports = ${JSON.stringify(this.url)};`)
104
107
  );
105
108
  const data = new Map();
106
- data.set("url", this.url);
109
+ data.set("url", this.urlBuffer);
107
110
  const runtimeRequirements = new Set();
108
111
  runtimeRequirements.add(RuntimeGlobals.module);
109
112
  return { sources, runtimeRequirements, data };
@@ -115,14 +118,14 @@ class RawDataUrlModule extends Module {
115
118
  * @returns {void}
116
119
  */
117
120
  updateHash(hash, context) {
118
- hash.update(this.url);
121
+ hash.update(this.urlBuffer);
119
122
  super.updateHash(hash, context);
120
123
  }
121
124
 
122
125
  serialize(context) {
123
126
  const { write } = context;
124
127
 
125
- write(this.url);
128
+ write(this.urlBuffer);
126
129
  write(this.identifierStr);
127
130
  write(this.readableIdentifierStr);
128
131
 
@@ -132,7 +135,7 @@ class RawDataUrlModule extends Module {
132
135
  deserialize(context) {
133
136
  const { read } = context;
134
137
 
135
- this.url = read();
138
+ this.urlBuffer = read();
136
139
  this.identifierStr = read();
137
140
  this.readableIdentifierStr = read();
138
141
 
@@ -30,8 +30,8 @@ class AwaitDependenciesInitFragment extends InitFragment {
30
30
  }
31
31
 
32
32
  merge(other) {
33
- const promises = new Set(this.promises);
34
- for (const p of other.promises) {
33
+ const promises = new Set(other.promises);
34
+ for (const p of this.promises) {
35
35
  promises.add(p);
36
36
  }
37
37
  return new AwaitDependenciesInitFragment(promises);
@@ -51,7 +51,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
51
51
  for (const p of promises) {
52
52
  return Template.asString([
53
53
  `var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${p}]);`,
54
- `${p} = (__webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__)[0];`,
54
+ `${p} = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];`,
55
55
  ""
56
56
  ]);
57
57
  }
@@ -60,7 +60,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
60
60
  // TODO check if destructuring is supported
61
61
  return Template.asString([
62
62
  `var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${sepPromises}]);`,
63
- `([${sepPromises}] = __webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__);`,
63
+ `([${sepPromises}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);`,
64
64
  ""
65
65
  ]);
66
66
  }
@@ -905,7 +905,7 @@ const visitModules = (
905
905
  const module = it.value;
906
906
  if (
907
907
  availableModules.has(module) ||
908
- availableModules.plus.has(m)
908
+ availableModules.plus.has(module)
909
909
  ) {
910
910
  cachedMinAvailableModules.add(module);
911
911
  }
@@ -106,7 +106,7 @@ class ResolverCachePlugin {
106
106
  * @param {Resolver} resolver the resolver
107
107
  * @param {Object} resolveContext context for resolving meta info
108
108
  * @param {Object} request the request info object
109
- * @param {function(Error=, Object=): void} callback callback function
109
+ * @param {function((Error | null)=, Object=): void} callback callback function
110
110
  * @returns {void}
111
111
  */
112
112
  const doRealResolve = (
package/lib/cli.js CHANGED
@@ -37,6 +37,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
37
37
  /**
38
38
  * @typedef {Object} ArgumentConfig
39
39
  * @property {string} description
40
+ * @property {string} [negatedDescription]
40
41
  * @property {string} path
41
42
  * @property {boolean} multiple
42
43
  * @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type
@@ -96,11 +97,42 @@ const getArguments = (schema = webpackSchema) => {
96
97
  */
97
98
  const getDescription = path => {
98
99
  for (const { schema } of path) {
99
- if (schema.cli && schema.cli.helper) continue;
100
+ if (schema.cli) {
101
+ if (schema.cli.helper) continue;
102
+ if (schema.cli.description) return schema.cli.description;
103
+ }
100
104
  if (schema.description) return schema.description;
101
105
  }
102
106
  };
103
107
 
108
+ /**
109
+ *
110
+ * @param {PathItem[]} path path in the schema
111
+ * @returns {string | undefined} negative description
112
+ */
113
+ const getNegatedDescription = path => {
114
+ for (const { schema } of path) {
115
+ if (schema.cli) {
116
+ if (schema.cli.helper) continue;
117
+ if (schema.cli.negatedDescription) return schema.cli.negatedDescription;
118
+ }
119
+ }
120
+ };
121
+
122
+ /**
123
+ *
124
+ * @param {PathItem[]} path path in the schema
125
+ * @returns {string | undefined} reset description
126
+ */
127
+ const getResetDescription = path => {
128
+ for (const { schema } of path) {
129
+ if (schema.cli) {
130
+ if (schema.cli.helper) continue;
131
+ if (schema.cli.resetDescription) return schema.cli.resetDescription;
132
+ }
133
+ }
134
+ };
135
+
104
136
  /**
105
137
  *
106
138
  * @param {any} schemaPart schema
@@ -142,13 +174,17 @@ const getArguments = (schema = webpackSchema) => {
142
174
  const addResetFlag = path => {
143
175
  const schemaPath = path[0].path;
144
176
  const name = pathToArgumentName(`${schemaPath}.reset`);
145
- const description = getDescription(path);
177
+ const description =
178
+ getResetDescription(path) ||
179
+ `Clear all items provided in '${schemaPath}' configuration. ${getDescription(
180
+ path
181
+ )}`;
146
182
  flags[name] = {
147
183
  configs: [
148
184
  {
149
185
  type: "reset",
150
186
  multiple: false,
151
- description: `Clear all items provided in '${schemaPath}' configuration. ${description}`,
187
+ description,
152
188
  path: schemaPath
153
189
  }
154
190
  ],
@@ -167,6 +203,7 @@ const getArguments = (schema = webpackSchema) => {
167
203
  const argConfigBase = schemaToArgumentConfig(path[0].schema);
168
204
  if (!argConfigBase) return 0;
169
205
 
206
+ const negatedDescription = getNegatedDescription(path);
170
207
  const name = pathToArgumentName(path[0].path);
171
208
  /** @type {ArgumentConfig} */
172
209
  const argConfig = {
@@ -176,6 +213,10 @@ const getArguments = (schema = webpackSchema) => {
176
213
  path: path[0].path
177
214
  };
178
215
 
216
+ if (negatedDescription) {
217
+ argConfig.negatedDescription = negatedDescription;
218
+ }
219
+
179
220
  if (!flags[name]) {
180
221
  flags[name] = {
181
222
  configs: [],
@@ -16,6 +16,7 @@ const {
16
16
  } = require("./target");
17
17
 
18
18
  /** @typedef {import("../../declarations/WebpackOptions").CacheOptionsNormalized} CacheOptions */
19
+ /** @typedef {import("../../declarations/WebpackOptions").CssExperimentOptions} CssExperimentOptions */
19
20
  /** @typedef {import("../../declarations/WebpackOptions").EntryDescription} EntryDescription */
20
21
  /** @typedef {import("../../declarations/WebpackOptions").EntryNormalized} Entry */
21
22
  /** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */
@@ -160,7 +161,11 @@ const applyWebpackOptionsDefaults = options => {
160
161
  D(options, "recordsInputPath", false);
161
162
  D(options, "recordsOutputPath", false);
162
163
 
163
- applyExperimentsDefaults(options.experiments, { production, development });
164
+ applyExperimentsDefaults(options.experiments, {
165
+ production,
166
+ development,
167
+ targetProperties
168
+ });
164
169
 
165
170
  const futureDefaults = options.experiments.futureDefaults;
166
171
 
@@ -265,9 +270,13 @@ const applyWebpackOptionsDefaults = options => {
265
270
  * @param {Object} options options
266
271
  * @param {boolean} options.production is production
267
272
  * @param {boolean} options.development is development mode
273
+ * @param {TargetProperties | false} options.targetProperties target properties
268
274
  * @returns {void}
269
275
  */
270
- const applyExperimentsDefaults = (experiments, { production, development }) => {
276
+ const applyExperimentsDefaults = (
277
+ experiments,
278
+ { production, development, targetProperties }
279
+ ) => {
271
280
  D(experiments, "futureDefaults", false);
272
281
  D(experiments, "backCompat", !experiments.futureDefaults);
273
282
  D(experiments, "topLevelAwait", experiments.futureDefaults);
@@ -278,12 +287,20 @@ const applyExperimentsDefaults = (experiments, { production, development }) => {
278
287
  D(experiments, "lazyCompilation", undefined);
279
288
  D(experiments, "buildHttp", undefined);
280
289
  D(experiments, "cacheUnaffected", experiments.futureDefaults);
281
- D(experiments, "css", experiments.futureDefaults);
290
+ F(experiments, "css", () => (experiments.futureDefaults ? {} : undefined));
282
291
 
283
292
  if (typeof experiments.buildHttp === "object") {
284
293
  D(experiments.buildHttp, "frozen", production);
285
294
  D(experiments.buildHttp, "upgrade", false);
286
295
  }
296
+
297
+ if (typeof experiments.css === "object") {
298
+ D(
299
+ experiments.css,
300
+ "exportsOnly",
301
+ !targetProperties || !targetProperties.document
302
+ );
303
+ }
287
304
  };
288
305
 
289
306
  /**
@@ -452,6 +469,7 @@ const applyJavascriptParserOptionsDefaults = (
452
469
  D(parserOptions, "wrappedContextRecursive", true);
453
470
  D(parserOptions, "wrappedContextCritical", false);
454
471
  D(parserOptions, "strictThisContextOnImports", false);
472
+ D(parserOptions, "importMeta", true);
455
473
  if (futureDefaults) D(parserOptions, "exportsPresence", "error");
456
474
  };
457
475
 
@@ -461,7 +479,7 @@ const applyJavascriptParserOptionsDefaults = (
461
479
  * @param {boolean} options.cache is caching enabled
462
480
  * @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
463
481
  * @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
464
- * @param {boolean} options.css is css enabled
482
+ * @param {CssExperimentOptions} options.css is css enabled
465
483
  * @param {boolean} options.futureDefaults is future defaults enabled
466
484
  * @returns {void}
467
485
  */
@@ -889,6 +907,7 @@ const applyOutputDefaults = (
889
907
  D(output, "strictModuleExceptionHandling", false);
890
908
 
891
909
  const optimistic = v => v || v === undefined;
910
+ const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
892
911
  F(
893
912
  output.environment,
894
913
  "arrowFunction",
@@ -902,8 +921,12 @@ const applyOutputDefaults = (
902
921
  );
903
922
  F(output.environment, "forOf", () => tp && optimistic(tp.forOf));
904
923
  F(output.environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
905
- F(output.environment, "dynamicImport", () => tp && tp.dynamicImport);
906
- F(output.environment, "module", () => tp && tp.module);
924
+ F(output.environment, "dynamicImport", () =>
925
+ conditionallyOptimistic(tp && tp.dynamicImport, output.module)
926
+ );
927
+ F(output.environment, "module", () =>
928
+ conditionallyOptimistic(tp && tp.module, output.module)
929
+ );
907
930
 
908
931
  const { trustedTypes } = output;
909
932
  if (trustedTypes) {
@@ -1083,7 +1106,7 @@ const applyPerformanceDefaults = (performance, { production }) => {
1083
1106
  * @param {Object} options options
1084
1107
  * @param {boolean} options.production is production
1085
1108
  * @param {boolean} options.development is development
1086
- * @param {boolean} options.css is css enabled
1109
+ * @param {CssExperimentOptions} options.css is css enabled
1087
1110
  * @param {boolean} options.records using records
1088
1111
  * @returns {void}
1089
1112
  */
@@ -180,6 +180,9 @@ const getNormalizedWebpackOptions = config => {
180
180
  experiments.lazyCompilation,
181
181
  options =>
182
182
  options === true ? {} : options === false ? undefined : options
183
+ ),
184
+ css: optionalNestedConfig(experiments.css, options =>
185
+ options === true ? {} : options === false ? undefined : options
183
186
  )
184
187
  })),
185
188
  externals: config.externals,
@@ -297,6 +300,8 @@ const getNormalizedWebpackOptions = config => {
297
300
  chunkLoading: output.chunkLoading,
298
301
  chunkLoadingGlobal: output.chunkLoadingGlobal,
299
302
  chunkLoadTimeout: output.chunkLoadTimeout,
303
+ cssFilename: output.cssFilename,
304
+ cssChunkFilename: output.cssChunkFilename,
300
305
  clean: output.clean,
301
306
  compareBeforeEmit: output.compareBeforeEmit,
302
307
  crossOriginLoading: output.crossOriginLoading,
@@ -79,12 +79,14 @@ class ContainerEntryModule extends Module {
79
79
  * @returns {string | null} an identifier for library inclusion
80
80
  */
81
81
  libIdent(options) {
82
- return `webpack/container/entry/${this._name}`;
82
+ return `${this.layer ? `(${this.layer})/` : ""}webpack/container/entry/${
83
+ this._name
84
+ }`;
83
85
  }
84
86
 
85
87
  /**
86
88
  * @param {NeedBuildContext} context context info
87
- * @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
89
+ * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
88
90
  * @returns {void}
89
91
  */
90
92
  needBuild(context, callback) {
@@ -60,9 +60,9 @@ class FallbackModule extends Module {
60
60
  * @returns {string | null} an identifier for library inclusion
61
61
  */
62
62
  libIdent(options) {
63
- return `webpack/container/fallback/${this.requests[0]}/and ${
64
- this.requests.length - 1
65
- } more`;
63
+ return `${this.layer ? `(${this.layer})/` : ""}webpack/container/fallback/${
64
+ this.requests[0]
65
+ }/and ${this.requests.length - 1} more`;
66
66
  }
67
67
 
68
68
  /**
@@ -76,7 +76,7 @@ class FallbackModule extends Module {
76
76
 
77
77
  /**
78
78
  * @param {NeedBuildContext} context context info
79
- * @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
79
+ * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
80
80
  * @returns {void}
81
81
  */
82
82
  needBuild(context, callback) {
@@ -67,12 +67,14 @@ class RemoteModule extends Module {
67
67
  * @returns {string | null} an identifier for library inclusion
68
68
  */
69
69
  libIdent(options) {
70
- return `webpack/container/remote/${this.request}`;
70
+ return `${this.layer ? `(${this.layer})/` : ""}webpack/container/remote/${
71
+ this.request
72
+ }`;
71
73
  }
72
74
 
73
75
  /**
74
76
  * @param {NeedBuildContext} context context info
75
- * @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
77
+ * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
76
78
  * @returns {void}
77
79
  */
78
80
  needBuild(context, callback) {