webpack 5.64.3 → 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 +4 -11
- package/lib/Chunk.js +2 -0
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +91 -47
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +21 -17
- 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/ExternalModule.js +94 -54
- 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 -2
- 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/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 +113 -2
- package/lib/Template.js +2 -1
- package/lib/WatchIgnorePlugin.js +14 -1
- package/lib/Watching.js +33 -19
- package/lib/WebpackOptionsApply.js +43 -2
- package/lib/asset/AssetGenerator.js +71 -30
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/cache/ResolverCachePlugin.js +1 -1
- package/lib/cli.js +44 -3
- package/lib/config/browserslistTargetHandler.js +38 -1
- package/lib/config/defaults.js +79 -6
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +8 -5
- 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 +447 -0
- package/lib/css/CssModulesPlugin.js +461 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +12 -10
- 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/LoaderPlugin.js +2 -2
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- 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 +8 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptParser.js +16 -8
- package/lib/javascript/StartupHelpers.js +4 -28
- package/lib/library/AssignLibraryPlugin.js +31 -13
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +11 -5
- 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 +8 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +25 -4
- 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 +89 -24
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +10 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/internalSerializables.js +11 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -2
- package/package.json +5 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +100 -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 +305 -58
@@ -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;
|
@@ -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: [],
|
@@ -274,7 +274,44 @@ const resolve = browsers => {
|
|
274
274
|
// kaios: Unknown support
|
275
275
|
node: [12, 0]
|
276
276
|
}),
|
277
|
-
|
277
|
+
optionalChaining: rawChecker({
|
278
|
+
chrome: 80,
|
279
|
+
and_chr: 80,
|
280
|
+
edge: 80,
|
281
|
+
firefox: 74,
|
282
|
+
and_ff: 79,
|
283
|
+
// ie: Not supported,
|
284
|
+
opera: 67,
|
285
|
+
op_mob: 64,
|
286
|
+
safari: [13, 1],
|
287
|
+
ios_saf: [13, 4],
|
288
|
+
samsung: 13,
|
289
|
+
android: 80,
|
290
|
+
// and_qq: Not supported
|
291
|
+
// baidu: Not supported
|
292
|
+
// and_uc: Not supported
|
293
|
+
// kaios: Not supported
|
294
|
+
node: 14
|
295
|
+
}),
|
296
|
+
templateLiteral: rawChecker({
|
297
|
+
chrome: 41,
|
298
|
+
and_chr: 41,
|
299
|
+
edge: 13,
|
300
|
+
firefox: 34,
|
301
|
+
and_ff: 34,
|
302
|
+
// ie: Not supported,
|
303
|
+
opera: 29,
|
304
|
+
op_mob: 64,
|
305
|
+
safari: [9, 1],
|
306
|
+
ios_saf: 9,
|
307
|
+
samsung: 4,
|
308
|
+
android: 41,
|
309
|
+
and_qq: [10, 4],
|
310
|
+
baidu: [7, 12],
|
311
|
+
and_uc: [12, 12],
|
312
|
+
kaios: [2, 5],
|
313
|
+
node: 4
|
314
|
+
}),
|
278
315
|
browser: browserProperty,
|
279
316
|
electron: false,
|
280
317
|
node: nodeProperty,
|
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
|
/**
|
@@ -458,12 +478,13 @@ const applyJavascriptParserOptionsDefaults = (
|
|
458
478
|
* @param {boolean} options.cache is caching enabled
|
459
479
|
* @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
|
460
480
|
* @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
|
481
|
+
* @param {CssExperimentOptions} options.css is css enabled
|
461
482
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
462
483
|
* @returns {void}
|
463
484
|
*/
|
464
485
|
const applyModuleDefaults = (
|
465
486
|
module,
|
466
|
-
{ cache, syncWebAssembly, asyncWebAssembly, futureDefaults }
|
487
|
+
{ cache, syncWebAssembly, asyncWebAssembly, css, futureDefaults }
|
467
488
|
) => {
|
468
489
|
if (cache) {
|
469
490
|
D(module, "unsafeCache", module => {
|
@@ -587,6 +608,41 @@ const applyModuleDefaults = (
|
|
587
608
|
...wasm
|
588
609
|
});
|
589
610
|
}
|
611
|
+
if (css) {
|
612
|
+
const cssRule = {
|
613
|
+
type: "css",
|
614
|
+
resolve: {
|
615
|
+
fullySpecified: true,
|
616
|
+
preferRelative: true
|
617
|
+
}
|
618
|
+
};
|
619
|
+
const cssModulesRule = {
|
620
|
+
type: "css/module",
|
621
|
+
resolve: {
|
622
|
+
fullySpecified: true
|
623
|
+
}
|
624
|
+
};
|
625
|
+
rules.push({
|
626
|
+
test: /\.css$/i,
|
627
|
+
oneOf: [
|
628
|
+
{
|
629
|
+
test: /\.module\.css$/i,
|
630
|
+
...cssModulesRule
|
631
|
+
},
|
632
|
+
{
|
633
|
+
...cssRule
|
634
|
+
}
|
635
|
+
]
|
636
|
+
});
|
637
|
+
rules.push({
|
638
|
+
mimetype: "text/css+module",
|
639
|
+
...cssModulesRule
|
640
|
+
});
|
641
|
+
rules.push({
|
642
|
+
mimetype: "text/css",
|
643
|
+
...cssRule
|
644
|
+
});
|
645
|
+
}
|
590
646
|
rules.push(
|
591
647
|
{
|
592
648
|
dependency: "url",
|
@@ -692,6 +748,20 @@ const applyOutputDefaults = (
|
|
692
748
|
}
|
693
749
|
return output.module ? "[id].mjs" : "[id].js";
|
694
750
|
});
|
751
|
+
F(output, "cssFilename", () => {
|
752
|
+
const filename = output.filename;
|
753
|
+
if (typeof filename !== "function") {
|
754
|
+
return filename.replace(/\.[mc]?js(\?|$)/, ".css$1");
|
755
|
+
}
|
756
|
+
return "[id].css";
|
757
|
+
});
|
758
|
+
F(output, "cssChunkFilename", () => {
|
759
|
+
const chunkFilename = output.chunkFilename;
|
760
|
+
if (typeof chunkFilename !== "function") {
|
761
|
+
return chunkFilename.replace(/\.[mc]?js(\?|$)/, ".css$1");
|
762
|
+
}
|
763
|
+
return "[id].css";
|
764
|
+
});
|
695
765
|
D(output, "assetModuleFilename", "[hash][ext][query]");
|
696
766
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
697
767
|
D(output, "compareBeforeEmit", true);
|
@@ -832,7 +902,7 @@ const applyOutputDefaults = (
|
|
832
902
|
D(output, "chunkLoadTimeout", 120000);
|
833
903
|
D(output, "hashFunction", futureDefaults ? "xxhash64" : "md4");
|
834
904
|
D(output, "hashDigest", "hex");
|
835
|
-
D(output, "hashDigestLength", 20);
|
905
|
+
D(output, "hashDigestLength", futureDefaults ? 16 : 20);
|
836
906
|
D(output, "strictModuleExceptionHandling", false);
|
837
907
|
|
838
908
|
const optimistic = v => v || v === undefined;
|
@@ -1030,12 +1100,13 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
1030
1100
|
* @param {Object} options options
|
1031
1101
|
* @param {boolean} options.production is production
|
1032
1102
|
* @param {boolean} options.development is development
|
1103
|
+
* @param {CssExperimentOptions} options.css is css enabled
|
1033
1104
|
* @param {boolean} options.records using records
|
1034
1105
|
* @returns {void}
|
1035
1106
|
*/
|
1036
1107
|
const applyOptimizationDefaults = (
|
1037
1108
|
optimization,
|
1038
|
-
{ production, development, records }
|
1109
|
+
{ production, development, css, records }
|
1039
1110
|
) => {
|
1040
1111
|
D(optimization, "removeAvailableModules", false);
|
1041
1112
|
D(optimization, "removeEmptyChunks", true);
|
@@ -1086,7 +1157,9 @@ const applyOptimizationDefaults = (
|
|
1086
1157
|
});
|
1087
1158
|
const { splitChunks } = optimization;
|
1088
1159
|
if (splitChunks) {
|
1089
|
-
A(splitChunks, "defaultSizeTypes", () =>
|
1160
|
+
A(splitChunks, "defaultSizeTypes", () =>
|
1161
|
+
css ? ["javascript", "css", "unknown"] : ["javascript", "unknown"]
|
1162
|
+
);
|
1090
1163
|
D(splitChunks, "hidePathInfo", production);
|
1091
1164
|
D(splitChunks, "chunks", "async");
|
1092
1165
|
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,
|
package/lib/config/target.js
CHANGED
@@ -59,6 +59,8 @@ const getDefaultTarget = context => {
|
|
59
59
|
* @property {boolean | null} dynamicImport async import() is available
|
60
60
|
* @property {boolean | null} dynamicImportInWorker async import() is available when creating a worker
|
61
61
|
* @property {boolean | null} module ESM syntax is available (when in module)
|
62
|
+
* @property {boolean | null} optionalChaining optional chaining is available
|
63
|
+
* @property {boolean | null} templateLiteral template literal is available
|
62
64
|
*/
|
63
65
|
|
64
66
|
///** @typedef {PlatformTargetProperties | ApiTargetProperties | EcmaTargetProperties | PlatformTargetProperties & ApiTargetProperties | PlatformTargetProperties & EcmaTargetProperties | ApiTargetProperties & EcmaTargetProperties} TargetProperties */
|
@@ -167,6 +169,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
167
169
|
|
168
170
|
globalThis: v(12),
|
169
171
|
const: v(6),
|
172
|
+
templateLiteral: v(4),
|
173
|
+
optionalChaining: v(14),
|
170
174
|
arrowFunction: v(6),
|
171
175
|
forOf: v(5),
|
172
176
|
destructuring: v(6),
|
@@ -206,6 +210,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
206
210
|
|
207
211
|
globalThis: v(5),
|
208
212
|
const: v(1, 1),
|
213
|
+
templateLiteral: v(1, 1),
|
214
|
+
optionalChaining: v(8),
|
209
215
|
arrowFunction: v(1, 1),
|
210
216
|
forOf: v(0, 36),
|
211
217
|
destructuring: v(1, 1),
|
@@ -241,6 +247,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
241
247
|
|
242
248
|
globalThis: v(0, 43),
|
243
249
|
const: v(0, 15),
|
250
|
+
templateLiteral: v(0, 13),
|
251
|
+
optionalChaining: v(0, 44),
|
244
252
|
arrowFunction: v(0, 15),
|
245
253
|
forOf: v(0, 13),
|
246
254
|
destructuring: v(0, 15),
|
@@ -260,6 +268,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
260
268
|
if (v < 1000) v = v + 2009;
|
261
269
|
return {
|
262
270
|
const: v >= 2015,
|
271
|
+
templateLiteral: v >= 2015,
|
272
|
+
optionalChaining: v >= 2020,
|
263
273
|
arrowFunction: v >= 2015,
|
264
274
|
forOf: v >= 2015,
|
265
275
|
destructuring: v >= 2015,
|
@@ -10,6 +10,7 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
10
10
|
const Module = require("../Module");
|
11
11
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
12
12
|
const Template = require("../Template");
|
13
|
+
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
13
14
|
const makeSerializable = require("../util/makeSerializable");
|
14
15
|
const ContainerExposedDependency = require("./ContainerExposedDependency");
|
15
16
|
|
@@ -78,12 +79,14 @@ class ContainerEntryModule extends Module {
|
|
78
79
|
* @returns {string | null} an identifier for library inclusion
|
79
80
|
*/
|
80
81
|
libIdent(options) {
|
81
|
-
return `webpack/container/entry/${
|
82
|
+
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/entry/${
|
83
|
+
this._name
|
84
|
+
}`;
|
82
85
|
}
|
83
86
|
|
84
87
|
/**
|
85
88
|
* @param {NeedBuildContext} context context info
|
86
|
-
* @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
|
87
90
|
* @returns {void}
|
88
91
|
*/
|
89
92
|
needBuild(context, callback) {
|
@@ -104,6 +107,7 @@ class ContainerEntryModule extends Module {
|
|
104
107
|
strict: true,
|
105
108
|
topLevelDeclarations: new Set(["moduleMap", "get", "init"])
|
106
109
|
};
|
110
|
+
this.buildMeta.exportsType = "namespace";
|
107
111
|
|
108
112
|
this.clearDependenciesAndBlocks();
|
109
113
|
|
@@ -127,6 +131,7 @@ class ContainerEntryModule extends Module {
|
|
127
131
|
}
|
128
132
|
this.addBlock(block);
|
129
133
|
}
|
134
|
+
this.addDependency(new StaticExportsDependency(["get", "init"], false));
|
130
135
|
|
131
136
|
callback();
|
132
137
|
}
|
@@ -217,10 +222,8 @@ class ContainerEntryModule extends Module {
|
|
217
222
|
])};`,
|
218
223
|
`var init = ${runtimeTemplate.basicFunction("shareScope, initScope", [
|
219
224
|
`if (!${RuntimeGlobals.shareScopeMap}) return;`,
|
220
|
-
`var oldScope = ${RuntimeGlobals.shareScopeMap}[${JSON.stringify(
|
221
|
-
this._shareScope
|
222
|
-
)}];`,
|
223
225
|
`var name = ${JSON.stringify(this._shareScope)}`,
|
226
|
+
`var oldScope = ${RuntimeGlobals.shareScopeMap}[name];`,
|
224
227
|
`if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope");`,
|
225
228
|
`${RuntimeGlobals.shareScopeMap}[name] = shareScope;`,
|
226
229
|
`return ${RuntimeGlobals.initializeSharing}(name, initScope);`
|
@@ -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) {
|
@@ -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/${
|
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) {
|