webpack 5.105.3 → 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 +36 -13
- 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 +84 -4
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleParseError.js +1 -1
- package/lib/ModuleTypeConstants.js +1 -1
- package/lib/MultiStats.js +5 -5
- 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/RuntimeModule.js +18 -1
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +13 -11
- package/lib/Stats.js +3 -2
- 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/container/RemoteModule.js +18 -1
- package/lib/css/CssGenerator.js +315 -191
- 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/CreateRequireParserPlugin.js +11 -0
- 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 +124 -205
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +12 -6
- 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 +6 -2
- 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/ModuleConcatenationPlugin.js +4 -1
- 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/ConsumeSharedModule.js +18 -1
- package/lib/sharing/ConsumeSharedPlugin.js +32 -25
- package/lib/sharing/ProvideSharedPlugin.js +29 -25
- package/lib/util/AppendOnlyStackedSet.js +22 -1
- 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 +20 -18
- 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 +606 -150
- package/lib/util/create-schema-validation.js +0 -41
- package/lib/util/propertyAccess.js +0 -30
|
@@ -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 ||
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
const { RawSource } = require("webpack-sources");
|
|
9
9
|
const Module = require("../Module");
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
JAVASCRIPT_TYPES,
|
|
12
|
+
REMOTE_AND_SHARE_INIT_TYPES
|
|
13
|
+
} = require("../ModuleSourceTypeConstants");
|
|
11
14
|
const { WEBPACK_MODULE_TYPE_REMOTE } = require("../ModuleTypeConstants");
|
|
12
15
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
13
16
|
const makeSerializable = require("../util/makeSerializable");
|
|
@@ -34,6 +37,7 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
|
|
|
34
37
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
35
38
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
36
39
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
40
|
+
/** @typedef {import("../Module").BasicSourceTypes} BasicSourceTypes */
|
|
37
41
|
|
|
38
42
|
const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
|
|
39
43
|
|
|
@@ -137,6 +141,19 @@ class RemoteModule extends Module {
|
|
|
137
141
|
return REMOTE_AND_SHARE_INIT_TYPES;
|
|
138
142
|
}
|
|
139
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Basic source types are high-level categories like javascript, css, webassembly, etc.
|
|
146
|
+
* We only have built-in knowledge about the javascript basic type here; other basic types may be
|
|
147
|
+
* added or changed over time by generators and do not need to be handled or detected here.
|
|
148
|
+
*
|
|
149
|
+
* Some modules, e.g. RemoteModule, may return non-basic source types like "remote" and "share-init"
|
|
150
|
+
* from getSourceTypes(), but their generated output is still JavaScript, i.e. their basic type is JS.
|
|
151
|
+
* @returns {BasicSourceTypes} types available (do not mutate)
|
|
152
|
+
*/
|
|
153
|
+
getSourceBasicTypes() {
|
|
154
|
+
return JAVASCRIPT_TYPES;
|
|
155
|
+
}
|
|
156
|
+
|
|
140
157
|
/**
|
|
141
158
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
142
159
|
* @param {boolean | undefined} strict the importing module is strict
|