webpack 5.85.1 → 5.87.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 +5 -2
- package/lib/APIPlugin.js +150 -99
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +35 -17
- package/lib/ChunkGroup.js +11 -6
- package/lib/Compiler.js +4 -3
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +57 -29
- package/lib/ContextModule.js +4 -2
- package/lib/ContextModuleFactory.js +1 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/DllModule.js +6 -0
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/ExternalModule.js +15 -8
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/Module.js +7 -1
- package/lib/ModuleDependencyError.js +4 -2
- package/lib/ModuleDependencyWarning.js +4 -2
- package/lib/ModuleGraph.js +31 -24
- package/lib/ModuleGraphConnection.js +19 -6
- package/lib/ModuleInfoHeaderPlugin.js +9 -2
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +7 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/ProgressPlugin.js +71 -15
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +2 -1
- package/lib/RuntimeTemplate.js +20 -2
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackOptionsApply.js +4 -2
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/config/defaults.js +31 -2
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +13 -6
- package/lib/css/CssModulesPlugin.js +42 -14
- package/lib/css/CssParser.js +12 -0
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
- package/lib/dependencies/ImportParserPlugin.js +25 -1
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -0
- package/lib/javascript/BasicEvaluatedExpression.js +23 -15
- package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
- package/lib/javascript/JavascriptModulesPlugin.js +1 -0
- package/lib/javascript/JavascriptParser.js +118 -58
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/json/JsonData.js +2 -2
- package/lib/json/JsonParser.js +25 -12
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/optimize/AggressiveMergingPlugin.js +8 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
- package/lib/optimize/InnerGraph.js +4 -4
- package/lib/optimize/LimitChunkCountPlugin.js +29 -4
- package/lib/optimize/MangleExportsPlugin.js +1 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
- package/lib/optimize/RealContentHashPlugin.js +80 -30
- package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
- package/lib/optimize/RuntimeChunkPlugin.js +9 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
- package/lib/optimize/SplitChunksPlugin.js +71 -31
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +3 -1
- package/lib/rules/BasicEffectRulePlugin.js +4 -0
- package/lib/rules/BasicMatcherRulePlugin.js +5 -0
- package/lib/rules/RuleSetCompiler.js +3 -3
- package/lib/rules/UseEffectRulePlugin.js +6 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +4 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -1
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +4 -1
- package/lib/runtime/CompatRuntimeModule.js +6 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +4 -1
- package/lib/runtime/CreateScriptRuntimeModule.js +3 -1
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +3 -1
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +4 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +14 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -9
- package/lib/runtime/GetFullHashRuntimeModule.js +3 -2
- package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +3 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +4 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +63 -47
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +4 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +3 -1
- package/lib/runtime/PublicPathRuntimeModule.js +3 -1
- package/lib/runtime/RelativeUrlRuntimeModule.js +4 -1
- package/lib/runtime/RuntimeIdRuntimeModule.js +5 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -1
- package/lib/serialization/BinaryMiddleware.js +143 -1
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/ObjectMiddleware.js +9 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +13 -4
- package/lib/sharing/ProvideSharedDependency.js +11 -0
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +22 -21
- package/lib/sharing/ShareRuntimeModule.js +11 -4
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/sharing/utils.js +32 -5
- package/lib/util/AsyncQueue.js +4 -2
- package/lib/util/ParallelismFactorCalculator.js +10 -0
- package/lib/util/Semaphore.js +1 -1
- package/lib/util/createHash.js +30 -9
- package/lib/util/deprecation.js +10 -3
- package/lib/util/deterministicGrouping.js +50 -11
- package/lib/util/findGraphRoots.js +4 -2
- package/lib/util/memoize.js +3 -3
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +14 -1
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -6
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyParser.js +6 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -3
- package/lib/webpack.js +11 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +14 -15
- package/module.d.ts +1 -0
- package/package.json +4 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +51 -5
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +476 -218
@@ -11,7 +11,8 @@ const HotUpdateChunk = require("../HotUpdateChunk");
|
|
11
11
|
const {
|
12
12
|
CSS_MODULE_TYPE,
|
13
13
|
CSS_MODULE_TYPE_GLOBAL,
|
14
|
-
CSS_MODULE_TYPE_MODULE
|
14
|
+
CSS_MODULE_TYPE_MODULE,
|
15
|
+
CSS_MODULE_TYPE_AUTO
|
15
16
|
} = require("../ModuleTypeConstants");
|
16
17
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
17
18
|
const SelfModuleFactory = require("../SelfModuleFactory");
|
@@ -46,6 +47,10 @@ const getCssLoadingRuntimeModule = memoize(() =>
|
|
46
47
|
require("./CssLoadingRuntimeModule")
|
47
48
|
);
|
48
49
|
|
50
|
+
/**
|
51
|
+
* @param {string} name name
|
52
|
+
* @returns {{oneOf: [{$ref: string}], definitions: *}} schema
|
53
|
+
*/
|
49
54
|
const getSchema = name => {
|
50
55
|
const { definitions } = require("../../schemas/WebpackOptions.json");
|
51
56
|
return {
|
@@ -145,7 +150,8 @@ class CssModulesPlugin {
|
|
145
150
|
for (const type of [
|
146
151
|
CSS_MODULE_TYPE,
|
147
152
|
CSS_MODULE_TYPE_GLOBAL,
|
148
|
-
CSS_MODULE_TYPE_MODULE
|
153
|
+
CSS_MODULE_TYPE_MODULE,
|
154
|
+
CSS_MODULE_TYPE_AUTO
|
149
155
|
]) {
|
150
156
|
normalModuleFactory.hooks.createParser
|
151
157
|
.for(type)
|
@@ -154,6 +160,7 @@ class CssModulesPlugin {
|
|
154
160
|
|
155
161
|
switch (type) {
|
156
162
|
case CSS_MODULE_TYPE:
|
163
|
+
case CSS_MODULE_TYPE_AUTO:
|
157
164
|
return new CssParser();
|
158
165
|
case CSS_MODULE_TYPE_GLOBAL:
|
159
166
|
return new CssParser({
|
@@ -302,6 +309,10 @@ class CssModulesPlugin {
|
|
302
309
|
return result;
|
303
310
|
});
|
304
311
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
312
|
+
/**
|
313
|
+
* @param {Chunk} chunk the chunk
|
314
|
+
* @returns {boolean} true, when enabled
|
315
|
+
*/
|
305
316
|
const isEnabledForChunk = chunk => {
|
306
317
|
const options = chunk.getEntryOptions();
|
307
318
|
const chunkLoading =
|
@@ -311,6 +322,10 @@ class CssModulesPlugin {
|
|
311
322
|
return chunkLoading === "jsonp";
|
312
323
|
};
|
313
324
|
const onceForChunkSet = new WeakSet();
|
325
|
+
/**
|
326
|
+
* @param {Chunk} chunk chunk to check
|
327
|
+
* @param {Set<string>} set runtime requirements
|
328
|
+
*/
|
314
329
|
const handler = (chunk, set) => {
|
315
330
|
if (onceForChunkSet.has(chunk)) return;
|
316
331
|
onceForChunkSet.add(chunk);
|
@@ -361,7 +376,10 @@ class CssModulesPlugin {
|
|
361
376
|
};
|
362
377
|
})
|
363
378
|
.filter(item => item.index !== undefined)
|
364
|
-
.sort(
|
379
|
+
.sort(
|
380
|
+
(a, b) =>
|
381
|
+
/** @type {number} */ (b.index) - /** @type {number} */ (a.index)
|
382
|
+
)
|
365
383
|
.map(item => item.module);
|
366
384
|
|
367
385
|
return { list: sortedModules, set: new Set(sortedModules) };
|
@@ -455,19 +473,25 @@ class CssModulesPlugin {
|
|
455
473
|
return [
|
456
474
|
...this.getModulesInOrder(
|
457
475
|
chunk,
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
476
|
+
/** @type {Iterable<Module>} */
|
477
|
+
(
|
478
|
+
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
479
|
+
chunk,
|
480
|
+
"css-import",
|
481
|
+
compareModulesByIdentifier
|
482
|
+
)
|
462
483
|
),
|
463
484
|
compilation
|
464
485
|
),
|
465
486
|
...this.getModulesInOrder(
|
466
487
|
chunk,
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
488
|
+
/** @type {Iterable<Module>} */
|
489
|
+
(
|
490
|
+
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
491
|
+
chunk,
|
492
|
+
"css",
|
493
|
+
compareModulesByIdentifier
|
494
|
+
)
|
471
495
|
),
|
472
496
|
compilation
|
473
497
|
)
|
@@ -498,8 +522,11 @@ class CssModulesPlugin {
|
|
498
522
|
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
|
499
523
|
|
500
524
|
let moduleSource =
|
501
|
-
|
502
|
-
|
525
|
+
/** @type {Source} */
|
526
|
+
(
|
527
|
+
codeGenResult.sources.get("css") ||
|
528
|
+
codeGenResult.sources.get("css-import")
|
529
|
+
);
|
503
530
|
|
504
531
|
let inheritance = [[module.cssLayer, module.supports, module.media]];
|
505
532
|
|
@@ -569,7 +596,8 @@ class CssModulesPlugin {
|
|
569
596
|
}${escapeCss(moduleId)}`
|
570
597
|
);
|
571
598
|
} catch (e) {
|
572
|
-
|
599
|
+
/** @type {Error} */
|
600
|
+
(e).message += `\nduring rendering of css ${module.identifier()}`;
|
573
601
|
throw e;
|
574
602
|
}
|
575
603
|
}
|
package/lib/css/CssParser.js
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const ModuleDependencyWarning = require("../ModuleDependencyWarning");
|
9
|
+
const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");
|
9
10
|
const Parser = require("../Parser");
|
10
11
|
const WebpackError = require("../WebpackError");
|
11
12
|
const ConstDependency = require("../dependencies/ConstDependency");
|
@@ -15,6 +16,7 @@ const CssLocalIdentifierDependency = require("../dependencies/CssLocalIdentifier
|
|
15
16
|
const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalIdentifierDependency");
|
16
17
|
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
17
18
|
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
19
|
+
const { parseResource } = require("../util/identifier");
|
18
20
|
const walkCssTokens = require("./walkCssTokens");
|
19
21
|
|
20
22
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
@@ -37,6 +39,7 @@ const IMAGE_SET_FUNCTION = /^(-\w+-)?image-set$/i;
|
|
37
39
|
const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(-\w+-)?keyframes$/;
|
38
40
|
const OPTIONALLY_VENDOR_PREFIXED_ANIMATION_PROPERTY =
|
39
41
|
/^(-\w+-)?animation(-name)?$/i;
|
42
|
+
const IS_MODULES = /\.module(s)?\.\w+$/i;
|
40
43
|
|
41
44
|
/**
|
42
45
|
* @param {string} str url string
|
@@ -169,6 +172,15 @@ class CssParser extends Parser {
|
|
169
172
|
}
|
170
173
|
|
171
174
|
const module = state.module;
|
175
|
+
if (
|
176
|
+
module.type === CSS_MODULE_TYPE_AUTO &&
|
177
|
+
IS_MODULES.test(
|
178
|
+
parseResource(module.matchResource || module.resource).path
|
179
|
+
)
|
180
|
+
) {
|
181
|
+
this.defaultMode = "local";
|
182
|
+
}
|
183
|
+
|
172
184
|
const locConverter = new LocConverter(source);
|
173
185
|
/** @type {Set<string>}*/
|
174
186
|
const declaredCssVariables = new Set();
|
@@ -23,8 +23,8 @@ const NullDependency = require("./NullDependency");
|
|
23
23
|
class ConstDependency extends NullDependency {
|
24
24
|
/**
|
25
25
|
* @param {string} expression the expression
|
26
|
-
* @param {number|Range} range the source range
|
27
|
-
* @param {string[]=} runtimeRequirements runtime requirements
|
26
|
+
* @param {number | Range} range the source range
|
27
|
+
* @param {(string[] | null)=} runtimeRequirements runtime requirements
|
28
28
|
*/
|
29
29
|
constructor(expression, range, runtimeRequirements) {
|
30
30
|
super();
|
@@ -219,6 +219,25 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
219
219
|
}
|
220
220
|
break;
|
221
221
|
}
|
222
|
+
case "fetchPriority": {
|
223
|
+
const expr = parser.evaluateExpression(
|
224
|
+
/** @type {Expression} */ (prop.value)
|
225
|
+
);
|
226
|
+
if (
|
227
|
+
expr.isString() &&
|
228
|
+
["high", "low", "auto"].includes(expr.string)
|
229
|
+
) {
|
230
|
+
groupOptions.fetchPriority =
|
231
|
+
/** @type {RawChunkGroupOptions["fetchPriority"]} */ (
|
232
|
+
expr.string
|
233
|
+
);
|
234
|
+
} else {
|
235
|
+
errors.push(
|
236
|
+
createPropertyParseError(prop, '"high"|"low"|"auto"')
|
237
|
+
);
|
238
|
+
}
|
239
|
+
break;
|
240
|
+
}
|
222
241
|
case "recursive": {
|
223
242
|
const recursiveExpr = parser.evaluateExpression(
|
224
243
|
/** @type {Expression} */ (prop.value)
|
@@ -47,7 +47,11 @@ class ImportParserPlugin {
|
|
47
47
|
/** @type {RawChunkGroupOptions} */
|
48
48
|
const groupOptions = {};
|
49
49
|
|
50
|
-
const {
|
50
|
+
const {
|
51
|
+
dynamicImportPreload,
|
52
|
+
dynamicImportPrefetch,
|
53
|
+
dynamicImportFetchPriority
|
54
|
+
} = this.options;
|
51
55
|
if (dynamicImportPreload !== undefined && dynamicImportPreload !== false)
|
52
56
|
groupOptions.preloadOrder =
|
53
57
|
dynamicImportPreload === true ? 0 : dynamicImportPreload;
|
@@ -57,6 +61,11 @@ class ImportParserPlugin {
|
|
57
61
|
)
|
58
62
|
groupOptions.prefetchOrder =
|
59
63
|
dynamicImportPrefetch === true ? 0 : dynamicImportPrefetch;
|
64
|
+
if (
|
65
|
+
dynamicImportFetchPriority !== undefined &&
|
66
|
+
dynamicImportFetchPriority !== false
|
67
|
+
)
|
68
|
+
groupOptions.fetchPriority = dynamicImportFetchPriority;
|
60
69
|
|
61
70
|
const { options: importOptions, errors: commentErrors } =
|
62
71
|
parser.parseCommentOptions(expr.range);
|
@@ -141,6 +150,21 @@ class ImportParserPlugin {
|
|
141
150
|
);
|
142
151
|
}
|
143
152
|
}
|
153
|
+
if (importOptions.webpackFetchPriority !== undefined) {
|
154
|
+
if (
|
155
|
+
typeof importOptions.webpackFetchPriority === "string" &&
|
156
|
+
["high", "low", "auto"].includes(importOptions.webpackFetchPriority)
|
157
|
+
) {
|
158
|
+
groupOptions.fetchPriority = importOptions.webpackFetchPriority;
|
159
|
+
} else {
|
160
|
+
parser.state.module.addWarning(
|
161
|
+
new UnsupportedFeatureWarning(
|
162
|
+
`\`webpackFetchPriority\` expected true or "low", "high" or "auto", but received: ${importOptions.webpackFetchPriority}.`,
|
163
|
+
expr.loc
|
164
|
+
)
|
165
|
+
);
|
166
|
+
}
|
167
|
+
}
|
144
168
|
if (importOptions.webpackInclude !== undefined) {
|
145
169
|
if (
|
146
170
|
!importOptions.webpackInclude ||
|
@@ -63,6 +63,7 @@ class SyncModuleIdsPlugin {
|
|
63
63
|
if (this._write) {
|
64
64
|
compiler.hooks.emitRecords.tapAsync(plugin, callback => {
|
65
65
|
if (!data || !dataChanged) return callback();
|
66
|
+
/** @type {Object<string, string | number>} */
|
66
67
|
const json = {};
|
67
68
|
const sorted = Array.from(data).sort(([a], [b]) => (a < b ? -1 : 1));
|
68
69
|
for (const [key, value] of sorted) {
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
/** @typedef {import("estree").Node}
|
8
|
+
/** @typedef {import("estree").Node} Node */
|
9
9
|
/** @typedef {import("./JavascriptParser").Range} Range */
|
10
10
|
/** @typedef {import("./JavascriptParser").VariableInfoInterface} VariableInfoInterface */
|
11
11
|
|
@@ -27,7 +27,7 @@ const TypeBigInt = 13;
|
|
27
27
|
class BasicEvaluatedExpression {
|
28
28
|
constructor() {
|
29
29
|
this.type = TypeUnknown;
|
30
|
-
/** @type {[number, number]} */
|
30
|
+
/** @type {[number, number] | undefined} */
|
31
31
|
this.range = undefined;
|
32
32
|
/** @type {boolean} */
|
33
33
|
this.falsy = false;
|
@@ -57,23 +57,23 @@ class BasicEvaluatedExpression {
|
|
57
57
|
this.items = undefined;
|
58
58
|
/** @type {BasicEvaluatedExpression[] | undefined} */
|
59
59
|
this.options = undefined;
|
60
|
-
/** @type {BasicEvaluatedExpression | undefined} */
|
60
|
+
/** @type {BasicEvaluatedExpression | undefined | null} */
|
61
61
|
this.prefix = undefined;
|
62
|
-
/** @type {BasicEvaluatedExpression | undefined} */
|
62
|
+
/** @type {BasicEvaluatedExpression | undefined | null} */
|
63
63
|
this.postfix = undefined;
|
64
|
-
/** @type {BasicEvaluatedExpression[]} */
|
64
|
+
/** @type {BasicEvaluatedExpression[] | undefined} */
|
65
65
|
this.wrappedInnerExpressions = undefined;
|
66
66
|
/** @type {string | VariableInfoInterface | undefined} */
|
67
67
|
this.identifier = undefined;
|
68
|
-
/** @type {string | VariableInfoInterface} */
|
68
|
+
/** @type {string | VariableInfoInterface | undefined} */
|
69
69
|
this.rootInfo = undefined;
|
70
|
-
/** @type {() => string[]} */
|
70
|
+
/** @type {(() => string[]) | undefined} */
|
71
71
|
this.getMembers = undefined;
|
72
|
-
/** @type {() => boolean[]} */
|
72
|
+
/** @type {(() => boolean[]) | undefined} */
|
73
73
|
this.getMembersOptionals = undefined;
|
74
|
-
/** @type {() => Range[]} */
|
74
|
+
/** @type {(() => Range[]) | undefined} */
|
75
75
|
this.getMemberRanges = undefined;
|
76
|
-
/** @type {
|
76
|
+
/** @type {Node | undefined} */
|
77
77
|
this.expression = undefined;
|
78
78
|
}
|
79
79
|
|
@@ -293,7 +293,9 @@ class BasicEvaluatedExpression {
|
|
293
293
|
if (this.isRegExp()) return `${this.regExp}`;
|
294
294
|
if (this.isArray()) {
|
295
295
|
let array = [];
|
296
|
-
for (const item of
|
296
|
+
for (const item of /** @type {BasicEvaluatedExpression[]} */ (
|
297
|
+
this.items
|
298
|
+
)) {
|
297
299
|
const itemStr = item.asString();
|
298
300
|
if (itemStr === undefined) return undefined;
|
299
301
|
array.push(itemStr);
|
@@ -303,7 +305,9 @@ class BasicEvaluatedExpression {
|
|
303
305
|
if (this.isConstArray()) return `${this.array}`;
|
304
306
|
if (this.isTemplateString()) {
|
305
307
|
let str = "";
|
306
|
-
for (const part of
|
308
|
+
for (const part of /** @type {BasicEvaluatedExpression[]} */ (
|
309
|
+
this.parts
|
310
|
+
)) {
|
307
311
|
const partStr = part.asString();
|
308
312
|
if (partStr === undefined) return undefined;
|
309
313
|
str += partStr;
|
@@ -313,6 +317,10 @@ class BasicEvaluatedExpression {
|
|
313
317
|
return undefined;
|
314
318
|
}
|
315
319
|
|
320
|
+
/**
|
321
|
+
* @param {string} string value
|
322
|
+
* @returns {BasicEvaluatedExpression} basic evaluated expression
|
323
|
+
*/
|
316
324
|
setString(string) {
|
317
325
|
this.type = TypeString;
|
318
326
|
this.string = string;
|
@@ -410,8 +418,8 @@ class BasicEvaluatedExpression {
|
|
410
418
|
/**
|
411
419
|
* Wraps an array of expressions with a prefix and postfix expression.
|
412
420
|
*
|
413
|
-
* @param {BasicEvaluatedExpression | null} prefix Expression to be added before the innerExpressions
|
414
|
-
* @param {BasicEvaluatedExpression} postfix Expression to be added after the innerExpressions
|
421
|
+
* @param {BasicEvaluatedExpression | null | undefined} prefix Expression to be added before the innerExpressions
|
422
|
+
* @param {BasicEvaluatedExpression | null | undefined} postfix Expression to be added after the innerExpressions
|
415
423
|
* @param {BasicEvaluatedExpression[]} innerExpressions Expressions to be wrapped
|
416
424
|
* @returns {this} this
|
417
425
|
*/
|
@@ -551,7 +559,7 @@ class BasicEvaluatedExpression {
|
|
551
559
|
/**
|
552
560
|
* Set the expression node for the expression.
|
553
561
|
*
|
554
|
-
* @param {
|
562
|
+
* @param {Node | undefined} expression expression
|
555
563
|
* @returns {this} this
|
556
564
|
*/
|
557
565
|
setExpression(expression) {
|
@@ -17,7 +17,9 @@ const {
|
|
17
17
|
updateHashForEntryStartup
|
18
18
|
} = require("./StartupHelpers");
|
19
19
|
|
20
|
+
/** @typedef {import("../Chunk")} Chunk */
|
20
21
|
/** @typedef {import("../Compiler")} Compiler */
|
22
|
+
/** @typedef {import("../Entrypoint")} Entrypoint */
|
21
23
|
|
22
24
|
class CommonJsChunkFormatPlugin {
|
23
25
|
/**
|
@@ -66,7 +68,9 @@ class CommonJsChunkFormatPlugin {
|
|
66
68
|
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
67
69
|
);
|
68
70
|
if (entries.length > 0) {
|
69
|
-
const runtimeChunk =
|
71
|
+
const runtimeChunk =
|
72
|
+
/** @type {Entrypoint} */
|
73
|
+
(entries[0][1]).getRuntimeChunk();
|
70
74
|
const currentOutputName = compilation
|
71
75
|
.getPath(
|
72
76
|
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
@@ -83,7 +87,7 @@ class CommonJsChunkFormatPlugin {
|
|
83
87
|
compilation.outputOptions
|
84
88
|
),
|
85
89
|
{
|
86
|
-
chunk: runtimeChunk,
|
90
|
+
chunk: /** @type {Chunk} */ (runtimeChunk),
|
87
91
|
contentHashType: "javascript"
|
88
92
|
}
|
89
93
|
)
|
@@ -937,6 +937,7 @@ class JavascriptModulesPlugin {
|
|
937
937
|
"JavascriptModulesPlugin error: JavascriptModulesPlugin.getCompilationHooks().renderContent plugins should return something"
|
938
938
|
);
|
939
939
|
}
|
940
|
+
|
940
941
|
finalSource = InitFragment.addToSource(
|
941
942
|
finalSource,
|
942
943
|
chunkRenderContext.chunkInitFragments,
|