webpack 5.99.6 → 5.99.8
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/lib/AutomaticPrefetchPlugin.js +21 -22
- package/lib/BannerPlugin.js +31 -35
- package/lib/CleanPlugin.js +5 -3
- package/lib/Compilation.js +21 -15
- package/lib/Compiler.js +2 -1
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextModule.js +1 -1
- package/lib/ContextModuleFactory.js +1 -2
- package/lib/ContextReplacementPlugin.js +7 -4
- package/lib/DefinePlugin.js +2 -2
- package/lib/DelegatedModule.js +18 -8
- package/lib/DelegatedModuleFactoryPlugin.js +9 -7
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllPlugin.js +5 -3
- package/lib/DllReferencePlugin.js +56 -60
- package/lib/DynamicEntryPlugin.js +4 -2
- package/lib/EntryOptionPlugin.js +3 -1
- package/lib/EntryPlugin.js +4 -2
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/EvalDevToolModulePlugin.js +9 -7
- package/lib/EvalSourceMapDevToolPlugin.js +138 -139
- package/lib/ExportsInfo.js +35 -16
- package/lib/ExternalModule.js +6 -5
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FileSystemInfo.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +2 -1
- package/lib/IgnorePlugin.js +6 -4
- package/lib/IgnoreWarningsPlugin.js +4 -2
- package/lib/LibManifestPlugin.js +5 -6
- package/lib/LoaderOptionsPlugin.js +4 -2
- package/lib/LoaderTargetPlugin.js +4 -2
- package/lib/Module.js +19 -12
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +13 -8
- package/lib/NormalModuleReplacementPlugin.js +33 -36
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +4 -2
- package/lib/ProgressPlugin.js +23 -26
- package/lib/RecordIdsPlugin.js +72 -102
- package/lib/RuntimePlugin.js +34 -32
- package/lib/SourceMapDevToolPlugin.js +9 -8
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +3 -1
- package/lib/WebpackError.js +11 -3
- package/lib/WebpackOptionsApply.js +6 -7
- package/lib/asset/AssetGenerator.js +2 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/cache/IdleFileCachePlugin.js +11 -12
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
- package/lib/cache/ResolverCachePlugin.js +8 -6
- package/lib/cli.js +5 -1
- package/lib/config/defaults.js +10 -6
- package/lib/config/normalization.js +14 -8
- package/lib/container/ContainerReferencePlugin.js +24 -26
- package/lib/container/ModuleFederationPlugin.js +2 -1
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssModulesPlugin.js +8 -6
- package/lib/debug/ProfilingPlugin.js +18 -21
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
- package/lib/dependencies/LoaderPlugin.js +5 -3
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -2
- package/lib/hmr/LazyCompilationPlugin.js +17 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
- package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
- package/lib/ids/HashedModuleIdsPlugin.js +4 -2
- package/lib/ids/NamedChunkIdsPlugin.js +4 -2
- package/lib/ids/NamedModuleIdsPlugin.js +4 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
- package/lib/index.js +11 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -2
- package/lib/javascript/JavascriptParser.js +634 -656
- package/lib/json/JsonModulesPlugin.js +4 -4
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +60 -42
- package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/node/nodeConsole.js +3 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
- package/lib/optimize/ConcatenatedModule.js +15 -16
- package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +15 -16
- package/lib/optimize/MinChunkSizePlugin.js +4 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +6 -4
- package/lib/optimize/RealContentHashPlugin.js +4 -2
- package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
- package/lib/optimize/RuntimeChunkPlugin.js +21 -23
- package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
- package/lib/optimize/SplitChunksPlugin.js +9 -7
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- package/lib/rules/BasicEffectRulePlugin.js +1 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +4 -6
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/schemes/DataUriPlugin.js +5 -3
- package/lib/schemes/FileUriPlugin.js +5 -3
- package/lib/schemes/HttpUriPlugin.js +186 -188
- package/lib/serialization/AggregateErrorSerializer.js +42 -0
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/ObjectMiddleware.js +13 -0
- package/lib/sharing/ProvideSharedPlugin.js +6 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
- package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
- package/lib/util/concatenate.js +4 -2
- package/lib/util/createHash.js +3 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
- package/package.json +35 -30
- package/schemas/WebpackOptions.check.d.ts +1 -1
- package/schemas/WebpackOptions.check.js +2 -2
- package/schemas/WebpackOptions.json +267 -26
- package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/DllPlugin.check.d.ts +1 -1
- package/schemas/plugins/DllPlugin.check.js +1 -1
- package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
- package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
- package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
- package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +587 -207
- package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
- package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginParser.json +0 -16
@@ -16,8 +16,8 @@ const JsonParser = require("./JsonParser");
|
|
16
16
|
/** @typedef {import("../util/fs").JsonValue} JsonValue */
|
17
17
|
|
18
18
|
const validate = createSchemaValidation(
|
19
|
-
require("../../schemas/plugins/JsonModulesPluginParser.check.js"),
|
20
|
-
() => require("../../schemas/plugins/JsonModulesPluginParser.json"),
|
19
|
+
require("../../schemas/plugins/json/JsonModulesPluginParser.check.js"),
|
20
|
+
() => require("../../schemas/plugins/json/JsonModulesPluginParser.json"),
|
21
21
|
{
|
22
22
|
name: "Json Modules Plugin",
|
23
23
|
baseDataPath: "parser"
|
@@ -25,8 +25,8 @@ const validate = createSchemaValidation(
|
|
25
25
|
);
|
26
26
|
|
27
27
|
const validateGenerator = createSchemaValidation(
|
28
|
-
require("../../schemas/plugins/JsonModulesPluginGenerator.check.js"),
|
29
|
-
() => require("../../schemas/plugins/JsonModulesPluginGenerator.json"),
|
28
|
+
require("../../schemas/plugins/json/JsonModulesPluginGenerator.check.js"),
|
29
|
+
() => require("../../schemas/plugins/json/JsonModulesPluginGenerator.json"),
|
30
30
|
{
|
31
31
|
name: "Json Modules Plugin",
|
32
32
|
baseDataPath: "generator"
|
@@ -93,7 +93,7 @@ class AbstractLibraryPlugin {
|
|
93
93
|
|
94
94
|
/**
|
95
95
|
* @param {Chunk} chunk chunk
|
96
|
-
* @returns {
|
96
|
+
* @returns {T | false} options for the chunk
|
97
97
|
*/
|
98
98
|
const getOptionsForChunk = chunk => {
|
99
99
|
if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0)
|
@@ -39,6 +39,8 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
39
39
|
* @property {string | string[]=} export
|
40
40
|
*/
|
41
41
|
|
42
|
+
const PLUGIN_NAME = "ModuleLibraryPlugin";
|
43
|
+
|
42
44
|
/**
|
43
45
|
* @typedef {ModuleLibraryPluginParsed} T
|
44
46
|
* @extends {AbstractLibraryPlugin<ModuleLibraryPluginParsed>}
|
@@ -62,34 +64,31 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
62
64
|
apply(compiler) {
|
63
65
|
super.apply(compiler);
|
64
66
|
|
65
|
-
compiler.hooks.
|
67
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
66
68
|
const { exportsDefinitions } =
|
67
69
|
ConcatenatedModule.getCompilationHooks(compilation);
|
68
|
-
exportsDefinitions.tap(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if (connection.originModule) {
|
77
|
-
return false;
|
78
|
-
}
|
70
|
+
exportsDefinitions.tap(PLUGIN_NAME, (definitions, module) => {
|
71
|
+
// If we have connections not all modules were concatenated, so we need the wrapper
|
72
|
+
const connections =
|
73
|
+
compilation.moduleGraph.getIncomingConnections(module);
|
74
|
+
|
75
|
+
for (const connection of connections) {
|
76
|
+
if (connection.originModule) {
|
77
|
+
return false;
|
79
78
|
}
|
79
|
+
}
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
81
|
+
// Runtime and splitting chunks now requires the wrapper too
|
82
|
+
for (const chunk of compilation.chunkGraph.getModuleChunksIterable(
|
83
|
+
module
|
84
|
+
)) {
|
85
|
+
if (!chunk.hasRuntime()) {
|
86
|
+
return false;
|
88
87
|
}
|
89
|
-
|
90
|
-
return true;
|
91
88
|
}
|
92
|
-
|
89
|
+
|
90
|
+
return true;
|
91
|
+
});
|
93
92
|
});
|
94
93
|
}
|
95
94
|
|
@@ -121,11 +120,11 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
121
120
|
renderStartup(
|
122
121
|
source,
|
123
122
|
module,
|
124
|
-
{ moduleGraph, chunk },
|
123
|
+
{ moduleGraph, chunk, codeGenerationResults },
|
125
124
|
{ options, compilation }
|
126
125
|
) {
|
127
126
|
const result = new ConcatSource(source);
|
128
|
-
const
|
127
|
+
const exportsInfo = options.export
|
129
128
|
? [
|
130
129
|
moduleGraph.getExportInfo(
|
131
130
|
module,
|
@@ -136,7 +135,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
136
135
|
const definitions =
|
137
136
|
/** @type {BuildMeta} */
|
138
137
|
(module.buildMeta).exportsFinalName || {};
|
138
|
+
/** @type {string[]} */
|
139
139
|
const shortHandedExports = [];
|
140
|
+
/** @type {[string, string][]} */
|
140
141
|
const exports = [];
|
141
142
|
const isAsync = moduleGraph.isAsync(module);
|
142
143
|
|
@@ -146,7 +147,11 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
146
147
|
);
|
147
148
|
}
|
148
149
|
|
149
|
-
|
150
|
+
const varType = compilation.outputOptions.environment.const
|
151
|
+
? "const"
|
152
|
+
: "var";
|
153
|
+
|
154
|
+
for (const exportInfo of exportsInfo) {
|
150
155
|
if (!exportInfo.provided) continue;
|
151
156
|
|
152
157
|
let shouldContinue = false;
|
@@ -159,6 +164,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
159
164
|
for (const reexportInfo of exp.orderedExports) {
|
160
165
|
if (
|
161
166
|
reexportInfo.provided === false &&
|
167
|
+
reexportInfo.name !== "default" &&
|
162
168
|
reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
|
163
169
|
) {
|
164
170
|
shouldContinue = true;
|
@@ -168,22 +174,21 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
168
174
|
|
169
175
|
if (shouldContinue) continue;
|
170
176
|
|
171
|
-
const
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
+
const originalName = exportInfo.name;
|
178
|
+
const usedName =
|
179
|
+
/** @type {string} */
|
180
|
+
(exportInfo.getUsedName(originalName, chunk.runtime));
|
181
|
+
/** @type {string | undefined} */
|
182
|
+
const definition = definitions[usedName];
|
177
183
|
const finalName =
|
178
184
|
definition ||
|
179
|
-
`${RuntimeGlobals.exports}${Template.toIdentifier(
|
185
|
+
`${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
|
180
186
|
|
181
187
|
if (!definition) {
|
182
188
|
result.add(
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
])}\n`
|
189
|
+
`${varType} ${finalName} = ${RuntimeGlobals.exports}${propertyAccess([
|
190
|
+
usedName
|
191
|
+
])};\n`
|
187
192
|
);
|
188
193
|
}
|
189
194
|
|
@@ -193,12 +198,27 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
193
198
|
finalName.includes("[") ||
|
194
199
|
finalName.includes("("))
|
195
200
|
) {
|
196
|
-
|
201
|
+
if (exportInfo.isReexport()) {
|
202
|
+
const { data } = codeGenerationResults.get(module, chunk.runtime);
|
203
|
+
const topLevelDeclarations =
|
204
|
+
(data && data.get("topLevelDeclarations")) ||
|
205
|
+
(module.buildInfo && module.buildInfo.topLevelDeclarations);
|
206
|
+
|
207
|
+
if (topLevelDeclarations && topLevelDeclarations.has(originalName)) {
|
208
|
+
const name = `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`;
|
209
|
+
result.add(`${varType} ${name} = ${finalName};\n`);
|
210
|
+
shortHandedExports.push(`${name} as ${originalName}`);
|
211
|
+
} else {
|
212
|
+
exports.push([originalName, finalName]);
|
213
|
+
}
|
214
|
+
} else {
|
215
|
+
exports.push([originalName, finalName]);
|
216
|
+
}
|
197
217
|
} else {
|
198
218
|
shortHandedExports.push(
|
199
|
-
definition && finalName ===
|
219
|
+
definition && finalName === originalName
|
200
220
|
? finalName
|
201
|
-
: `${finalName} as ${
|
221
|
+
: `${finalName} as ${originalName}`
|
202
222
|
);
|
203
223
|
}
|
204
224
|
}
|
@@ -208,9 +228,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
208
228
|
}
|
209
229
|
|
210
230
|
for (const [exportName, final] of exports) {
|
211
|
-
result.add(
|
212
|
-
`export ${compilation.outputOptions.environment.const ? "const" : "var"} ${exportName} = ${final};\n`
|
213
|
-
);
|
231
|
+
result.add(`export ${varType} ${exportName} = ${final};\n`);
|
214
232
|
}
|
215
233
|
|
216
234
|
return result;
|
@@ -16,6 +16,8 @@ const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenc
|
|
16
16
|
* @property {boolean=} asyncChunkLoading enable async chunk loading
|
17
17
|
*/
|
18
18
|
|
19
|
+
const PLUGIN_NAME = "CommonJsChunkLoadingPlugin";
|
20
|
+
|
19
21
|
class CommonJsChunkLoadingPlugin {
|
20
22
|
/**
|
21
23
|
* @param {CommonJsChunkLoadingPluginOptions=} options options
|
@@ -40,81 +42,75 @@ class CommonJsChunkLoadingPlugin {
|
|
40
42
|
chunkLoading: chunkLoadingValue,
|
41
43
|
asyncChunkLoading: this._asyncChunkLoading
|
42
44
|
}).apply(compiler);
|
43
|
-
compiler.hooks.thisCompilation.tap(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
compilation.addRuntimeModule(
|
71
|
-
chunk,
|
72
|
-
new ChunkLoadingRuntimeModule(set)
|
73
|
-
);
|
74
|
-
};
|
45
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
46
|
+
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
47
|
+
/**
|
48
|
+
* @param {Chunk} chunk chunk
|
49
|
+
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
50
|
+
*/
|
51
|
+
const isEnabledForChunk = chunk => {
|
52
|
+
const options = chunk.getEntryOptions();
|
53
|
+
const chunkLoading =
|
54
|
+
options && options.chunkLoading !== undefined
|
55
|
+
? options.chunkLoading
|
56
|
+
: globalChunkLoading;
|
57
|
+
return chunkLoading === chunkLoadingValue;
|
58
|
+
};
|
59
|
+
const onceForChunkSet = new WeakSet();
|
60
|
+
/**
|
61
|
+
* @param {Chunk} chunk chunk
|
62
|
+
* @param {Set<string>} set runtime requirements
|
63
|
+
*/
|
64
|
+
const handler = (chunk, set) => {
|
65
|
+
if (onceForChunkSet.has(chunk)) return;
|
66
|
+
onceForChunkSet.add(chunk);
|
67
|
+
if (!isEnabledForChunk(chunk)) return;
|
68
|
+
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
69
|
+
set.add(RuntimeGlobals.hasOwnProperty);
|
70
|
+
compilation.addRuntimeModule(chunk, new ChunkLoadingRuntimeModule(set));
|
71
|
+
};
|
75
72
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
73
|
+
compilation.hooks.runtimeRequirementInTree
|
74
|
+
.for(RuntimeGlobals.ensureChunkHandlers)
|
75
|
+
.tap(PLUGIN_NAME, handler);
|
76
|
+
compilation.hooks.runtimeRequirementInTree
|
77
|
+
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
78
|
+
.tap(PLUGIN_NAME, handler);
|
79
|
+
compilation.hooks.runtimeRequirementInTree
|
80
|
+
.for(RuntimeGlobals.hmrDownloadManifest)
|
81
|
+
.tap(PLUGIN_NAME, handler);
|
82
|
+
compilation.hooks.runtimeRequirementInTree
|
83
|
+
.for(RuntimeGlobals.baseURI)
|
84
|
+
.tap(PLUGIN_NAME, handler);
|
85
|
+
compilation.hooks.runtimeRequirementInTree
|
86
|
+
.for(RuntimeGlobals.externalInstallChunk)
|
87
|
+
.tap(PLUGIN_NAME, handler);
|
88
|
+
compilation.hooks.runtimeRequirementInTree
|
89
|
+
.for(RuntimeGlobals.onChunksLoaded)
|
90
|
+
.tap(PLUGIN_NAME, handler);
|
94
91
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
);
|
92
|
+
compilation.hooks.runtimeRequirementInTree
|
93
|
+
.for(RuntimeGlobals.ensureChunkHandlers)
|
94
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
95
|
+
if (!isEnabledForChunk(chunk)) return;
|
96
|
+
set.add(RuntimeGlobals.getChunkScriptFilename);
|
97
|
+
});
|
98
|
+
compilation.hooks.runtimeRequirementInTree
|
99
|
+
.for(RuntimeGlobals.hmrDownloadUpdateHandlers)
|
100
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
101
|
+
if (!isEnabledForChunk(chunk)) return;
|
102
|
+
set.add(RuntimeGlobals.getChunkUpdateScriptFilename);
|
103
|
+
set.add(RuntimeGlobals.moduleCache);
|
104
|
+
set.add(RuntimeGlobals.hmrModuleData);
|
105
|
+
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
106
|
+
});
|
107
|
+
compilation.hooks.runtimeRequirementInTree
|
108
|
+
.for(RuntimeGlobals.hmrDownloadManifest)
|
109
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
110
|
+
if (!isEnabledForChunk(chunk)) return;
|
111
|
+
set.add(RuntimeGlobals.getUpdateManifestFilename);
|
112
|
+
});
|
113
|
+
});
|
118
114
|
}
|
119
115
|
}
|
120
116
|
|
@@ -20,6 +20,8 @@ const nodeConsole = require("./nodeConsole");
|
|
20
20
|
* @property {InfrastructureLogging} infrastructureLogging infrastructure logging options
|
21
21
|
*/
|
22
22
|
|
23
|
+
const PLUGIN_NAME = "NodeEnvironmentPlugin";
|
24
|
+
|
23
25
|
class NodeEnvironmentPlugin {
|
24
26
|
/**
|
25
27
|
* @param {NodeEnvironmentPluginOptions} options options
|
@@ -55,7 +57,7 @@ class NodeEnvironmentPlugin {
|
|
55
57
|
compiler.outputFileSystem = fs;
|
56
58
|
compiler.intermediateFileSystem = fs;
|
57
59
|
compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
|
58
|
-
compiler.hooks.beforeRun.tap(
|
60
|
+
compiler.hooks.beforeRun.tap(PLUGIN_NAME, compiler => {
|
59
61
|
if (
|
60
62
|
compiler.inputFileSystem === inputFileSystem &&
|
61
63
|
inputFileSystem.purge
|
package/lib/node/nodeConsole.js
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
const util = require("util");
|
9
9
|
const truncateArgs = require("../logging/truncateArgs");
|
10
10
|
|
11
|
+
/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
|
11
12
|
/** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
|
12
13
|
|
13
14
|
/* eslint-disable no-console */
|
@@ -16,7 +17,7 @@ const truncateArgs = require("../logging/truncateArgs");
|
|
16
17
|
* @param {object} options options
|
17
18
|
* @param {boolean=} options.colors colors
|
18
19
|
* @param {boolean=} options.appendOnly append only
|
19
|
-
* @param {
|
20
|
+
* @param {NonNullable<InfrastructureLogging["stream"]>} options.stream stream
|
20
21
|
* @returns {LoggerConsole} logger function
|
21
22
|
*/
|
22
23
|
module.exports = ({ colors, appendOnly, stream }) => {
|
@@ -57,7 +58,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
57
58
|
|
58
59
|
const writeStatusMessage = () => {
|
59
60
|
if (!currentStatusMessage) return;
|
60
|
-
const l =
|
61
|
+
const l = stream.columns || 40;
|
61
62
|
const args = truncateArgs(currentStatusMessage, l - 1);
|
62
63
|
const str = args.join(" ");
|
63
64
|
const coloredStr = `\u001B[1m${str}\u001B[39m\u001B[22m`;
|