webpack 5.65.0 → 5.69.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/APIPlugin.js +33 -0
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +2 -0
- package/lib/ChunkGraph.js +1 -2
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +93 -47
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +100 -41
- package/lib/ContextModuleFactory.js +60 -21
- package/lib/DelegatedModule.js +1 -1
- package/lib/Dependency.js +10 -0
- package/lib/DependencyTemplate.js +9 -0
- 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/ExportsInfo.js +4 -4
- package/lib/ExternalModule.js +93 -53
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +29 -25
- package/lib/Generator.js +2 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/Module.js +25 -4
- package/lib/ModuleFilenameHelpers.js +5 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +9 -5
- package/lib/NormalModuleFactory.js +25 -27
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +50 -0
- package/lib/RuntimeTemplate.js +21 -0
- package/lib/Template.js +2 -1
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/Watching.js +2 -2
- package/lib/WebpackOptionsApply.js +43 -2
- package/lib/asset/AssetGenerator.js +67 -26
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +1 -1
- package/lib/cache/ResolverCachePlugin.js +81 -29
- package/lib/cli.js +44 -3
- package/lib/config/defaults.js +86 -7
- 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 +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +440 -0
- package/lib/css/CssModulesPlugin.js +462 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +15 -14
- package/lib/dependencies/ContextElementDependency.js +8 -2
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +45 -21
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- 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 +10 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/StartupHelpers.js +6 -5
- package/lib/library/AssignLibraryPlugin.js +34 -5
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +21 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
- 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 +32 -11
- package/lib/serialization/FileMiddleware.js +44 -9
- 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/ArrayHelpers.js +18 -4
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +65 -44
- package/lib/util/internalSerializables.js +11 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -2
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +16 -23
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +96 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/types.d.ts +295 -59
@@ -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
|
});
|
@@ -0,0 +1,148 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const { RawSource } = require("webpack-sources");
|
9
|
+
const Module = require("../Module");
|
10
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
11
|
+
const makeSerializable = require("../util/makeSerializable");
|
12
|
+
|
13
|
+
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
14
|
+
/** @typedef {import("../Compilation")} Compilation */
|
15
|
+
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
16
|
+
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
17
|
+
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
18
|
+
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
19
|
+
/** @typedef {import("../RequestShortener")} RequestShortener */
|
20
|
+
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
21
|
+
/** @typedef {import("../WebpackError")} WebpackError */
|
22
|
+
/** @typedef {import("../util/Hash")} Hash */
|
23
|
+
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
24
|
+
|
25
|
+
const TYPES = new Set(["javascript"]);
|
26
|
+
|
27
|
+
class RawDataUrlModule extends Module {
|
28
|
+
/**
|
29
|
+
* @param {string} url raw url
|
30
|
+
* @param {string} identifier unique identifier
|
31
|
+
* @param {string=} readableIdentifier readable identifier
|
32
|
+
*/
|
33
|
+
constructor(url, identifier, readableIdentifier) {
|
34
|
+
super("asset/raw-data-url", null);
|
35
|
+
this.url = url;
|
36
|
+
this.urlBuffer = url ? Buffer.from(url) : undefined;
|
37
|
+
this.identifierStr = identifier || this.url;
|
38
|
+
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* @returns {Set<string>} types available (do not mutate)
|
43
|
+
*/
|
44
|
+
getSourceTypes() {
|
45
|
+
return TYPES;
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @returns {string} a unique identifier of the module
|
50
|
+
*/
|
51
|
+
identifier() {
|
52
|
+
return this.identifierStr;
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @param {string=} type the source type for which the size should be estimated
|
57
|
+
* @returns {number} the estimated size of the module (must be non-zero)
|
58
|
+
*/
|
59
|
+
size(type) {
|
60
|
+
if (this.url === undefined) this.url = this.urlBuffer.toString();
|
61
|
+
return Math.max(1, this.url.length);
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @param {RequestShortener} requestShortener the request shortener
|
66
|
+
* @returns {string} a user readable identifier of the module
|
67
|
+
*/
|
68
|
+
readableIdentifier(requestShortener) {
|
69
|
+
return requestShortener.shorten(this.readableIdentifierStr);
|
70
|
+
}
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @param {NeedBuildContext} context context info
|
74
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
75
|
+
* @returns {void}
|
76
|
+
*/
|
77
|
+
needBuild(context, callback) {
|
78
|
+
return callback(null, !this.buildMeta);
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @param {WebpackOptions} options webpack options
|
83
|
+
* @param {Compilation} compilation the compilation
|
84
|
+
* @param {ResolverWithOptions} resolver the resolver
|
85
|
+
* @param {InputFileSystem} fs the file system
|
86
|
+
* @param {function(WebpackError=): void} callback callback function
|
87
|
+
* @returns {void}
|
88
|
+
*/
|
89
|
+
build(options, compilation, resolver, fs, callback) {
|
90
|
+
this.buildMeta = {};
|
91
|
+
this.buildInfo = {
|
92
|
+
cacheable: true
|
93
|
+
};
|
94
|
+
callback();
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* @param {CodeGenerationContext} context context for code generation
|
99
|
+
* @returns {CodeGenerationResult} result
|
100
|
+
*/
|
101
|
+
codeGeneration(context) {
|
102
|
+
if (this.url === undefined) this.url = this.urlBuffer.toString();
|
103
|
+
const sources = new Map();
|
104
|
+
sources.set(
|
105
|
+
"javascript",
|
106
|
+
new RawSource(`module.exports = ${JSON.stringify(this.url)};`)
|
107
|
+
);
|
108
|
+
const data = new Map();
|
109
|
+
data.set("url", this.urlBuffer);
|
110
|
+
const runtimeRequirements = new Set();
|
111
|
+
runtimeRequirements.add(RuntimeGlobals.module);
|
112
|
+
return { sources, runtimeRequirements, data };
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @param {Hash} hash the hash used to track dependencies
|
117
|
+
* @param {UpdateHashContext} context context
|
118
|
+
* @returns {void}
|
119
|
+
*/
|
120
|
+
updateHash(hash, context) {
|
121
|
+
hash.update(this.urlBuffer);
|
122
|
+
super.updateHash(hash, context);
|
123
|
+
}
|
124
|
+
|
125
|
+
serialize(context) {
|
126
|
+
const { write } = context;
|
127
|
+
|
128
|
+
write(this.urlBuffer);
|
129
|
+
write(this.identifierStr);
|
130
|
+
write(this.readableIdentifierStr);
|
131
|
+
|
132
|
+
super.serialize(context);
|
133
|
+
}
|
134
|
+
|
135
|
+
deserialize(context) {
|
136
|
+
const { read } = context;
|
137
|
+
|
138
|
+
this.urlBuffer = read();
|
139
|
+
this.identifierStr = read();
|
140
|
+
this.readableIdentifierStr = read();
|
141
|
+
|
142
|
+
super.deserialize(context);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
makeSerializable(RawDataUrlModule, "webpack/lib/asset/RawDataUrlModule");
|
147
|
+
|
148
|
+
module.exports = RawDataUrlModule;
|
@@ -30,8 +30,8 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
merge(other) {
|
33
|
-
const promises = new Set(
|
34
|
-
for (const p of
|
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
|
}
|
package/lib/buildChunkGraph.js
CHANGED
@@ -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 = (
|
@@ -128,6 +128,11 @@ class ResolverCachePlugin {
|
|
128
128
|
fileDependencies: new LazySet(),
|
129
129
|
contextDependencies: new LazySet()
|
130
130
|
};
|
131
|
+
let yieldResult;
|
132
|
+
if (typeof newResolveContext.yield === "function") {
|
133
|
+
yieldResult = [];
|
134
|
+
newResolveContext.yield = obj => yieldResult.push(obj);
|
135
|
+
}
|
131
136
|
const propagate = key => {
|
132
137
|
if (resolveContext[key]) {
|
133
138
|
addAllToSet(resolveContext[key], newResolveContext[key]);
|
@@ -155,15 +160,19 @@ class ResolverCachePlugin {
|
|
155
160
|
snapshotOptions,
|
156
161
|
(err, snapshot) => {
|
157
162
|
if (err) return callback(err);
|
163
|
+
const resolveResult = result || yieldResult;
|
158
164
|
if (!snapshot) {
|
159
|
-
if (
|
165
|
+
if (resolveResult) return callback(null, resolveResult);
|
160
166
|
return callback();
|
161
167
|
}
|
162
|
-
itemCache.store(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
168
|
+
itemCache.store(
|
169
|
+
new CacheEntry(resolveResult, snapshot),
|
170
|
+
storeErr => {
|
171
|
+
if (storeErr) return callback(storeErr);
|
172
|
+
if (resolveResult) return callback(null, resolveResult);
|
173
|
+
callback();
|
174
|
+
}
|
175
|
+
);
|
167
176
|
}
|
168
177
|
);
|
169
178
|
}
|
@@ -173,6 +182,8 @@ class ResolverCachePlugin {
|
|
173
182
|
factory(type, hook) {
|
174
183
|
/** @type {Map<string, (function(Error=, Object=): void)[]>} */
|
175
184
|
const activeRequests = new Map();
|
185
|
+
/** @type {Map<string, [function(Error=, Object=): void, function(Error=, Object=): void][]>} */
|
186
|
+
const activeRequestsWithYield = new Map();
|
176
187
|
hook.tap(
|
177
188
|
"ResolverCachePlugin",
|
178
189
|
/**
|
@@ -197,29 +208,63 @@ class ResolverCachePlugin {
|
|
197
208
|
if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
|
198
209
|
return callback();
|
199
210
|
}
|
200
|
-
const
|
201
|
-
|
202
|
-
|
203
|
-
)}`;
|
204
|
-
|
205
|
-
if (
|
206
|
-
activeRequest.
|
207
|
-
|
211
|
+
const withYield = typeof resolveContext.yield === "function";
|
212
|
+
const identifier = `${type}${
|
213
|
+
withYield ? "|yield" : "|default"
|
214
|
+
}${optionsIdent}${objectToString(request, !cacheWithContext)}`;
|
215
|
+
|
216
|
+
if (withYield) {
|
217
|
+
const activeRequest = activeRequestsWithYield.get(identifier);
|
218
|
+
if (activeRequest) {
|
219
|
+
activeRequest[0].push(callback);
|
220
|
+
activeRequest[1].push(resolveContext.yield);
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
} else {
|
224
|
+
const activeRequest = activeRequests.get(identifier);
|
225
|
+
if (activeRequest) {
|
226
|
+
activeRequest.push(callback);
|
227
|
+
return;
|
228
|
+
}
|
208
229
|
}
|
209
230
|
const itemCache = cache.getItemCache(identifier, null);
|
210
|
-
let callbacks;
|
211
|
-
const done =
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
231
|
+
let callbacks, yields;
|
232
|
+
const done = withYield
|
233
|
+
? (err, result) => {
|
234
|
+
if (callbacks === undefined) {
|
235
|
+
if (err) {
|
236
|
+
callback(err);
|
237
|
+
} else {
|
238
|
+
if (result)
|
239
|
+
for (const r of result) resolveContext.yield(r);
|
240
|
+
callback(null, null);
|
241
|
+
}
|
242
|
+
yields = undefined;
|
243
|
+
callbacks = false;
|
244
|
+
} else {
|
245
|
+
for (let i = 0; i < callbacks.length; i++) {
|
246
|
+
const cb = callbacks[i];
|
247
|
+
const yield_ = yields[i];
|
248
|
+
if (result) for (const r of result) yield_(r);
|
249
|
+
cb(null, null);
|
250
|
+
}
|
251
|
+
activeRequestsWithYield.delete(identifier);
|
252
|
+
yields = undefined;
|
253
|
+
callbacks = false;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
: (err, result) => {
|
257
|
+
if (callbacks === undefined) {
|
258
|
+
callback(err, result);
|
259
|
+
callbacks = false;
|
260
|
+
} else {
|
261
|
+
for (const callback of callbacks) {
|
262
|
+
callback(err, result);
|
263
|
+
}
|
264
|
+
activeRequests.delete(identifier);
|
265
|
+
callbacks = false;
|
266
|
+
}
|
267
|
+
};
|
223
268
|
/**
|
224
269
|
* @param {Error=} err error if any
|
225
270
|
* @param {CacheEntry=} cacheEntry cache entry
|
@@ -276,7 +321,14 @@ class ResolverCachePlugin {
|
|
276
321
|
}
|
277
322
|
};
|
278
323
|
itemCache.get(processCacheResult);
|
279
|
-
if (callbacks === undefined) {
|
324
|
+
if (withYield && callbacks === undefined) {
|
325
|
+
callbacks = [callback];
|
326
|
+
yields = [resolveContext.yield];
|
327
|
+
activeRequestsWithYield.set(
|
328
|
+
identifier,
|
329
|
+
/** @type {[any, any]} */ ([callbacks, yields])
|
330
|
+
);
|
331
|
+
} else if (callbacks === undefined) {
|
280
332
|
callbacks = [callback];
|
281
333
|
activeRequests.set(identifier, callbacks);
|
282
334
|
}
|
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
|
|
@@ -184,6 +189,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
184
189
|
cache,
|
185
190
|
syncWebAssembly: options.experiments.syncWebAssembly,
|
186
191
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
192
|
+
css: options.experiments.css,
|
187
193
|
futureDefaults
|
188
194
|
});
|
189
195
|
|
@@ -239,6 +245,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
239
245
|
applyOptimizationDefaults(options.optimization, {
|
240
246
|
development,
|
241
247
|
production,
|
248
|
+
css: options.experiments.css,
|
242
249
|
records: !!(options.recordsInputPath || options.recordsOutputPath)
|
243
250
|
});
|
244
251
|
|
@@ -263,9 +270,13 @@ const applyWebpackOptionsDefaults = options => {
|
|
263
270
|
* @param {Object} options options
|
264
271
|
* @param {boolean} options.production is production
|
265
272
|
* @param {boolean} options.development is development mode
|
273
|
+
* @param {TargetProperties | false} options.targetProperties target properties
|
266
274
|
* @returns {void}
|
267
275
|
*/
|
268
|
-
const applyExperimentsDefaults = (
|
276
|
+
const applyExperimentsDefaults = (
|
277
|
+
experiments,
|
278
|
+
{ production, development, targetProperties }
|
279
|
+
) => {
|
269
280
|
D(experiments, "futureDefaults", false);
|
270
281
|
D(experiments, "backCompat", !experiments.futureDefaults);
|
271
282
|
D(experiments, "topLevelAwait", experiments.futureDefaults);
|
@@ -276,11 +287,20 @@ const applyExperimentsDefaults = (experiments, { production, development }) => {
|
|
276
287
|
D(experiments, "lazyCompilation", undefined);
|
277
288
|
D(experiments, "buildHttp", undefined);
|
278
289
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
290
|
+
F(experiments, "css", () => (experiments.futureDefaults ? {} : undefined));
|
279
291
|
|
280
292
|
if (typeof experiments.buildHttp === "object") {
|
281
293
|
D(experiments.buildHttp, "frozen", production);
|
282
294
|
D(experiments.buildHttp, "upgrade", false);
|
283
295
|
}
|
296
|
+
|
297
|
+
if (typeof experiments.css === "object") {
|
298
|
+
D(
|
299
|
+
experiments.css,
|
300
|
+
"exportsOnly",
|
301
|
+
!targetProperties || !targetProperties.document
|
302
|
+
);
|
303
|
+
}
|
284
304
|
};
|
285
305
|
|
286
306
|
/**
|
@@ -449,6 +469,7 @@ const applyJavascriptParserOptionsDefaults = (
|
|
449
469
|
D(parserOptions, "wrappedContextRecursive", true);
|
450
470
|
D(parserOptions, "wrappedContextCritical", false);
|
451
471
|
D(parserOptions, "strictThisContextOnImports", false);
|
472
|
+
D(parserOptions, "importMeta", true);
|
452
473
|
if (futureDefaults) D(parserOptions, "exportsPresence", "error");
|
453
474
|
};
|
454
475
|
|
@@ -458,12 +479,13 @@ const applyJavascriptParserOptionsDefaults = (
|
|
458
479
|
* @param {boolean} options.cache is caching enabled
|
459
480
|
* @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
|
460
481
|
* @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
|
482
|
+
* @param {CssExperimentOptions} options.css is css enabled
|
461
483
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
462
484
|
* @returns {void}
|
463
485
|
*/
|
464
486
|
const applyModuleDefaults = (
|
465
487
|
module,
|
466
|
-
{ cache, syncWebAssembly, asyncWebAssembly, futureDefaults }
|
488
|
+
{ cache, syncWebAssembly, asyncWebAssembly, css, futureDefaults }
|
467
489
|
) => {
|
468
490
|
if (cache) {
|
469
491
|
D(module, "unsafeCache", module => {
|
@@ -587,6 +609,41 @@ const applyModuleDefaults = (
|
|
587
609
|
...wasm
|
588
610
|
});
|
589
611
|
}
|
612
|
+
if (css) {
|
613
|
+
const cssRule = {
|
614
|
+
type: "css",
|
615
|
+
resolve: {
|
616
|
+
fullySpecified: true,
|
617
|
+
preferRelative: true
|
618
|
+
}
|
619
|
+
};
|
620
|
+
const cssModulesRule = {
|
621
|
+
type: "css/module",
|
622
|
+
resolve: {
|
623
|
+
fullySpecified: true
|
624
|
+
}
|
625
|
+
};
|
626
|
+
rules.push({
|
627
|
+
test: /\.css$/i,
|
628
|
+
oneOf: [
|
629
|
+
{
|
630
|
+
test: /\.module\.css$/i,
|
631
|
+
...cssModulesRule
|
632
|
+
},
|
633
|
+
{
|
634
|
+
...cssRule
|
635
|
+
}
|
636
|
+
]
|
637
|
+
});
|
638
|
+
rules.push({
|
639
|
+
mimetype: "text/css+module",
|
640
|
+
...cssModulesRule
|
641
|
+
});
|
642
|
+
rules.push({
|
643
|
+
mimetype: "text/css",
|
644
|
+
...cssRule
|
645
|
+
});
|
646
|
+
}
|
590
647
|
rules.push(
|
591
648
|
{
|
592
649
|
dependency: "url",
|
@@ -692,6 +749,20 @@ const applyOutputDefaults = (
|
|
692
749
|
}
|
693
750
|
return output.module ? "[id].mjs" : "[id].js";
|
694
751
|
});
|
752
|
+
F(output, "cssFilename", () => {
|
753
|
+
const filename = output.filename;
|
754
|
+
if (typeof filename !== "function") {
|
755
|
+
return filename.replace(/\.[mc]?js(\?|$)/, ".css$1");
|
756
|
+
}
|
757
|
+
return "[id].css";
|
758
|
+
});
|
759
|
+
F(output, "cssChunkFilename", () => {
|
760
|
+
const chunkFilename = output.chunkFilename;
|
761
|
+
if (typeof chunkFilename !== "function") {
|
762
|
+
return chunkFilename.replace(/\.[mc]?js(\?|$)/, ".css$1");
|
763
|
+
}
|
764
|
+
return "[id].css";
|
765
|
+
});
|
695
766
|
D(output, "assetModuleFilename", "[hash][ext][query]");
|
696
767
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
697
768
|
D(output, "compareBeforeEmit", true);
|
@@ -836,6 +907,7 @@ const applyOutputDefaults = (
|
|
836
907
|
D(output, "strictModuleExceptionHandling", false);
|
837
908
|
|
838
909
|
const optimistic = v => v || v === undefined;
|
910
|
+
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
|
839
911
|
F(
|
840
912
|
output.environment,
|
841
913
|
"arrowFunction",
|
@@ -849,8 +921,12 @@ const applyOutputDefaults = (
|
|
849
921
|
);
|
850
922
|
F(output.environment, "forOf", () => tp && optimistic(tp.forOf));
|
851
923
|
F(output.environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
|
852
|
-
F(output.environment, "dynamicImport", () =>
|
853
|
-
|
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
|
+
);
|
854
930
|
|
855
931
|
const { trustedTypes } = output;
|
856
932
|
if (trustedTypes) {
|
@@ -1030,12 +1106,13 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
1030
1106
|
* @param {Object} options options
|
1031
1107
|
* @param {boolean} options.production is production
|
1032
1108
|
* @param {boolean} options.development is development
|
1109
|
+
* @param {CssExperimentOptions} options.css is css enabled
|
1033
1110
|
* @param {boolean} options.records using records
|
1034
1111
|
* @returns {void}
|
1035
1112
|
*/
|
1036
1113
|
const applyOptimizationDefaults = (
|
1037
1114
|
optimization,
|
1038
|
-
{ production, development, records }
|
1115
|
+
{ production, development, css, records }
|
1039
1116
|
) => {
|
1040
1117
|
D(optimization, "removeAvailableModules", false);
|
1041
1118
|
D(optimization, "removeEmptyChunks", true);
|
@@ -1086,7 +1163,9 @@ const applyOptimizationDefaults = (
|
|
1086
1163
|
});
|
1087
1164
|
const { splitChunks } = optimization;
|
1088
1165
|
if (splitChunks) {
|
1089
|
-
A(splitChunks, "defaultSizeTypes", () =>
|
1166
|
+
A(splitChunks, "defaultSizeTypes", () =>
|
1167
|
+
css ? ["javascript", "css", "unknown"] : ["javascript", "unknown"]
|
1168
|
+
);
|
1090
1169
|
D(splitChunks, "hidePathInfo", production);
|
1091
1170
|
D(splitChunks, "chunks", "async");
|
1092
1171
|
D(splitChunks, "usedExports", optimization.usedExports === true);
|
@@ -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) {
|