webpack 5.66.0 → 5.67.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 +1 -1
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +2 -2
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +12 -9
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +21 -17
- package/lib/DelegatedModule.js +1 -1
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +18 -1
- package/lib/ExternalModule.js +1 -1
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +29 -25
- package/lib/HookWebpackError.js +1 -1
- package/lib/Module.js +1 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +6 -4
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +18 -0
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +28 -3
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/Watching.js +1 -1
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +62 -24
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +8 -5
- package/lib/cache/ResolverCachePlugin.js +1 -1
- package/lib/cli.js +44 -3
- package/lib/config/defaults.js +22 -5
- package/lib/config/normalization.js +5 -0
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/RemoteModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +3 -0
- package/lib/css/CssLoadingRuntimeModule.js +139 -85
- package/lib/css/CssModulesPlugin.js +20 -3
- package/lib/debug/ProfilingPlugin.js +12 -10
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/hmr/LazyCompilationPlugin.js +45 -21
- package/lib/hmr/lazyCompilationBackend.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +9 -12
- package/lib/ids/IdHelpers.js +24 -10
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +5 -0
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/schemes/HttpUriPlugin.js +8 -8
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
- package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/package.json +3 -10
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +43 -6
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/types.d.ts +163 -42
package/lib/MultiWatching.js
CHANGED
package/lib/NormalModule.js
CHANGED
@@ -310,7 +310,7 @@ class NormalModule extends Module {
|
|
310
310
|
}
|
311
311
|
|
312
312
|
// Info from Build
|
313
|
-
/** @type {WebpackError=} */
|
313
|
+
/** @type {(WebpackError | null)=} */
|
314
314
|
this.error = null;
|
315
315
|
/** @private @type {Source=} */
|
316
316
|
this._source = null;
|
@@ -355,11 +355,13 @@ class NormalModule extends Module {
|
|
355
355
|
* @returns {string | null} an identifier for library inclusion
|
356
356
|
*/
|
357
357
|
libIdent(options) {
|
358
|
-
|
358
|
+
let ident = contextify(
|
359
359
|
options.context,
|
360
360
|
this.userRequest,
|
361
361
|
options.associatedObjectForCache
|
362
362
|
);
|
363
|
+
if (this.layer) ident = `(${this.layer})/${ident}`;
|
364
|
+
return ident;
|
363
365
|
}
|
364
366
|
|
365
367
|
/**
|
@@ -730,7 +732,7 @@ class NormalModule extends Module {
|
|
730
732
|
* @param {ResolverWithOptions} resolver the resolver
|
731
733
|
* @param {InputFileSystem} fs the file system
|
732
734
|
* @param {NormalModuleCompilationHooks} hooks the hooks
|
733
|
-
* @param {function(WebpackError=): void} callback callback function
|
735
|
+
* @param {function((WebpackError | null)=): void} callback callback function
|
734
736
|
* @returns {void}
|
735
737
|
*/
|
736
738
|
_doBuild(options, compilation, resolver, fs, hooks, callback) {
|
@@ -1236,7 +1238,7 @@ class NormalModule extends Module {
|
|
1236
1238
|
|
1237
1239
|
/**
|
1238
1240
|
* @param {NeedBuildContext} context context info
|
1239
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
1241
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
1240
1242
|
* @returns {void}
|
1241
1243
|
*/
|
1242
1244
|
needBuild(context, callback) {
|
package/lib/RawModule.js
CHANGED
@@ -74,7 +74,7 @@ class RawModule extends Module {
|
|
74
74
|
|
75
75
|
/**
|
76
76
|
* @param {NeedBuildContext} context context info
|
77
|
-
* @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
|
78
78
|
* @returns {void}
|
79
79
|
*/
|
80
80
|
needBuild(context, callback) {
|
package/lib/RuntimeGlobals.js
CHANGED
@@ -168,6 +168,13 @@ exports.scriptNonce = "__webpack_require__.nc";
|
|
168
168
|
*/
|
169
169
|
exports.loadScript = "__webpack_require__.l";
|
170
170
|
|
171
|
+
/**
|
172
|
+
* function to promote a string to a TrustedScript using webpack's Trusted
|
173
|
+
* Types policy
|
174
|
+
* Arguments: (script: string) => TrustedScript
|
175
|
+
*/
|
176
|
+
exports.createScript = "__webpack_require__.ts";
|
177
|
+
|
171
178
|
/**
|
172
179
|
* function to promote a string to a TrustedScriptURL using webpack's Trusted
|
173
180
|
* Types policy
|
@@ -175,6 +182,12 @@ exports.loadScript = "__webpack_require__.l";
|
|
175
182
|
*/
|
176
183
|
exports.createScriptUrl = "__webpack_require__.tu";
|
177
184
|
|
185
|
+
/**
|
186
|
+
* function to return webpack's Trusted Types policy
|
187
|
+
* Arguments: () => TrustedTypePolicy
|
188
|
+
*/
|
189
|
+
exports.getTrustedTypesPolicy = "__webpack_require__.tt";
|
190
|
+
|
178
191
|
/**
|
179
192
|
* the chunk name of the chunk with the runtime
|
180
193
|
*/
|
@@ -195,6 +208,11 @@ exports.getChunkScriptFilename = "__webpack_require__.u";
|
|
195
208
|
*/
|
196
209
|
exports.getChunkCssFilename = "__webpack_require__.k";
|
197
210
|
|
211
|
+
/**
|
212
|
+
* a flag when a module/chunk/tree has css modules
|
213
|
+
*/
|
214
|
+
exports.hasCssModules = "has css modules";
|
215
|
+
|
198
216
|
/**
|
199
217
|
* the filename of the script part of the hot update chunk
|
200
218
|
*/
|
package/lib/RuntimeModule.js
CHANGED
@@ -78,7 +78,7 @@ class RuntimeModule extends Module {
|
|
78
78
|
|
79
79
|
/**
|
80
80
|
* @param {NeedBuildContext} context context info
|
81
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
81
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
82
82
|
* @returns {void}
|
83
83
|
*/
|
84
84
|
needBuild(context, callback) {
|
package/lib/RuntimePlugin.js
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
9
|
+
const { getChunkFilenameTemplate } = require("./css/CssModulesPlugin");
|
9
10
|
const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency");
|
10
11
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
11
12
|
const AsyncModuleRuntimeModule = require("./runtime/AsyncModuleRuntimeModule");
|
@@ -13,11 +14,13 @@ const AutoPublicPathRuntimeModule = require("./runtime/AutoPublicPathRuntimeModu
|
|
13
14
|
const CompatGetDefaultExportRuntimeModule = require("./runtime/CompatGetDefaultExportRuntimeModule");
|
14
15
|
const CompatRuntimeModule = require("./runtime/CompatRuntimeModule");
|
15
16
|
const CreateFakeNamespaceObjectRuntimeModule = require("./runtime/CreateFakeNamespaceObjectRuntimeModule");
|
17
|
+
const CreateScriptRuntimeModule = require("./runtime/CreateScriptRuntimeModule");
|
16
18
|
const CreateScriptUrlRuntimeModule = require("./runtime/CreateScriptUrlRuntimeModule");
|
17
19
|
const DefinePropertyGettersRuntimeModule = require("./runtime/DefinePropertyGettersRuntimeModule");
|
18
20
|
const EnsureChunkRuntimeModule = require("./runtime/EnsureChunkRuntimeModule");
|
19
21
|
const GetChunkFilenameRuntimeModule = require("./runtime/GetChunkFilenameRuntimeModule");
|
20
22
|
const GetMainFilenameRuntimeModule = require("./runtime/GetMainFilenameRuntimeModule");
|
23
|
+
const GetTrustedTypesPolicyRuntimeModule = require("./runtime/GetTrustedTypesPolicyRuntimeModule");
|
21
24
|
const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule");
|
22
25
|
const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule");
|
23
26
|
const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
|
@@ -39,7 +42,9 @@ const GLOBALS_ON_REQUIRE = [
|
|
39
42
|
RuntimeGlobals.runtimeId,
|
40
43
|
RuntimeGlobals.compatGetDefaultExport,
|
41
44
|
RuntimeGlobals.createFakeNamespaceObject,
|
45
|
+
RuntimeGlobals.createScript,
|
42
46
|
RuntimeGlobals.createScriptUrl,
|
47
|
+
RuntimeGlobals.getTrustedTypesPolicy,
|
43
48
|
RuntimeGlobals.definePropertyGetters,
|
44
49
|
RuntimeGlobals.ensureChunk,
|
45
50
|
RuntimeGlobals.entryModuleId,
|
@@ -279,9 +284,8 @@ class RuntimePlugin {
|
|
279
284
|
"css",
|
280
285
|
RuntimeGlobals.getChunkCssFilename,
|
281
286
|
chunk =>
|
282
|
-
chunk.
|
283
|
-
|
284
|
-
false
|
287
|
+
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
288
|
+
set.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
285
289
|
)
|
286
290
|
);
|
287
291
|
return true;
|
@@ -364,15 +368,36 @@ class RuntimePlugin {
|
|
364
368
|
);
|
365
369
|
return true;
|
366
370
|
});
|
371
|
+
compilation.hooks.runtimeRequirementInTree
|
372
|
+
.for(RuntimeGlobals.createScript)
|
373
|
+
.tap("RuntimePlugin", (chunk, set) => {
|
374
|
+
if (compilation.outputOptions.trustedTypes) {
|
375
|
+
set.add(RuntimeGlobals.getTrustedTypesPolicy);
|
376
|
+
}
|
377
|
+
compilation.addRuntimeModule(chunk, new CreateScriptRuntimeModule());
|
378
|
+
return true;
|
379
|
+
});
|
367
380
|
compilation.hooks.runtimeRequirementInTree
|
368
381
|
.for(RuntimeGlobals.createScriptUrl)
|
369
382
|
.tap("RuntimePlugin", (chunk, set) => {
|
383
|
+
if (compilation.outputOptions.trustedTypes) {
|
384
|
+
set.add(RuntimeGlobals.getTrustedTypesPolicy);
|
385
|
+
}
|
370
386
|
compilation.addRuntimeModule(
|
371
387
|
chunk,
|
372
388
|
new CreateScriptUrlRuntimeModule()
|
373
389
|
);
|
374
390
|
return true;
|
375
391
|
});
|
392
|
+
compilation.hooks.runtimeRequirementInTree
|
393
|
+
.for(RuntimeGlobals.getTrustedTypesPolicy)
|
394
|
+
.tap("RuntimePlugin", (chunk, set) => {
|
395
|
+
compilation.addRuntimeModule(
|
396
|
+
chunk,
|
397
|
+
new GetTrustedTypesPolicyRuntimeModule(set)
|
398
|
+
);
|
399
|
+
return true;
|
400
|
+
});
|
376
401
|
compilation.hooks.runtimeRequirementInTree
|
377
402
|
.for(RuntimeGlobals.relativeUrl)
|
378
403
|
.tap("RuntimePlugin", (chunk, set) => {
|
package/lib/RuntimeTemplate.js
CHANGED
@@ -1031,7 +1031,7 @@ class RuntimeTemplate {
|
|
1031
1031
|
const codeGen = codeGenerationResults.get(module, runtime);
|
1032
1032
|
const { data } = codeGen;
|
1033
1033
|
const url = data.get("url");
|
1034
|
-
if (url) return url;
|
1034
|
+
if (url) return url.toString();
|
1035
1035
|
const filename = data.get("filename");
|
1036
1036
|
return publicPath + filename;
|
1037
1037
|
}
|
package/lib/Watching.js
CHANGED
@@ -291,7 +291,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
291
291
|
|
292
292
|
if (options.experiments.css) {
|
293
293
|
const CssModulesPlugin = require("./css/CssModulesPlugin");
|
294
|
-
new CssModulesPlugin().apply(compiler);
|
294
|
+
new CssModulesPlugin(options.experiments.css).apply(compiler);
|
295
295
|
}
|
296
296
|
|
297
297
|
if (options.experiments.lazyCompilation) {
|
@@ -15,6 +15,7 @@ const { makePathsRelative } = require("../util/identifier");
|
|
15
15
|
|
16
16
|
/** @typedef {import("webpack-sources").Source} Source */
|
17
17
|
/** @typedef {import("../../declarations/WebpackOptions").AssetGeneratorOptions} AssetGeneratorOptions */
|
18
|
+
/** @typedef {import("../../declarations/WebpackOptions").AssetModuleOutputPath} AssetModuleOutputPath */
|
18
19
|
/** @typedef {import("../../declarations/WebpackOptions").RawPublicPath} RawPublicPath */
|
19
20
|
/** @typedef {import("../Compilation")} Compilation */
|
20
21
|
/** @typedef {import("../Compiler")} Compiler */
|
@@ -74,6 +75,41 @@ const mergeRelatedInfo = (a, b) => {
|
|
74
75
|
return result;
|
75
76
|
};
|
76
77
|
|
78
|
+
const encodeDataUri = (encoding, source) => {
|
79
|
+
let encodedContent;
|
80
|
+
|
81
|
+
switch (encoding) {
|
82
|
+
case "base64": {
|
83
|
+
encodedContent = source.buffer().toString("base64");
|
84
|
+
break;
|
85
|
+
}
|
86
|
+
case false: {
|
87
|
+
const content = source.source();
|
88
|
+
|
89
|
+
if (typeof content !== "string") {
|
90
|
+
encodedContent = content.toString("utf-8");
|
91
|
+
}
|
92
|
+
|
93
|
+
encodedContent = encodeURIComponent(encodedContent).replace(
|
94
|
+
/[!'()*]/g,
|
95
|
+
character => "%" + character.codePointAt(0).toString(16)
|
96
|
+
);
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
default:
|
100
|
+
throw new Error(`Unsupported encoding '${encoding}'`);
|
101
|
+
}
|
102
|
+
|
103
|
+
return encodedContent;
|
104
|
+
};
|
105
|
+
|
106
|
+
const decodeDataUriContent = (encoding, content) => {
|
107
|
+
const isBase64 = encoding === "base64";
|
108
|
+
return isBase64
|
109
|
+
? Buffer.from(content, "base64")
|
110
|
+
: Buffer.from(decodeURIComponent(content), "ascii");
|
111
|
+
};
|
112
|
+
|
77
113
|
const JS_TYPES = new Set(["javascript"]);
|
78
114
|
const JS_AND_ASSET_TYPES = new Set(["javascript", "asset"]);
|
79
115
|
|
@@ -82,13 +118,15 @@ class AssetGenerator extends Generator {
|
|
82
118
|
* @param {AssetGeneratorOptions["dataUrl"]=} dataUrlOptions the options for the data url
|
83
119
|
* @param {string=} filename override for output.assetModuleFilename
|
84
120
|
* @param {RawPublicPath=} publicPath override for output.assetModulePublicPath
|
121
|
+
* @param {AssetModuleOutputPath=} outputPath the output path for the emitted file which is not included in the runtime import
|
85
122
|
* @param {boolean=} emit generate output asset
|
86
123
|
*/
|
87
|
-
constructor(dataUrlOptions, filename, publicPath, emit) {
|
124
|
+
constructor(dataUrlOptions, filename, publicPath, outputPath, emit) {
|
88
125
|
super();
|
89
126
|
this.dataUrlOptions = dataUrlOptions;
|
90
127
|
this.filename = filename;
|
91
128
|
this.publicPath = publicPath;
|
129
|
+
this.outputPath = outputPath;
|
92
130
|
this.emit = emit;
|
93
131
|
}
|
94
132
|
|
@@ -158,33 +196,18 @@ class AssetGenerator extends Generator {
|
|
158
196
|
}
|
159
197
|
|
160
198
|
let encodedContent;
|
199
|
+
|
161
200
|
if (
|
162
201
|
module.resourceResolveData &&
|
163
|
-
module.resourceResolveData.encoding === encoding
|
202
|
+
module.resourceResolveData.encoding === encoding &&
|
203
|
+
decodeDataUriContent(
|
204
|
+
module.resourceResolveData.encoding,
|
205
|
+
module.resourceResolveData.encodedContent
|
206
|
+
).equals(originalSource.buffer())
|
164
207
|
) {
|
165
208
|
encodedContent = module.resourceResolveData.encodedContent;
|
166
209
|
} else {
|
167
|
-
|
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
|
-
}
|
210
|
+
encodedContent = encodeDataUri(encoding, originalSource);
|
188
211
|
}
|
189
212
|
|
190
213
|
encodedSource = `data:${mimeType}${
|
@@ -192,7 +215,7 @@ class AssetGenerator extends Generator {
|
|
192
215
|
},${encodedContent}`;
|
193
216
|
}
|
194
217
|
const data = getData();
|
195
|
-
data.set("url", encodedSource);
|
218
|
+
data.set("url", Buffer.from(encodedSource));
|
196
219
|
return new RawSource(
|
197
220
|
`${RuntimeGlobals.module}.exports = ${JSON.stringify(
|
198
221
|
encodedSource
|
@@ -256,6 +279,21 @@ class AssetGenerator extends Generator {
|
|
256
279
|
sourceFilename,
|
257
280
|
...assetInfo
|
258
281
|
};
|
282
|
+
if (this.outputPath) {
|
283
|
+
const { path: outputPath, info } =
|
284
|
+
runtimeTemplate.compilation.getAssetPathWithInfo(
|
285
|
+
this.outputPath,
|
286
|
+
{
|
287
|
+
module,
|
288
|
+
runtime,
|
289
|
+
filename: sourceFilename,
|
290
|
+
chunkGraph,
|
291
|
+
contentHash
|
292
|
+
}
|
293
|
+
);
|
294
|
+
assetInfo = mergeAssetInfo(assetInfo, info);
|
295
|
+
filename = path.posix.join(outputPath, filename);
|
296
|
+
}
|
259
297
|
module.buildInfo.filename = filename;
|
260
298
|
module.buildInfo.assetInfo = assetInfo;
|
261
299
|
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.
|
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.
|
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.
|
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.
|
138
|
+
this.urlBuffer = read();
|
136
139
|
this.identifierStr = read();
|
137
140
|
this.readableIdentifierStr = read();
|
138
141
|
|
@@ -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
|
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 =
|
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
|
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: [],
|
package/lib/config/defaults.js
CHANGED
@@ -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, {
|
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 = (
|
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
|
-
|
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
|
/**
|
@@ -461,7 +478,7 @@ const applyJavascriptParserOptionsDefaults = (
|
|
461
478
|
* @param {boolean} options.cache is caching enabled
|
462
479
|
* @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
|
463
480
|
* @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
|
464
|
-
* @param {
|
481
|
+
* @param {CssExperimentOptions} options.css is css enabled
|
465
482
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
466
483
|
* @returns {void}
|
467
484
|
*/
|
@@ -1083,7 +1100,7 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
1083
1100
|
* @param {Object} options options
|
1084
1101
|
* @param {boolean} options.production is production
|
1085
1102
|
* @param {boolean} options.development is development
|
1086
|
-
* @param {
|
1103
|
+
* @param {CssExperimentOptions} options.css is css enabled
|
1087
1104
|
* @param {boolean} options.records using records
|
1088
1105
|
* @returns {void}
|
1089
1106
|
*/
|
@@ -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/${
|
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/${
|
64
|
-
this.requests
|
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) {
|