webpack 5.105.4 → 5.106.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.
- package/README.md +3 -6
- package/lib/BannerPlugin.js +13 -13
- package/lib/Chunk.js +25 -0
- package/lib/ChunkGraph.js +8 -4
- package/lib/CleanPlugin.js +23 -20
- package/lib/CompatibilityPlugin.js +1 -1
- package/lib/Compilation.js +34 -11
- package/lib/Compiler.js +59 -1
- package/lib/CssModule.js +17 -2
- package/lib/Dependency.js +1 -1
- package/lib/DllPlugin.js +17 -17
- package/lib/DllReferencePlugin.js +20 -18
- package/lib/DotenvPlugin.js +29 -27
- package/lib/ExternalModule.js +39 -6
- package/lib/FileSystemInfo.js +3 -1
- package/lib/IgnorePlugin.js +12 -11
- package/lib/LoaderOptionsPlugin.js +17 -15
- package/lib/ManifestPlugin.js +27 -25
- package/lib/Module.js +69 -4
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleParseError.js +1 -1
- package/lib/ModuleTypeConstants.js +1 -1
- package/lib/NormalModule.js +7 -3
- package/lib/NormalModuleFactory.js +20 -1
- package/lib/ProgressPlugin.js +39 -29
- package/lib/RuntimeGlobals.js +6 -0
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +13 -11
- package/lib/TemplatedPathPlugin.js +4 -3
- package/lib/WatchIgnorePlugin.js +15 -13
- package/lib/WebpackOptionsApply.js +4 -4
- package/lib/asset/AssetModulesPlugin.js +50 -29
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +27 -13
- package/lib/config/normalization.js +3 -2
- package/lib/container/ContainerPlugin.js +46 -42
- package/lib/container/ContainerReferencePlugin.js +42 -26
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +17 -13
- package/lib/css/CssGenerator.js +306 -192
- package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
- package/lib/css/CssLoadingRuntimeModule.js +1 -4
- package/lib/css/CssModulesPlugin.js +197 -98
- package/lib/css/CssParser.js +231 -134
- package/lib/css/walkCssTokens.js +115 -12
- package/lib/debug/ProfilingPlugin.js +16 -13
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
- package/lib/dependencies/CommonJsExportsDependency.js +1 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
- package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
- package/lib/dependencies/CommonJsRequireDependency.js +42 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +210 -87
- package/lib/dependencies/CssIcssImportDependency.js +13 -70
- package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
- package/lib/dependencies/HarmonyExportExpressionDependency.js +28 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +21 -8
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
- package/lib/dependencies/ImportContextDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +16 -2
- package/lib/dependencies/ImportMetaPlugin.js +39 -29
- package/lib/dependencies/ImportParserPlugin.js +4 -5
- package/lib/dependencies/ImportPhase.js +65 -22
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
- package/lib/ids/HashedModuleIdsPlugin.js +21 -23
- package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
- package/lib/javascript/JavascriptModulesPlugin.js +38 -12
- package/lib/javascript/JavascriptParser.js +5 -3
- package/lib/json/JsonModulesPlugin.js +28 -21
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +35 -13
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
- package/lib/optimize/ConcatenatedModule.js +4 -3
- package/lib/optimize/InnerGraphPlugin.js +11 -5
- package/lib/optimize/LimitChunkCountPlugin.js +22 -18
- package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
- package/lib/optimize/MinChunkSizePlugin.js +20 -16
- package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +20 -11
- package/lib/schemes/VirtualUrlPlugin.js +77 -30
- package/lib/serialization/FileMiddleware.js +7 -7
- package/lib/sharing/ConsumeSharedPlugin.js +32 -25
- package/lib/sharing/ProvideSharedPlugin.js +29 -25
- package/lib/util/{propertyName.js → property.js} +26 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
- package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
- package/lib/web/JsonpTemplatePlugin.js +1 -0
- package/lib/webpack.js +34 -4
- package/package.json +18 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +82 -22
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
- package/types.d.ts +511 -114
- package/lib/util/create-schema-validation.js +0 -41
- package/lib/util/propertyAccess.js +0 -30
package/lib/WatchIgnorePlugin.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const { groupBy } = require("./util/ArrayHelpers");
|
|
9
|
-
const createSchemaValidation = require("./util/create-schema-validation");
|
|
10
9
|
|
|
11
10
|
/** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
|
|
12
11
|
/** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
|
|
@@ -15,15 +14,6 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
15
14
|
/** @typedef {import("./util/fs").WatchMethod} WatchMethod */
|
|
16
15
|
/** @typedef {import("./util/fs").Watcher} Watcher */
|
|
17
16
|
|
|
18
|
-
const validate = createSchemaValidation(
|
|
19
|
-
require("../schemas/plugins/WatchIgnorePlugin.check"),
|
|
20
|
-
() => require("../schemas/plugins/WatchIgnorePlugin.json"),
|
|
21
|
-
{
|
|
22
|
-
name: "Watch Ignore Plugin",
|
|
23
|
-
baseDataPath: "options"
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
17
|
const IGNORE_TIME_ENTRY = "ignore";
|
|
28
18
|
|
|
29
19
|
class IgnoringWatchFileSystem {
|
|
@@ -132,8 +122,8 @@ class WatchIgnorePlugin {
|
|
|
132
122
|
* @param {WatchIgnorePluginOptions} options options
|
|
133
123
|
*/
|
|
134
124
|
constructor(options) {
|
|
135
|
-
|
|
136
|
-
this.
|
|
125
|
+
/** @type {WatchIgnorePluginOptions} */
|
|
126
|
+
this.options = options;
|
|
137
127
|
}
|
|
138
128
|
|
|
139
129
|
/**
|
|
@@ -142,11 +132,23 @@ class WatchIgnorePlugin {
|
|
|
142
132
|
* @returns {void}
|
|
143
133
|
*/
|
|
144
134
|
apply(compiler) {
|
|
135
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
136
|
+
compiler.validate(
|
|
137
|
+
() => require("../schemas/plugins/WatchIgnorePlugin.json"),
|
|
138
|
+
this.options,
|
|
139
|
+
{
|
|
140
|
+
name: "Watch Ignore Plugin",
|
|
141
|
+
baseDataPath: "options"
|
|
142
|
+
},
|
|
143
|
+
(options) =>
|
|
144
|
+
require("../schemas/plugins/WatchIgnorePlugin.check")(options)
|
|
145
|
+
);
|
|
146
|
+
});
|
|
145
147
|
compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => {
|
|
146
148
|
compiler.watchFileSystem = new IgnoringWatchFileSystem(
|
|
147
149
|
/** @type {WatchFileSystem} */
|
|
148
150
|
(compiler.watchFileSystem),
|
|
149
|
-
this.paths
|
|
151
|
+
this.options.paths
|
|
150
152
|
);
|
|
151
153
|
});
|
|
152
154
|
}
|
|
@@ -442,7 +442,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
442
442
|
const NormalModuleReplacementPlugin = require("./NormalModuleReplacementPlugin");
|
|
443
443
|
|
|
444
444
|
// Override emitter that using `EventEmitter` to `EventTarget`
|
|
445
|
-
// TODO
|
|
445
|
+
// TODO webpack 6 - migrate to `EventTarget` by default
|
|
446
446
|
new NormalModuleReplacementPlugin(/emitter(\.js)?$/, (result) => {
|
|
447
447
|
if (
|
|
448
448
|
/webpack[/\\]hot|webpack-dev-server[/\\]client|webpack-hot-middleware[/\\]client/.test(
|
|
@@ -487,15 +487,15 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
if (
|
|
490
|
-
options.experiments.deferImport &&
|
|
491
490
|
!(
|
|
492
491
|
/** @type {typeof JavascriptParser & { __importPhasesExtended?: true }} */
|
|
493
492
|
(JavascriptParser).__importPhasesExtended
|
|
494
|
-
)
|
|
493
|
+
) &&
|
|
494
|
+
(options.experiments.deferImport || options.experiments.sourceImport)
|
|
495
495
|
) {
|
|
496
496
|
const importPhases = require("acorn-import-phases");
|
|
497
497
|
|
|
498
|
-
JavascriptParser.extend(importPhases({ source:
|
|
498
|
+
JavascriptParser.extend(importPhases({ source: true, defer: true }));
|
|
499
499
|
/** @type {typeof JavascriptParser & { __importPhasesExtended?: true }} */
|
|
500
500
|
(JavascriptParser).__importPhasesExtended = true;
|
|
501
501
|
}
|
|
@@ -13,7 +13,6 @@ const {
|
|
|
13
13
|
ASSET_MODULE_TYPE_SOURCE
|
|
14
14
|
} = require("../ModuleTypeConstants");
|
|
15
15
|
const { compareModulesByFullName } = require("../util/comparators");
|
|
16
|
-
const createSchemaValidation = require("../util/create-schema-validation");
|
|
17
16
|
const memoize = require("../util/memoize");
|
|
18
17
|
|
|
19
18
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
@@ -46,32 +45,6 @@ const generatorValidationOptions = {
|
|
|
46
45
|
name: "Asset Modules Plugin",
|
|
47
46
|
baseDataPath: "generator"
|
|
48
47
|
};
|
|
49
|
-
const validateGeneratorOptions = {
|
|
50
|
-
asset: createSchemaValidation(
|
|
51
|
-
require("../../schemas/plugins/asset/AssetGeneratorOptions.check"),
|
|
52
|
-
() => getSchema("AssetGeneratorOptions"),
|
|
53
|
-
generatorValidationOptions
|
|
54
|
-
),
|
|
55
|
-
"asset/resource": createSchemaValidation(
|
|
56
|
-
require("../../schemas/plugins/asset/AssetResourceGeneratorOptions.check"),
|
|
57
|
-
() => getSchema("AssetResourceGeneratorOptions"),
|
|
58
|
-
generatorValidationOptions
|
|
59
|
-
),
|
|
60
|
-
"asset/inline": createSchemaValidation(
|
|
61
|
-
require("../../schemas/plugins/asset/AssetInlineGeneratorOptions.check"),
|
|
62
|
-
() => getSchema("AssetInlineGeneratorOptions"),
|
|
63
|
-
generatorValidationOptions
|
|
64
|
-
)
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const validateParserOptions = createSchemaValidation(
|
|
68
|
-
require("../../schemas/plugins/asset/AssetParserOptions.check"),
|
|
69
|
-
() => getSchema("AssetParserOptions"),
|
|
70
|
-
{
|
|
71
|
-
name: "Asset Modules Plugin",
|
|
72
|
-
baseDataPath: "parser"
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
48
|
|
|
76
49
|
const getAssetGenerator = memoize(() => require("./AssetGenerator"));
|
|
77
50
|
const getAssetParser = memoize(() => require("./AssetParser"));
|
|
@@ -135,7 +108,18 @@ class AssetModulesPlugin {
|
|
|
135
108
|
normalModuleFactory.hooks.createParser
|
|
136
109
|
.for(ASSET_MODULE_TYPE)
|
|
137
110
|
.tap(PLUGIN_NAME, (parserOptions) => {
|
|
138
|
-
|
|
111
|
+
compiler.validate(
|
|
112
|
+
() => getSchema("AssetParserOptions"),
|
|
113
|
+
parserOptions,
|
|
114
|
+
{
|
|
115
|
+
name: "Asset Modules Plugin",
|
|
116
|
+
baseDataPath: "parser"
|
|
117
|
+
},
|
|
118
|
+
(options) =>
|
|
119
|
+
require("../../schemas/plugins/asset/AssetParserOptions.check")(
|
|
120
|
+
options
|
|
121
|
+
)
|
|
122
|
+
);
|
|
139
123
|
|
|
140
124
|
let dataUrlCondition = parserOptions.dataUrlCondition;
|
|
141
125
|
if (!dataUrlCondition || typeof dataUrlCondition === "object") {
|
|
@@ -186,7 +170,44 @@ class AssetModulesPlugin {
|
|
|
186
170
|
normalModuleFactory.hooks.createGenerator
|
|
187
171
|
.for(type)
|
|
188
172
|
.tap(PLUGIN_NAME, (generatorOptions) => {
|
|
189
|
-
|
|
173
|
+
switch (type) {
|
|
174
|
+
case ASSET_MODULE_TYPE: {
|
|
175
|
+
compiler.validate(
|
|
176
|
+
() => getSchema("AssetGeneratorOptions"),
|
|
177
|
+
generatorOptions,
|
|
178
|
+
generatorValidationOptions,
|
|
179
|
+
(options) =>
|
|
180
|
+
require("../../schemas/plugins/asset/AssetGeneratorOptions.check")(
|
|
181
|
+
options
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case ASSET_MODULE_TYPE_RESOURCE: {
|
|
187
|
+
compiler.validate(
|
|
188
|
+
() => getSchema("AssetResourceGeneratorOptions"),
|
|
189
|
+
generatorOptions,
|
|
190
|
+
generatorValidationOptions,
|
|
191
|
+
(options) =>
|
|
192
|
+
require("../../schemas/plugins/asset/AssetResourceGeneratorOptions.check")(
|
|
193
|
+
options
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case ASSET_MODULE_TYPE_INLINE: {
|
|
199
|
+
compiler.validate(
|
|
200
|
+
() => getSchema("AssetInlineGeneratorOptions"),
|
|
201
|
+
generatorOptions,
|
|
202
|
+
generatorValidationOptions,
|
|
203
|
+
(options) =>
|
|
204
|
+
require("../../schemas/plugins/asset/AssetInlineGeneratorOptions.check")(
|
|
205
|
+
options
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
190
211
|
|
|
191
212
|
/** @type {undefined | AssetGeneratorDataUrl} */
|
|
192
213
|
let dataUrl;
|
package/lib/cli.js
CHANGED
|
@@ -603,6 +603,8 @@ const getExpectedValue = (argConfig) => {
|
|
|
603
603
|
|
|
604
604
|
/** @typedef {null | string | number | boolean | RegExp | EnumValue | []} ParsedValue */
|
|
605
605
|
|
|
606
|
+
const DECIMAL_NUMBER_REGEXP = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
607
|
+
|
|
606
608
|
/**
|
|
607
609
|
* @param {ArgumentConfig} argConfig processing instructions
|
|
608
610
|
* @param {Value} value the value
|
|
@@ -622,7 +624,7 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
|
622
624
|
break;
|
|
623
625
|
case "number":
|
|
624
626
|
if (typeof value === "number") return value;
|
|
625
|
-
if (typeof value === "string" &&
|
|
627
|
+
if (typeof value === "string" && DECIMAL_NUMBER_REGEXP.test(value)) {
|
|
626
628
|
const n = Number(value);
|
|
627
629
|
if (!Number.isNaN(n)) return n;
|
|
628
630
|
}
|
package/lib/config/defaults.js
CHANGED
|
@@ -58,8 +58,9 @@ const {
|
|
|
58
58
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
|
|
59
59
|
/** @typedef {import("../../declarations/WebpackOptions").Loader} Loader */
|
|
60
60
|
/** @typedef {import("../../declarations/WebpackOptions").Mode} Mode */
|
|
61
|
+
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
61
62
|
/** @typedef {import("../../declarations/WebpackOptions").HashSalt} HashSalt */
|
|
62
|
-
/** @typedef {import("../../declarations/WebpackOptions").
|
|
63
|
+
/** @typedef {import("../../declarations/WebpackOptions").HashDigest} HashDigest */
|
|
63
64
|
/** @typedef {import("../../declarations/WebpackOptions").HashDigestLength} HashDigestLength */
|
|
64
65
|
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
|
65
66
|
/** @typedef {import("../../declarations/WebpackOptions").Node} WebpackNode */
|
|
@@ -363,6 +364,8 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
363
364
|
/** @type {NonNullable<ExperimentsNormalized["futureDefaults"]>} */
|
|
364
365
|
(options.experiments.futureDefaults);
|
|
365
366
|
|
|
367
|
+
F(options, "validate", () => !(futureDefaults === true && production));
|
|
368
|
+
|
|
366
369
|
F(options, "cache", () =>
|
|
367
370
|
development ? { type: /** @type {"memory"} */ ("memory") } : false
|
|
368
371
|
);
|
|
@@ -405,11 +408,8 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
405
408
|
hashSalt: /** @type {NonNullable<Output["hashSalt"]>} */ (
|
|
406
409
|
options.output.hashSalt
|
|
407
410
|
),
|
|
408
|
-
|
|
409
|
-
options.output.
|
|
410
|
-
),
|
|
411
|
-
hashDigestLength: /** @type {NonNullable<Output["hashDigestLength"]>} */ (
|
|
412
|
-
options.output.hashDigestLength
|
|
411
|
+
hashFunction: /** @type {NonNullable<Output["hashFunction"]>} */ (
|
|
412
|
+
options.output.hashFunction
|
|
413
413
|
),
|
|
414
414
|
syncWebAssembly:
|
|
415
415
|
/** @type {NonNullable<ExperimentsNormalized["syncWebAssembly"]>} */
|
|
@@ -423,6 +423,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
423
423
|
deferImport:
|
|
424
424
|
/** @type {NonNullable<ExperimentsNormalized["deferImport"]>} */
|
|
425
425
|
(options.experiments.deferImport),
|
|
426
|
+
sourceImport:
|
|
427
|
+
/** @type {NonNullable<ExperimentsNormalized["sourceImport"]>} */
|
|
428
|
+
(options.experiments.sourceImport),
|
|
426
429
|
futureDefaults,
|
|
427
430
|
isNode: targetProperties && targetProperties.node === true,
|
|
428
431
|
uniqueName: /** @type {string} */ (options.output.uniqueName),
|
|
@@ -549,6 +552,7 @@ const applyExperimentsDefaults = (
|
|
|
549
552
|
D(experiments, "buildHttp", undefined);
|
|
550
553
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
|
551
554
|
D(experiments, "deferImport", false);
|
|
555
|
+
D(experiments, "sourceImport", false);
|
|
552
556
|
F(experiments, "css", () => (experiments.futureDefaults ? true : undefined));
|
|
553
557
|
|
|
554
558
|
if (typeof experiments.buildHttp === "object") {
|
|
@@ -721,13 +725,14 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
|
|
721
725
|
* @param {object} options options
|
|
722
726
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
|
723
727
|
* @param {boolean} options.deferImport is defer import enabled
|
|
728
|
+
* @param {boolean} options.sourceImport is import source enabled
|
|
724
729
|
* @param {boolean} options.isNode is node target platform
|
|
725
730
|
* @param {boolean} options.outputModule is output.module enabled
|
|
726
731
|
* @returns {void}
|
|
727
732
|
*/
|
|
728
733
|
const applyJavascriptParserOptionsDefaults = (
|
|
729
734
|
parserOptions,
|
|
730
|
-
{ futureDefaults, deferImport, isNode, outputModule }
|
|
735
|
+
{ futureDefaults, deferImport, sourceImport, isNode, outputModule }
|
|
731
736
|
) => {
|
|
732
737
|
D(parserOptions, "unknownContextRequest", ".");
|
|
733
738
|
D(parserOptions, "unknownContextRegExp", false);
|
|
@@ -749,6 +754,7 @@ const applyJavascriptParserOptionsDefaults = (
|
|
|
749
754
|
D(parserOptions, "createRequire", isNode);
|
|
750
755
|
D(parserOptions, "dynamicUrl", true);
|
|
751
756
|
D(parserOptions, "deferImport", deferImport);
|
|
757
|
+
D(parserOptions, "sourceImport", sourceImport);
|
|
752
758
|
if (futureDefaults) D(parserOptions, "exportsPresence", "error");
|
|
753
759
|
};
|
|
754
760
|
|
|
@@ -789,11 +795,11 @@ const applyCssGeneratorOptionsDefaults = (
|
|
|
789
795
|
* @param {string} options.uniqueName the unique name
|
|
790
796
|
* @param {boolean} options.isNode is node target platform
|
|
791
797
|
* @param {boolean} options.deferImport is defer import enabled
|
|
798
|
+
* @param {boolean} options.sourceImport is import source enabled
|
|
792
799
|
* @param {TargetProperties | false} options.targetProperties target properties
|
|
793
800
|
* @param {Mode | undefined} options.mode mode
|
|
794
801
|
* @param {HashSalt} options.hashSalt hash salt
|
|
795
|
-
* @param {
|
|
796
|
-
* @param {HashDigestLength} options.hashDigestLength hash digest length
|
|
802
|
+
* @param {HashFunction} options.hashFunction hash function
|
|
797
803
|
* @param {boolean} options.outputModule is output.module enabled
|
|
798
804
|
* @returns {void}
|
|
799
805
|
*/
|
|
@@ -801,8 +807,7 @@ const applyModuleDefaults = (
|
|
|
801
807
|
module,
|
|
802
808
|
{
|
|
803
809
|
hashSalt,
|
|
804
|
-
|
|
805
|
-
hashDigestLength,
|
|
810
|
+
hashFunction,
|
|
806
811
|
cache,
|
|
807
812
|
syncWebAssembly,
|
|
808
813
|
asyncWebAssembly,
|
|
@@ -813,6 +818,7 @@ const applyModuleDefaults = (
|
|
|
813
818
|
targetProperties,
|
|
814
819
|
mode,
|
|
815
820
|
deferImport,
|
|
821
|
+
sourceImport,
|
|
816
822
|
outputModule
|
|
817
823
|
}
|
|
818
824
|
) => {
|
|
@@ -872,6 +878,7 @@ const applyModuleDefaults = (
|
|
|
872
878
|
{
|
|
873
879
|
futureDefaults,
|
|
874
880
|
deferImport,
|
|
881
|
+
sourceImport,
|
|
875
882
|
isNode,
|
|
876
883
|
outputModule
|
|
877
884
|
}
|
|
@@ -990,6 +997,13 @@ const applyModuleDefaults = (
|
|
|
990
997
|
localIdentHashSalt
|
|
991
998
|
);
|
|
992
999
|
|
|
1000
|
+
D(
|
|
1001
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
|
|
1002
|
+
(module.generator[type]),
|
|
1003
|
+
"localIdentHashFunction",
|
|
1004
|
+
hashFunction
|
|
1005
|
+
);
|
|
1006
|
+
|
|
993
1007
|
D(
|
|
994
1008
|
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
|
|
995
1009
|
(module.generator[type]),
|
|
@@ -1501,7 +1515,7 @@ const applyOutputDefaults = (
|
|
|
1501
1515
|
output.module &&
|
|
1502
1516
|
environment.dynamicImport
|
|
1503
1517
|
) {
|
|
1504
|
-
return "
|
|
1518
|
+
return "import";
|
|
1505
1519
|
}
|
|
1506
1520
|
}
|
|
1507
1521
|
return false;
|
|
@@ -1527,7 +1541,7 @@ const applyOutputDefaults = (
|
|
|
1527
1541
|
output.module &&
|
|
1528
1542
|
environment.dynamicImportInWorker
|
|
1529
1543
|
) {
|
|
1530
|
-
return "
|
|
1544
|
+
return "import";
|
|
1531
1545
|
}
|
|
1532
1546
|
}
|
|
1533
1547
|
return false;
|
|
@@ -364,7 +364,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
364
364
|
importFunctionName: output.importFunctionName,
|
|
365
365
|
importMetaName: output.importMetaName,
|
|
366
366
|
scriptType: output.scriptType,
|
|
367
|
-
// TODO
|
|
367
|
+
// TODO webpack 6 remove `libraryTarget`/`auxiliaryComment`/`amdContainer`/etc in favor of the `library` option
|
|
368
368
|
library: libraryBase && {
|
|
369
369
|
type:
|
|
370
370
|
output.libraryTarget !== undefined
|
|
@@ -416,6 +416,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
416
416
|
return result;
|
|
417
417
|
}),
|
|
418
418
|
parallelism: config.parallelism,
|
|
419
|
+
validate: config.validate,
|
|
419
420
|
performance: optionalNestedConfig(config.performance, (performance) => {
|
|
420
421
|
if (performance === false) return false;
|
|
421
422
|
return {
|
|
@@ -599,7 +600,7 @@ const applyWebpackOptionsInterception = (options) => {
|
|
|
599
600
|
};
|
|
600
601
|
}
|
|
601
602
|
|
|
602
|
-
// TODO
|
|
603
|
+
// TODO webpack 6 - remove compatibility logic and move `devtools` fully into `devtool` with multi-type support
|
|
603
604
|
let _devtool = options.devtool;
|
|
604
605
|
/** @type {WebpackOptionsNormalized["devtool"]} */
|
|
605
606
|
let cached;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const createSchemaValidation = require("../util/create-schema-validation");
|
|
9
8
|
const memoize = require("../util/memoize");
|
|
10
9
|
const ContainerEntryDependency = require("./ContainerEntryDependency");
|
|
11
10
|
const ContainerEntryModuleFactory = require("./ContainerEntryModuleFactory");
|
|
@@ -20,15 +19,6 @@ const getModuleFederationPlugin = memoize(() =>
|
|
|
20
19
|
require("./ModuleFederationPlugin")
|
|
21
20
|
);
|
|
22
21
|
|
|
23
|
-
const validate = createSchemaValidation(
|
|
24
|
-
require("../../schemas/plugins/container/ContainerPlugin.check"),
|
|
25
|
-
() => require("../../schemas/plugins/container/ContainerPlugin.json"),
|
|
26
|
-
{
|
|
27
|
-
name: "Container Plugin",
|
|
28
|
-
baseDataPath: "options"
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
22
|
const PLUGIN_NAME = "ContainerPlugin";
|
|
33
23
|
|
|
34
24
|
class ContainerPlugin {
|
|
@@ -36,31 +26,8 @@ class ContainerPlugin {
|
|
|
36
26
|
* @param {ContainerPluginOptions} options options
|
|
37
27
|
*/
|
|
38
28
|
constructor(options) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this._options = {
|
|
42
|
-
name: options.name,
|
|
43
|
-
shareScope: options.shareScope || "default",
|
|
44
|
-
library: options.library || {
|
|
45
|
-
type: "var",
|
|
46
|
-
name: options.name
|
|
47
|
-
},
|
|
48
|
-
runtime: options.runtime,
|
|
49
|
-
filename: options.filename || undefined,
|
|
50
|
-
exposes: /** @type {ExposesList} */ (
|
|
51
|
-
parseOptions(
|
|
52
|
-
options.exposes,
|
|
53
|
-
(item) => ({
|
|
54
|
-
import: Array.isArray(item) ? item : [item],
|
|
55
|
-
name: undefined
|
|
56
|
-
}),
|
|
57
|
-
(item) => ({
|
|
58
|
-
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
59
|
-
name: item.name || undefined
|
|
60
|
-
})
|
|
61
|
-
)
|
|
62
|
-
)
|
|
63
|
-
};
|
|
29
|
+
/** @type {ContainerPluginOptions} */
|
|
30
|
+
this.options = options;
|
|
64
31
|
}
|
|
65
32
|
|
|
66
33
|
/**
|
|
@@ -69,25 +36,62 @@ class ContainerPlugin {
|
|
|
69
36
|
* @returns {void}
|
|
70
37
|
*/
|
|
71
38
|
apply(compiler) {
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
40
|
+
compiler.validate(
|
|
41
|
+
() => require("../../schemas/plugins/container/ContainerPlugin.json"),
|
|
42
|
+
this.options,
|
|
43
|
+
{
|
|
44
|
+
name: "Container Plugin",
|
|
45
|
+
baseDataPath: "options"
|
|
46
|
+
},
|
|
47
|
+
(options) =>
|
|
48
|
+
require("../../schemas/plugins/container/ContainerPlugin.check")(
|
|
49
|
+
options
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const library = this.options.library || {
|
|
55
|
+
type: "var",
|
|
56
|
+
name: this.options.name
|
|
57
|
+
};
|
|
74
58
|
|
|
75
59
|
if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) {
|
|
76
60
|
compiler.options.output.enabledLibraryTypes.push(library.type);
|
|
77
61
|
}
|
|
78
62
|
|
|
63
|
+
const exposes = /** @type {ExposesList} */ (
|
|
64
|
+
parseOptions(
|
|
65
|
+
this.options.exposes,
|
|
66
|
+
(item) => ({
|
|
67
|
+
import: Array.isArray(item) ? item : [item],
|
|
68
|
+
name: undefined
|
|
69
|
+
}),
|
|
70
|
+
(item) => ({
|
|
71
|
+
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
72
|
+
name: item.name || undefined
|
|
73
|
+
})
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const shareScope = this.options.shareScope || "default";
|
|
78
|
+
|
|
79
79
|
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
|
|
80
80
|
const hooks =
|
|
81
81
|
getModuleFederationPlugin().getCompilationHooks(compilation);
|
|
82
|
-
const dep = new ContainerEntryDependency(
|
|
83
|
-
|
|
82
|
+
const dep = new ContainerEntryDependency(
|
|
83
|
+
this.options.name,
|
|
84
|
+
exposes,
|
|
85
|
+
shareScope
|
|
86
|
+
);
|
|
87
|
+
dep.loc = { name: this.options.name };
|
|
84
88
|
compilation.addEntry(
|
|
85
89
|
compilation.options.context,
|
|
86
90
|
dep,
|
|
87
91
|
{
|
|
88
|
-
name,
|
|
89
|
-
filename,
|
|
90
|
-
runtime,
|
|
92
|
+
name: this.options.name,
|
|
93
|
+
filename: this.options.filename,
|
|
94
|
+
runtime: this.options.runtime,
|
|
91
95
|
library
|
|
92
96
|
},
|
|
93
97
|
(error) => {
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const ExternalModule = require("../ExternalModule");
|
|
8
9
|
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
9
10
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
|
-
const createSchemaValidation = require("../util/create-schema-validation");
|
|
11
11
|
const FallbackDependency = require("./FallbackDependency");
|
|
12
12
|
const FallbackItemDependency = require("./FallbackItemDependency");
|
|
13
13
|
const FallbackModuleFactory = require("./FallbackModuleFactory");
|
|
@@ -19,16 +19,6 @@ const { parseOptions } = require("./options");
|
|
|
19
19
|
/** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").ContainerReferencePluginOptions} ContainerReferencePluginOptions */
|
|
20
20
|
/** @typedef {import("../Compiler")} Compiler */
|
|
21
21
|
|
|
22
|
-
const validate = createSchemaValidation(
|
|
23
|
-
require("../../schemas/plugins/container/ContainerReferencePlugin.check"),
|
|
24
|
-
() =>
|
|
25
|
-
require("../../schemas/plugins/container/ContainerReferencePlugin.json"),
|
|
26
|
-
{
|
|
27
|
-
name: "Container Reference Plugin",
|
|
28
|
-
baseDataPath: "options"
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
22
|
const slashCode = "/".charCodeAt(0);
|
|
33
23
|
const PLUGIN_NAME = "ContainerReferencePlugin";
|
|
34
24
|
|
|
@@ -37,31 +27,46 @@ class ContainerReferencePlugin {
|
|
|
37
27
|
* @param {ContainerReferencePluginOptions} options options
|
|
38
28
|
*/
|
|
39
29
|
constructor(options) {
|
|
40
|
-
|
|
30
|
+
/** @typedef {ContainerReferencePluginOptions} */
|
|
31
|
+
this.options = options;
|
|
32
|
+
}
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Apply the plugin
|
|
36
|
+
* @param {Compiler} compiler the compiler instance
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
apply(compiler) {
|
|
40
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
41
|
+
compiler.validate(
|
|
42
|
+
() =>
|
|
43
|
+
require("../../schemas/plugins/container/ContainerReferencePlugin.json"),
|
|
44
|
+
this.options,
|
|
45
|
+
{
|
|
46
|
+
name: "Container Reference Plugin",
|
|
47
|
+
baseDataPath: "options"
|
|
48
|
+
},
|
|
49
|
+
(options) =>
|
|
50
|
+
require("../../schemas/plugins/container/ContainerReferencePlugin.check")(
|
|
51
|
+
options
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const { remoteType } = this.options;
|
|
57
|
+
const remotes = parseOptions(
|
|
58
|
+
this.options.remotes,
|
|
45
59
|
(item) => ({
|
|
46
60
|
external: Array.isArray(item) ? item : [item],
|
|
47
|
-
shareScope: options.shareScope || "default"
|
|
61
|
+
shareScope: this.options.shareScope || "default"
|
|
48
62
|
}),
|
|
49
63
|
(item) => ({
|
|
50
64
|
external: Array.isArray(item.external)
|
|
51
65
|
? item.external
|
|
52
66
|
: [item.external],
|
|
53
|
-
shareScope: item.shareScope || options.shareScope || "default"
|
|
67
|
+
shareScope: item.shareScope || this.options.shareScope || "default"
|
|
54
68
|
})
|
|
55
69
|
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Apply the plugin
|
|
60
|
-
* @param {Compiler} compiler the compiler instance
|
|
61
|
-
* @returns {void}
|
|
62
|
-
*/
|
|
63
|
-
apply(compiler) {
|
|
64
|
-
const { _remotes: remotes, _remoteType: remoteType } = this;
|
|
65
70
|
|
|
66
71
|
/** @type {Record<string, string>} */
|
|
67
72
|
const remoteExternals = {};
|
|
@@ -131,6 +136,17 @@ class ContainerReferencePlugin {
|
|
|
131
136
|
set.add(RuntimeGlobals.shareScopeMap);
|
|
132
137
|
compilation.addRuntimeModule(chunk, new RemoteRuntimeModule());
|
|
133
138
|
});
|
|
139
|
+
|
|
140
|
+
const { chunkCondition } =
|
|
141
|
+
ExternalModule.getCompilationHooks(compilation);
|
|
142
|
+
|
|
143
|
+
// External modules issued by remote modules should be placed in entry chunks
|
|
144
|
+
// to ensure they are loaded and initialize first
|
|
145
|
+
chunkCondition.tap(
|
|
146
|
+
PLUGIN_NAME,
|
|
147
|
+
(chunk, compilation) =>
|
|
148
|
+
compilation.chunkGraph.getNumberOfEntryModules(chunk) > 0
|
|
149
|
+
);
|
|
134
150
|
}
|
|
135
151
|
);
|
|
136
152
|
}
|
|
@@ -79,7 +79,7 @@ class FallbackModule extends Module {
|
|
|
79
79
|
/**
|
|
80
80
|
* @param {Chunk} chunk the chunk which condition should be checked
|
|
81
81
|
* @param {Compilation} compilation the compilation
|
|
82
|
-
* @returns {boolean} true
|
|
82
|
+
* @returns {boolean} true if the module can be placed in the chunk
|
|
83
83
|
*/
|
|
84
84
|
chunkCondition(chunk, { chunkGraph }) {
|
|
85
85
|
return chunkGraph.getNumberOfEntryModules(chunk) > 0;
|
|
@@ -9,7 +9,6 @@ const { SyncHook } = require("tapable");
|
|
|
9
9
|
const isValidExternalsType = require("../../schemas/plugins/container/ExternalsType.check");
|
|
10
10
|
const Compilation = require("../Compilation");
|
|
11
11
|
const SharePlugin = require("../sharing/SharePlugin");
|
|
12
|
-
const createSchemaValidation = require("../util/create-schema-validation");
|
|
13
12
|
const ContainerPlugin = require("./ContainerPlugin");
|
|
14
13
|
const ContainerReferencePlugin = require("./ContainerReferencePlugin");
|
|
15
14
|
const HoistContainerReferences = require("./HoistContainerReferencesPlugin");
|
|
@@ -25,15 +24,6 @@ const HoistContainerReferences = require("./HoistContainerReferencesPlugin");
|
|
|
25
24
|
* @property {SyncHook<Dependency>} addFederationRuntimeDependency
|
|
26
25
|
*/
|
|
27
26
|
|
|
28
|
-
const validate = createSchemaValidation(
|
|
29
|
-
require("../../schemas/plugins/container/ModuleFederationPlugin.check"),
|
|
30
|
-
() => require("../../schemas/plugins/container/ModuleFederationPlugin.json"),
|
|
31
|
-
{
|
|
32
|
-
name: "Module Federation Plugin",
|
|
33
|
-
baseDataPath: "options"
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
27
|
/** @type {WeakMap<Compilation, CompilationHooks>} */
|
|
38
28
|
const compilationHooksMap = new WeakMap();
|
|
39
29
|
const PLUGIN_NAME = "ModuleFederationPlugin";
|
|
@@ -43,9 +33,8 @@ class ModuleFederationPlugin {
|
|
|
43
33
|
* @param {ModuleFederationPluginOptions} options options
|
|
44
34
|
*/
|
|
45
35
|
constructor(options) {
|
|
46
|
-
validate(options);
|
|
47
36
|
/** @type {ModuleFederationPluginOptions} */
|
|
48
|
-
this.
|
|
37
|
+
this.options = options;
|
|
49
38
|
}
|
|
50
39
|
|
|
51
40
|
/**
|
|
@@ -76,7 +65,22 @@ class ModuleFederationPlugin {
|
|
|
76
65
|
* @returns {void}
|
|
77
66
|
*/
|
|
78
67
|
apply(compiler) {
|
|
79
|
-
|
|
68
|
+
compiler.hooks.validate.tap(PLUGIN_NAME, () => {
|
|
69
|
+
compiler.validate(
|
|
70
|
+
() =>
|
|
71
|
+
require("../../schemas/plugins/container/ModuleFederationPlugin.json"),
|
|
72
|
+
this.options,
|
|
73
|
+
{
|
|
74
|
+
name: "Module Federation Plugin",
|
|
75
|
+
baseDataPath: "options"
|
|
76
|
+
},
|
|
77
|
+
(options) =>
|
|
78
|
+
require("../../schemas/plugins/container/ModuleFederationPlugin.check")(
|
|
79
|
+
options
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
const { options } = this;
|
|
80
84
|
const library = options.library || { type: "var", name: options.name };
|
|
81
85
|
const remoteType =
|
|
82
86
|
options.remoteType ||
|