webpack 5.99.8 → 5.99.9
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 +0 -3
- package/lib/CacheFacade.js +2 -1
- package/lib/ChunkGraph.js +0 -1
- package/lib/ChunkGroup.js +13 -6
- package/lib/Compilation.js +10 -26
- package/lib/ConstPlugin.js +61 -43
- package/lib/CssModule.js +0 -1
- package/lib/Dependency.js +10 -11
- package/lib/FileSystemInfo.js +0 -2
- package/lib/NormalModule.js +30 -12
- package/lib/NormalModuleFactory.js +23 -18
- package/lib/RuntimePlugin.js +1 -1
- package/lib/asset/AssetGenerator.js +11 -10
- package/lib/asset/AssetSourceGenerator.js +7 -5
- package/lib/dependencies/CssUrlDependency.js +1 -1
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -0
- package/lib/dependencies/URLDependency.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +3 -3
- package/lib/javascript/JavascriptParser.js +19 -5
- package/lib/library/ModuleLibraryPlugin.js +4 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +1 -1
- package/lib/schemes/DataUriPlugin.js +3 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +13 -13
- package/package.json +16 -15
- package/types.d.ts +32 -7
package/README.md
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
|
10
10
|
[![node][node]][node-url]
|
11
11
|
[![builds1][builds1]][builds1-url]
|
12
|
-
[![builds2][builds2]][builds2-url]
|
13
12
|
[![dependency-review][dependency-review]][dependency-review-url]
|
14
13
|
[![coverage][cover]][cover-url]
|
15
14
|
[![PR's welcome][prs]][prs-url]
|
@@ -672,8 +671,6 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
672
671
|
[prs-url]: https://webpack.js.org/contribute/
|
673
672
|
[builds1]: https://github.com/webpack/webpack/actions/workflows/test.yml/badge.svg
|
674
673
|
[builds1-url]: https://github.com/webpack/webpack/actions/workflows/test.yml
|
675
|
-
[builds2]: https://dev.azure.com/webpack/webpack/_apis/build/status%2Fwebpack.webpack?branchName=main
|
676
|
-
[builds2-url]: https://dev.azure.com/webpack/webpack/_build/latest?definitionId=3&branchName=main
|
677
674
|
[dependency-review-url]: https://github.com/webpack/webpack/actions/workflows/dependency-review.yml
|
678
675
|
[dependency-review]: https://github.com/webpack/webpack/actions/workflows/dependency-review.yml/badge.svg
|
679
676
|
[cover]: https://codecov.io/gh/webpack/webpack/graph/badge.svg?token=mDP3mQJNnn
|
package/lib/CacheFacade.js
CHANGED
@@ -38,8 +38,9 @@ class MultiItemCache {
|
|
38
38
|
*/
|
39
39
|
constructor(items) {
|
40
40
|
this._items = items;
|
41
|
+
// @ts-expect-error expected - returns the single ItemCacheFacade when passed an array of length 1
|
41
42
|
// eslint-disable-next-line no-constructor-return
|
42
|
-
if (items.length === 1) return /** @type {
|
43
|
+
if (items.length === 1) return /** @type {ItemCacheFacade} */ (items[0]);
|
43
44
|
}
|
44
45
|
|
45
46
|
/**
|
package/lib/ChunkGraph.js
CHANGED
package/lib/ChunkGroup.js
CHANGED
@@ -115,16 +115,23 @@ class ChunkGroup {
|
|
115
115
|
*/
|
116
116
|
addOptions(options) {
|
117
117
|
for (const _key of Object.keys(options)) {
|
118
|
-
const key =
|
118
|
+
const key =
|
119
|
+
/** @type {keyof ChunkGroupOptions} */
|
120
|
+
(_key);
|
119
121
|
if (this.options[key] === undefined) {
|
120
|
-
/** @type {
|
122
|
+
/** @type {EXPECTED_ANY} */
|
121
123
|
(this.options)[key] = options[key];
|
122
124
|
} else if (this.options[key] !== options[key]) {
|
123
125
|
if (key.endsWith("Order")) {
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
126
|
+
const orderKey =
|
127
|
+
/** @type {Exclude<keyof ChunkGroupOptions, "name" | "fetchPriority">} */
|
128
|
+
(key);
|
129
|
+
|
130
|
+
this.options[orderKey] = Math.max(
|
131
|
+
/** @type {number} */
|
132
|
+
(this.options[orderKey]),
|
133
|
+
/** @type {number} */
|
134
|
+
(options[orderKey])
|
128
135
|
);
|
129
136
|
} else {
|
130
137
|
throw new Error(
|
package/lib/Compilation.js
CHANGED
@@ -2021,8 +2021,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2021
2021
|
const unsafeCacheableModule =
|
2022
2022
|
/** @type {ModuleWithRestoreFromUnsafeCache} */
|
2023
2023
|
(module);
|
2024
|
-
for (
|
2025
|
-
const dependency = dependencies[i];
|
2024
|
+
for (const dependency of dependencies) {
|
2026
2025
|
moduleGraph.setResolvedModule(
|
2027
2026
|
connectOrigin ? originModule : null,
|
2028
2027
|
dependency,
|
@@ -2038,8 +2037,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2038
2037
|
}
|
2039
2038
|
} else {
|
2040
2039
|
applyFactoryResultDependencies();
|
2041
|
-
for (
|
2042
|
-
const dependency = dependencies[i];
|
2040
|
+
for (const dependency of dependencies) {
|
2043
2041
|
moduleGraph.setResolvedModule(
|
2044
2042
|
connectOrigin ? originModule : null,
|
2045
2043
|
dependency,
|
@@ -2356,6 +2354,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2356
2354
|
*/
|
2357
2355
|
_addEntryItem(context, entry, target, options, callback) {
|
2358
2356
|
const { name } = options;
|
2357
|
+
/** @type {EntryData | undefined} */
|
2359
2358
|
let entryData =
|
2360
2359
|
name !== undefined ? this.entries.get(name) : this.globalEntry;
|
2361
2360
|
if (entryData === undefined) {
|
@@ -3435,18 +3434,13 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3435
3434
|
*/
|
3436
3435
|
reportDependencyErrorsAndWarnings(module, blocks) {
|
3437
3436
|
let hasProblems = false;
|
3438
|
-
for (
|
3439
|
-
const block = blocks[indexBlock];
|
3437
|
+
for (const block of blocks) {
|
3440
3438
|
const dependencies = block.dependencies;
|
3441
3439
|
|
3442
|
-
for (
|
3443
|
-
const d = dependencies[indexDep];
|
3444
|
-
|
3440
|
+
for (const d of dependencies) {
|
3445
3441
|
const warnings = d.getWarnings(this.moduleGraph);
|
3446
3442
|
if (warnings) {
|
3447
|
-
for (
|
3448
|
-
const w = warnings[indexWar];
|
3449
|
-
|
3443
|
+
for (const w of warnings) {
|
3450
3444
|
const warning = new ModuleDependencyWarning(module, w, d.loc);
|
3451
3445
|
this.warnings.push(warning);
|
3452
3446
|
hasProblems = true;
|
@@ -3454,9 +3448,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3454
3448
|
}
|
3455
3449
|
const errors = d.getErrors(this.moduleGraph);
|
3456
3450
|
if (errors) {
|
3457
|
-
for (
|
3458
|
-
const e = errors[indexErr];
|
3459
|
-
|
3451
|
+
for (const e of errors) {
|
3460
3452
|
const error = new ModuleDependencyError(module, e, d.loc);
|
3461
3453
|
this.errors.push(error);
|
3462
3454
|
hasProblems = true;
|
@@ -4161,16 +4153,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
4161
4153
|
};
|
4162
4154
|
|
4163
4155
|
const blocks = block.blocks;
|
4164
|
-
for (
|
4165
|
-
const asyncBlock = blocks[indexBlock];
|
4156
|
+
for (const asyncBlock of blocks) {
|
4166
4157
|
const chunkGroup =
|
4167
4158
|
/** @type {ChunkGroup} */
|
4168
4159
|
(this.chunkGraph.getBlockChunkGroup(asyncBlock));
|
4169
4160
|
// Grab all chunks from the first Block's AsyncDepBlock
|
4170
4161
|
const chunks = chunkGroup.chunks;
|
4171
4162
|
// For each chunk in chunkGroup
|
4172
|
-
for (
|
4173
|
-
const iteratedChunk = chunks[indexChunk];
|
4163
|
+
for (const iteratedChunk of chunks) {
|
4174
4164
|
chunkGroup.removeChunk(iteratedChunk);
|
4175
4165
|
// Recurse
|
4176
4166
|
this.removeChunkFromDependencies(block, iteratedChunk);
|
@@ -4211,13 +4201,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
4211
4201
|
}
|
4212
4202
|
|
4213
4203
|
summarizeDependencies() {
|
4214
|
-
for (
|
4215
|
-
let indexChildren = 0;
|
4216
|
-
indexChildren < this.children.length;
|
4217
|
-
indexChildren++
|
4218
|
-
) {
|
4219
|
-
const child = this.children[indexChildren];
|
4220
|
-
|
4204
|
+
for (const child of this.children) {
|
4221
4205
|
this.fileDependencies.addAll(child.fileDependencies);
|
4222
4206
|
this.contextDependencies.addAll(child.contextDependencies);
|
4223
4207
|
this.missingDependencies.addAll(child.missingDependencies);
|
package/lib/ConstPlugin.js
CHANGED
@@ -179,53 +179,21 @@ class ConstPlugin {
|
|
179
179
|
? statement.alternate
|
180
180
|
: statement.consequent;
|
181
181
|
if (branchToRemove) {
|
182
|
-
|
183
|
-
// must be collected.
|
184
|
-
//
|
185
|
-
// Given the following code:
|
186
|
-
//
|
187
|
-
// if (true) f() else g()
|
188
|
-
// if (false) {
|
189
|
-
// function f() {}
|
190
|
-
// const g = function g() {}
|
191
|
-
// if (someTest) {
|
192
|
-
// let a = 1
|
193
|
-
// var x, {y, z} = obj
|
194
|
-
// }
|
195
|
-
// } else {
|
196
|
-
// …
|
197
|
-
// }
|
198
|
-
//
|
199
|
-
// the generated code is:
|
200
|
-
//
|
201
|
-
// if (true) f() else {}
|
202
|
-
// if (false) {
|
203
|
-
// var f, x, y, z; (in loose mode)
|
204
|
-
// var x, y, z; (in strict mode)
|
205
|
-
// } else {
|
206
|
-
// …
|
207
|
-
// }
|
208
|
-
//
|
209
|
-
// NOTE: When code runs in strict mode, `var` declarations
|
210
|
-
// are hoisted but `function` declarations don't.
|
211
|
-
//
|
212
|
-
const declarations = parser.scope.isStrict
|
213
|
-
? getHoistedDeclarations(branchToRemove, false)
|
214
|
-
: getHoistedDeclarations(branchToRemove, true);
|
215
|
-
const replacement =
|
216
|
-
declarations.length > 0
|
217
|
-
? `{ var ${declarations.join(", ")}; }`
|
218
|
-
: "{}";
|
219
|
-
const dep = new ConstDependency(
|
220
|
-
replacement,
|
221
|
-
/** @type {Range} */ (branchToRemove.range)
|
222
|
-
);
|
223
|
-
dep.loc = /** @type {SourceLocation} */ (branchToRemove.loc);
|
224
|
-
parser.state.module.addPresentationalDependency(dep);
|
182
|
+
this.eliminateUnusedStatement(parser, branchToRemove);
|
225
183
|
}
|
226
184
|
return bool;
|
227
185
|
}
|
228
186
|
});
|
187
|
+
parser.hooks.unusedStatement.tap(PLUGIN_NAME, statement => {
|
188
|
+
if (
|
189
|
+
parser.scope.isAsmJs ||
|
190
|
+
// Check top level scope here again
|
191
|
+
parser.scope.topLevelScope === true
|
192
|
+
)
|
193
|
+
return;
|
194
|
+
this.eliminateUnusedStatement(parser, statement);
|
195
|
+
return true;
|
196
|
+
});
|
229
197
|
parser.hooks.expressionConditionalOperator.tap(
|
230
198
|
PLUGIN_NAME,
|
231
199
|
expression => {
|
@@ -534,6 +502,56 @@ class ConstPlugin {
|
|
534
502
|
}
|
535
503
|
);
|
536
504
|
}
|
505
|
+
|
506
|
+
/**
|
507
|
+
* Eliminate an unused statement.
|
508
|
+
* @param {JavascriptParser} parser the parser
|
509
|
+
* @param {Statement} statement the statement to remove
|
510
|
+
* @returns {void}
|
511
|
+
*/
|
512
|
+
eliminateUnusedStatement(parser, statement) {
|
513
|
+
// Before removing the unused branch, the hoisted declarations
|
514
|
+
// must be collected.
|
515
|
+
//
|
516
|
+
// Given the following code:
|
517
|
+
//
|
518
|
+
// if (true) f() else g()
|
519
|
+
// if (false) {
|
520
|
+
// function f() {}
|
521
|
+
// const g = function g() {}
|
522
|
+
// if (someTest) {
|
523
|
+
// let a = 1
|
524
|
+
// var x, {y, z} = obj
|
525
|
+
// }
|
526
|
+
// } else {
|
527
|
+
// …
|
528
|
+
// }
|
529
|
+
//
|
530
|
+
// the generated code is:
|
531
|
+
//
|
532
|
+
// if (true) f() else {}
|
533
|
+
// if (false) {
|
534
|
+
// var f, x, y, z; (in loose mode)
|
535
|
+
// var x, y, z; (in strict mode)
|
536
|
+
// } else {
|
537
|
+
// …
|
538
|
+
// }
|
539
|
+
//
|
540
|
+
// NOTE: When code runs in strict mode, `var` declarations
|
541
|
+
// are hoisted but `function` declarations don't.
|
542
|
+
//
|
543
|
+
const declarations = parser.scope.isStrict
|
544
|
+
? getHoistedDeclarations(statement, false)
|
545
|
+
: getHoistedDeclarations(statement, true);
|
546
|
+
const replacement =
|
547
|
+
declarations.length > 0 ? `{ var ${declarations.join(", ")}; }` : "{}";
|
548
|
+
const dep = new ConstDependency(
|
549
|
+
`// removed by dead control flow\n${replacement}`,
|
550
|
+
/** @type {Range} */ (statement.range)
|
551
|
+
);
|
552
|
+
dep.loc = /** @type {SourceLocation} */ (statement.loc);
|
553
|
+
parser.state.module.addPresentationalDependency(dep);
|
554
|
+
}
|
537
555
|
}
|
538
556
|
|
539
557
|
module.exports = ConstPlugin;
|
package/lib/CssModule.js
CHANGED
package/lib/Dependency.js
CHANGED
@@ -131,23 +131,22 @@ class Dependency {
|
|
131
131
|
*/
|
132
132
|
get loc() {
|
133
133
|
if (this._loc !== undefined) return this._loc;
|
134
|
+
|
134
135
|
/** @type {SyntheticDependencyLocation & RealDependencyLocation} */
|
135
|
-
const loc = {
|
136
|
-
|
137
|
-
end: { line: 0, column: 0 },
|
138
|
-
name: "",
|
139
|
-
index: -1
|
140
|
-
};
|
136
|
+
const loc = {};
|
137
|
+
|
141
138
|
if (this._locSL > 0) {
|
142
139
|
loc.start = { line: this._locSL, column: this._locSC };
|
143
140
|
}
|
144
141
|
if (this._locEL > 0) {
|
145
142
|
loc.end = { line: this._locEL, column: this._locEC };
|
146
143
|
}
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
144
|
+
if (this._locN !== undefined) {
|
145
|
+
loc.name = this._locN;
|
146
|
+
}
|
147
|
+
if (this._locI !== undefined) {
|
148
|
+
loc.index = this._locI;
|
149
|
+
}
|
151
150
|
|
152
151
|
return (this._loc = loc);
|
153
152
|
}
|
@@ -292,7 +291,7 @@ class Dependency {
|
|
292
291
|
|
293
292
|
/**
|
294
293
|
* @param {string} context context directory
|
295
|
-
* @returns {Module
|
294
|
+
* @returns {Module} ignored module
|
296
295
|
*/
|
297
296
|
createIgnoredModule(context) {
|
298
297
|
return getIgnoredModule();
|
package/lib/FileSystemInfo.js
CHANGED
@@ -708,7 +708,6 @@ class SnapshotOptimization {
|
|
708
708
|
};
|
709
709
|
}
|
710
710
|
this._map.set(path, newOptimizationEntry);
|
711
|
-
continue;
|
712
711
|
} else {
|
713
712
|
optimizationEntries.add(optimizationEntry);
|
714
713
|
}
|
@@ -742,7 +741,6 @@ class SnapshotOptimization {
|
|
742
741
|
continue optimizationEntriesLabel;
|
743
742
|
}
|
744
743
|
nonSharedFiles.add(path);
|
745
|
-
continue;
|
746
744
|
}
|
747
745
|
}
|
748
746
|
if (nonSharedFiles.size === 0) {
|
package/lib/NormalModule.js
CHANGED
@@ -81,11 +81,13 @@ const memoize = require("./util/memoize");
|
|
81
81
|
/** @typedef {import("./ModuleTypeConstants").JavaScriptModuleTypes} JavaScriptModuleTypes */
|
82
82
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
83
83
|
/** @typedef {import("./NormalModuleFactory").ResourceDataWithData} ResourceDataWithData */
|
84
|
+
/** @typedef {import("./NormalModuleFactory").ResourceSchemeData} ResourceSchemeData */
|
84
85
|
/** @typedef {import("./Parser")} Parser */
|
85
86
|
/** @typedef {import("./Parser").PreparsedAst} PreparsedAst */
|
86
87
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
87
88
|
/** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */
|
88
89
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
90
|
+
/** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */
|
89
91
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
90
92
|
/** @typedef {import("./logging/Logger").Logger} WebpackLogger */
|
91
93
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
@@ -250,7 +252,7 @@ makeSerializable(
|
|
250
252
|
* @property {string} rawRequest request without resolving
|
251
253
|
* @property {LoaderItem[]} loaders list of loaders
|
252
254
|
* @property {string} resource path + query of the real resource
|
253
|
-
* @property {
|
255
|
+
* @property {(ResourceSchemeData & Partial<ResolveRequest>)=} resourceResolveData resource resolve data
|
254
256
|
* @property {string} context context directory for resolving
|
255
257
|
* @property {string=} matchResource path + query of the matched resource (virtual)
|
256
258
|
* @property {Parser} parser the parser used
|
@@ -587,12 +589,14 @@ class NormalModule extends Module {
|
|
587
589
|
* @param {Compilation} compilation the compilation
|
588
590
|
* @param {InputFileSystem} fs file system from reading
|
589
591
|
* @param {NormalModuleCompilationHooks} hooks the hooks
|
590
|
-
* @returns {import("../declarations/LoaderContext").
|
592
|
+
* @returns {import("../declarations/LoaderContext").LoaderContext<T>} loader context
|
591
593
|
*/
|
592
594
|
_createLoaderContext(resolver, options, compilation, fs, hooks) {
|
593
595
|
const { requestShortener } = compilation.runtimeTemplate;
|
594
596
|
const getCurrentLoaderName = () => {
|
595
|
-
const currentLoader = this.getCurrentLoader(
|
597
|
+
const currentLoader = this.getCurrentLoader(
|
598
|
+
/** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext)
|
599
|
+
);
|
596
600
|
if (!currentLoader) return "(not in loader scope)";
|
597
601
|
return requestShortener.shorten(currentLoader.loader);
|
598
602
|
};
|
@@ -601,13 +605,22 @@ class NormalModule extends Module {
|
|
601
605
|
*/
|
602
606
|
const getResolveContext = () => ({
|
603
607
|
fileDependencies: {
|
604
|
-
add: d =>
|
608
|
+
add: d =>
|
609
|
+
/** @type {LoaderContext<EXPECTED_ANY>} */ (
|
610
|
+
loaderContext
|
611
|
+
).addDependency(d)
|
605
612
|
},
|
606
613
|
contextDependencies: {
|
607
|
-
add: d =>
|
614
|
+
add: d =>
|
615
|
+
/** @type {LoaderContext<EXPECTED_ANY>} */ (
|
616
|
+
loaderContext
|
617
|
+
).addContextDependency(d)
|
608
618
|
},
|
609
619
|
missingDependencies: {
|
610
|
-
add: d =>
|
620
|
+
add: d =>
|
621
|
+
/** @type {LoaderContext<EXPECTED_ANY>} */ (
|
622
|
+
loaderContext
|
623
|
+
).addMissingDependency(d)
|
611
624
|
}
|
612
625
|
});
|
613
626
|
const getAbsolutify = memoize(() =>
|
@@ -668,7 +681,9 @@ class NormalModule extends Module {
|
|
668
681
|
* @returns {T} options
|
669
682
|
*/
|
670
683
|
getOptions: schema => {
|
671
|
-
const loader = this.getCurrentLoader(
|
684
|
+
const loader = this.getCurrentLoader(
|
685
|
+
/** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext)
|
686
|
+
);
|
672
687
|
|
673
688
|
let { options } = /** @type {LoaderItem} */ (loader);
|
674
689
|
|
@@ -728,7 +743,9 @@ class NormalModule extends Module {
|
|
728
743
|
);
|
729
744
|
},
|
730
745
|
getLogger: name => {
|
731
|
-
const currentLoader = this.getCurrentLoader(
|
746
|
+
const currentLoader = this.getCurrentLoader(
|
747
|
+
/** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext)
|
748
|
+
);
|
732
749
|
return compilation.getLogger(() =>
|
733
750
|
[currentLoader && currentLoader.loader, name, this.identifier()]
|
734
751
|
.filter(Boolean)
|
@@ -816,18 +833,19 @@ class NormalModule extends Module {
|
|
816
833
|
|
817
834
|
Object.assign(loaderContext, options.loader);
|
818
835
|
|
836
|
+
// After `hooks.loader.call` is called, the loaderContext is typed as LoaderContext<EXPECTED_ANY>
|
819
837
|
hooks.loader.call(
|
820
838
|
/** @type {LoaderContext<EXPECTED_ANY>} */
|
821
839
|
(loaderContext),
|
822
840
|
this
|
823
841
|
);
|
824
842
|
|
825
|
-
return loaderContext;
|
843
|
+
return /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext);
|
826
844
|
}
|
827
845
|
|
828
846
|
// TODO remove `loaderContext` in webpack@6
|
829
847
|
/**
|
830
|
-
* @param {
|
848
|
+
* @param {LoaderContext<EXPECTED_ANY>} loaderContext loader context
|
831
849
|
* @param {number} index index
|
832
850
|
* @returns {LoaderItem | null} loader
|
833
851
|
*/
|
@@ -998,7 +1016,7 @@ class NormalModule extends Module {
|
|
998
1016
|
loaders: this.loaders,
|
999
1017
|
context: loaderContext,
|
1000
1018
|
/**
|
1001
|
-
* @param {LoaderContext<
|
1019
|
+
* @param {LoaderContext<EXPECTED_ANY>} loaderContext the loader context
|
1002
1020
|
* @param {string} resourcePath the resource Path
|
1003
1021
|
* @param {(err: Error | null, result?: string | Buffer) => void} callback callback
|
1004
1022
|
*/
|
@@ -1662,7 +1680,7 @@ class NormalModule extends Module {
|
|
1662
1680
|
|
1663
1681
|
/**
|
1664
1682
|
* @param {ObjectDeserializerContext} context context
|
1665
|
-
* @returns {
|
1683
|
+
* @returns {NormalModule} module
|
1666
1684
|
*/
|
1667
1685
|
static deserialize(context) {
|
1668
1686
|
const obj = new NormalModule({
|
@@ -85,7 +85,15 @@ const {
|
|
85
85
|
* @property {string=} context
|
86
86
|
*/
|
87
87
|
|
88
|
-
/**
|
88
|
+
/**
|
89
|
+
* @typedef {object} ResourceSchemeData
|
90
|
+
* @property {string=} mimetype mime type of the resource
|
91
|
+
* @property {string=} parameters additional parameters for the resource
|
92
|
+
* @property {"base64" | false=} encoding encoding of the resource
|
93
|
+
* @property {string=} encodedContent encoded content of the resource
|
94
|
+
*/
|
95
|
+
|
96
|
+
/** @typedef {ResourceData & { data: ResourceSchemeData & Partial<ResolveRequest> }} ResourceDataWithData */
|
89
97
|
|
90
98
|
/**
|
91
99
|
* @typedef {object} ParsedLoaderRequest
|
@@ -321,6 +329,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
321
329
|
/** @type {Set<Module>} */
|
322
330
|
this._restoredUnsafeCacheEntries = new Set();
|
323
331
|
|
332
|
+
/** @type {(resource: string) => import("./util/identifier").ParsedResource} */
|
324
333
|
const cacheParseResource = parseResource.bindCache(
|
325
334
|
associatedObjectForCache
|
326
335
|
);
|
@@ -447,21 +456,22 @@ class NormalModuleFactory extends ModuleFactory {
|
|
447
456
|
const matchResourceMatch = MATCH_RESOURCE_REGEX.exec(request);
|
448
457
|
if (matchResourceMatch) {
|
449
458
|
let matchResource = matchResourceMatch[1];
|
459
|
+
// Check if matchResource starts with ./ or ../
|
450
460
|
if (matchResource.charCodeAt(0) === 46) {
|
451
|
-
// 46
|
461
|
+
// 46 is "."
|
452
462
|
const secondChar = matchResource.charCodeAt(1);
|
453
463
|
if (
|
454
|
-
secondChar === 47 ||
|
455
|
-
(secondChar === 46 && matchResource.charCodeAt(2) === 47)
|
464
|
+
secondChar === 47 || // 47 is "/"
|
465
|
+
(secondChar === 46 && matchResource.charCodeAt(2) === 47) // "../"
|
456
466
|
) {
|
457
|
-
//
|
467
|
+
// Resolve relative path against context
|
458
468
|
matchResource = join(this.fs, context, matchResource);
|
459
469
|
}
|
460
470
|
}
|
461
471
|
|
462
472
|
matchResourceData = {
|
463
|
-
|
464
|
-
|
473
|
+
...cacheParseResource(matchResource),
|
474
|
+
resource: matchResource
|
465
475
|
};
|
466
476
|
requestWithoutMatchResource = request.slice(
|
467
477
|
matchResourceMatch[0].length
|
@@ -546,11 +556,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
546
556
|
|
547
557
|
if (!resourceData) {
|
548
558
|
// ignored
|
549
|
-
return callback(
|
550
|
-
null,
|
551
|
-
/** @type {TODO} */
|
552
|
-
(dependencies[0].createIgnoredModule(context))
|
553
|
-
);
|
559
|
+
return callback(null, dependencies[0].createIgnoredModule(context));
|
554
560
|
}
|
555
561
|
|
556
562
|
const userRequest =
|
@@ -759,9 +765,9 @@ class NormalModuleFactory extends ModuleFactory {
|
|
759
765
|
const defaultResolve = context => {
|
760
766
|
if (/^($|\?)/.test(unresolvedResource)) {
|
761
767
|
resourceData = {
|
768
|
+
...cacheParseResource(unresolvedResource),
|
762
769
|
resource: unresolvedResource,
|
763
|
-
data: {}
|
764
|
-
.../** @type {TODO} */ (cacheParseResource(unresolvedResource))
|
770
|
+
data: {}
|
765
771
|
};
|
766
772
|
continueCallback();
|
767
773
|
}
|
@@ -791,12 +797,11 @@ class NormalModuleFactory extends ModuleFactory {
|
|
791
797
|
/** @type {string} */
|
792
798
|
(_resolvedResource);
|
793
799
|
resourceData = {
|
800
|
+
...cacheParseResource(resolvedResource),
|
794
801
|
resource: resolvedResource,
|
795
802
|
data:
|
796
803
|
/** @type {ResolveRequest} */
|
797
|
-
(resolvedResourceResolveData)
|
798
|
-
.../** @type {TODO} */
|
799
|
-
(cacheParseResource(resolvedResource))
|
804
|
+
(resolvedResourceResolveData)
|
800
805
|
};
|
801
806
|
}
|
802
807
|
continueCallback();
|
@@ -1228,7 +1233,7 @@ If changing the source code is not an option there is also a resolve options cal
|
|
1228
1233
|
}
|
1229
1234
|
);
|
1230
1235
|
},
|
1231
|
-
/** @type {Callback<
|
1236
|
+
/** @type {Callback<(LoaderItem | undefined)[]>} */ (callback)
|
1232
1237
|
);
|
1233
1238
|
}
|
1234
1239
|
|
package/lib/RuntimePlugin.js
CHANGED
@@ -165,7 +165,7 @@ const encodeDataUri = (encoding, source) => {
|
|
165
165
|
};
|
166
166
|
|
167
167
|
/**
|
168
|
-
* @param {
|
168
|
+
* @param {"base64" | false} encoding encoding
|
169
169
|
* @param {string} content content
|
170
170
|
* @returns {Buffer} decoded content
|
171
171
|
*/
|
@@ -475,7 +475,6 @@ class AssetGenerator extends Generator {
|
|
475
475
|
module
|
476
476
|
});
|
477
477
|
} else {
|
478
|
-
/** @type {"base64" | false | undefined} */
|
479
478
|
let encoding =
|
480
479
|
/** @type {AssetGeneratorDataUrlOptions} */
|
481
480
|
(this.dataUrlOptions).encoding;
|
@@ -498,12 +497,15 @@ class AssetGenerator extends Generator {
|
|
498
497
|
module.resourceResolveData.encoding === encoding &&
|
499
498
|
decodeDataUriContent(
|
500
499
|
module.resourceResolveData.encoding,
|
501
|
-
module.resourceResolveData.encodedContent
|
500
|
+
/** @type {string} */ (module.resourceResolveData.encodedContent)
|
502
501
|
).equals(source.buffer())
|
503
502
|
) {
|
504
503
|
encodedContent = module.resourceResolveData.encodedContent;
|
505
504
|
} else {
|
506
|
-
encodedContent = encodeDataUri(
|
505
|
+
encodedContent = encodeDataUri(
|
506
|
+
/** @type {"base64" | false} */ (encoding),
|
507
|
+
source
|
508
|
+
);
|
507
509
|
}
|
508
510
|
|
509
511
|
encodedSource = `data:${mimeType}${
|
@@ -655,6 +657,7 @@ class AssetGenerator extends Generator {
|
|
655
657
|
* @returns {SourceTypes} available types (do not mutate)
|
656
658
|
*/
|
657
659
|
getTypes(module) {
|
660
|
+
/** @type {Set<string>} */
|
658
661
|
const sourceTypes = new Set();
|
659
662
|
const connections = this._moduleGraph.getIncomingConnections(module);
|
660
663
|
|
@@ -667,27 +670,25 @@ class AssetGenerator extends Generator {
|
|
667
670
|
}
|
668
671
|
|
669
672
|
if ((module.buildInfo && module.buildInfo.dataUrl) || this.emit === false) {
|
670
|
-
if (sourceTypes) {
|
673
|
+
if (sourceTypes.size > 0) {
|
671
674
|
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
|
672
675
|
return JS_AND_CSS_URL_TYPES;
|
673
|
-
} else if (sourceTypes.has("javascript")) {
|
674
|
-
return JS_TYPES;
|
675
676
|
} else if (sourceTypes.has("css")) {
|
676
677
|
return CSS_URL_TYPES;
|
677
678
|
}
|
679
|
+
return JS_TYPES;
|
678
680
|
}
|
679
681
|
|
680
682
|
return NO_TYPES;
|
681
683
|
}
|
682
684
|
|
683
|
-
if (sourceTypes) {
|
685
|
+
if (sourceTypes.size > 0) {
|
684
686
|
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
|
685
687
|
return ASSET_AND_JS_AND_CSS_URL_TYPES;
|
686
|
-
} else if (sourceTypes.has("javascript")) {
|
687
|
-
return ASSET_AND_JS_TYPES;
|
688
688
|
} else if (sourceTypes.has("css")) {
|
689
689
|
return ASSET_AND_CSS_URL_TYPES;
|
690
690
|
}
|
691
|
+
return ASSET_AND_JS_TYPES;
|
691
692
|
}
|
692
693
|
|
693
694
|
return ASSET_TYPES;
|
@@ -122,6 +122,7 @@ class AssetSourceGenerator extends Generator {
|
|
122
122
|
* @returns {SourceTypes} available types (do not mutate)
|
123
123
|
*/
|
124
124
|
getTypes(module) {
|
125
|
+
/** @type {Set<string>} */
|
125
126
|
const sourceTypes = new Set();
|
126
127
|
const connections = this._moduleGraph.getIncomingConnections(module);
|
127
128
|
|
@@ -133,12 +134,13 @@ class AssetSourceGenerator extends Generator {
|
|
133
134
|
sourceTypes.add(connection.originModule.type.split("/")[0]);
|
134
135
|
}
|
135
136
|
|
136
|
-
if (sourceTypes.
|
137
|
-
|
138
|
-
|
137
|
+
if (sourceTypes.size > 0) {
|
138
|
+
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
|
139
|
+
return JS_AND_CSS_URL_TYPES;
|
140
|
+
} else if (sourceTypes.has("css")) {
|
141
|
+
return CSS_URL_TYPES;
|
142
|
+
}
|
139
143
|
return JS_TYPES;
|
140
|
-
} else if (sourceTypes.has("css")) {
|
141
|
-
return CSS_URL_TYPES;
|
142
144
|
}
|
143
145
|
|
144
146
|
return NO_TYPES;
|
@@ -53,7 +53,7 @@ class CssUrlDependency extends ModuleDependency {
|
|
53
53
|
|
54
54
|
/**
|
55
55
|
* @param {string} context context directory
|
56
|
-
* @returns {Module
|
56
|
+
* @returns {Module} ignored module
|
57
57
|
*/
|
58
58
|
createIgnoredModule(context) {
|
59
59
|
return getIgnoredRawDataUrlModule();
|
@@ -109,7 +109,10 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
109
109
|
}
|
110
110
|
if (successExpression) {
|
111
111
|
if (successExpression.fn.body.type === "BlockStatement") {
|
112
|
+
// Opt-out of Dead Control Flow detection for this block
|
113
|
+
const oldTerminated = parser.scope.terminated;
|
112
114
|
parser.walkStatement(successExpression.fn.body);
|
115
|
+
parser.scope.terminated = oldTerminated;
|
113
116
|
} else {
|
114
117
|
parser.walkExpression(successExpression.fn.body);
|
115
118
|
}
|
@@ -72,7 +72,7 @@ class URLDependency extends ModuleDependency {
|
|
72
72
|
|
73
73
|
/**
|
74
74
|
* @param {string} context context directory
|
75
|
-
* @returns {Module
|
75
|
+
* @returns {Module} ignored module
|
76
76
|
*/
|
77
77
|
createIgnoredModule(context) {
|
78
78
|
return getIgnoredRawDataUrlModule();
|
@@ -216,9 +216,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
216
216
|
"// setup Promise in chunk cache",
|
217
217
|
`var promise = ${importFunctionName}(${
|
218
218
|
compilation.outputOptions.publicPath === "auto"
|
219
|
-
?
|
220
|
-
:
|
221
|
-
}
|
219
|
+
? JSON.stringify(rootOutputDir)
|
220
|
+
: RuntimeGlobals.publicPath
|
221
|
+
} + ${
|
222
222
|
RuntimeGlobals.getChunkScriptFilename
|
223
223
|
}(chunkId)).then(installChunk, ${runtimeTemplate.basicFunction(
|
224
224
|
"e",
|
@@ -578,7 +578,9 @@ class JavascriptParser extends Parser {
|
|
578
578
|
/** @type {SyncBailHook<[ThrowStatement | ReturnStatement], boolean | void>} */
|
579
579
|
terminate: new SyncBailHook(["statement"]),
|
580
580
|
/** @type {SyncBailHook<[Program, Comment[]], boolean | void>} */
|
581
|
-
finish: new SyncBailHook(["ast", "comments"])
|
581
|
+
finish: new SyncBailHook(["ast", "comments"]),
|
582
|
+
/** @type {SyncBailHook<[Statement], boolean | void>} */
|
583
|
+
unusedStatement: new SyncBailHook(["statement"])
|
582
584
|
});
|
583
585
|
this.sourceType = sourceType;
|
584
586
|
/** @type {ScopeInfo} */
|
@@ -1939,8 +1941,13 @@ class JavascriptParser extends Parser {
|
|
1939
1941
|
for (let index = 0, len = statements.length; index < len; index++) {
|
1940
1942
|
const statement = statements[index];
|
1941
1943
|
|
1942
|
-
if (
|
1944
|
+
if (
|
1945
|
+
onlyFunctionDeclaration &&
|
1946
|
+
statement.type !== "FunctionDeclaration" &&
|
1947
|
+
this.hooks.unusedStatement.call(/** @type {Statement} */ (statement))
|
1948
|
+
) {
|
1943
1949
|
continue;
|
1950
|
+
}
|
1944
1951
|
|
1945
1952
|
this.walkStatement(statement);
|
1946
1953
|
|
@@ -2852,11 +2859,18 @@ class JavascriptParser extends Parser {
|
|
2852
2859
|
for (let i = 0; i < properties.length; i++) {
|
2853
2860
|
const property = properties[i];
|
2854
2861
|
if (property.type !== "Property") return;
|
2855
|
-
if (property.shorthand
|
2856
|
-
|
2862
|
+
if (property.shorthand) {
|
2863
|
+
if (property.value.type === "Identifier") {
|
2864
|
+
this.scope.inShorthand = property.value.name;
|
2865
|
+
} else if (
|
2866
|
+
property.value.type === "AssignmentPattern" &&
|
2867
|
+
property.value.left.type === "Identifier"
|
2868
|
+
) {
|
2869
|
+
this.scope.inShorthand = property.value.left.name;
|
2870
|
+
}
|
2857
2871
|
}
|
2858
2872
|
const key = property.key;
|
2859
|
-
if (key.type === "Identifier") {
|
2873
|
+
if (key.type === "Identifier" && !property.computed) {
|
2860
2874
|
props.add({
|
2861
2875
|
id: key.name,
|
2862
2876
|
range: key.range,
|
@@ -82,7 +82,10 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
82
82
|
for (const chunk of compilation.chunkGraph.getModuleChunksIterable(
|
83
83
|
module
|
84
84
|
)) {
|
85
|
-
if (
|
85
|
+
if (
|
86
|
+
!chunk.hasRuntime() ||
|
87
|
+
compilation.chunkGraph.getNumberOfEntryModules(chunk) > 1
|
88
|
+
) {
|
86
89
|
return false;
|
87
90
|
}
|
88
91
|
}
|
@@ -105,7 +105,9 @@ class SideEffectsFlagPlugin {
|
|
105
105
|
}
|
106
106
|
const hasSideEffects = SideEffectsFlagPlugin.moduleHasSideEffects(
|
107
107
|
resolveData.relativePath,
|
108
|
-
|
108
|
+
/** @type {string | boolean | string[] | undefined} */ (
|
109
|
+
sideEffects
|
110
|
+
),
|
109
111
|
/** @type {CacheItem} */ (cache)
|
110
112
|
);
|
111
113
|
module.factoryMeta.sideEffectFree = !hasSideEffects;
|
@@ -40,7 +40,7 @@ const { SyncHook } = require("tapable");
|
|
40
40
|
* @property {ImportAttributes=} assertions
|
41
41
|
* @property {string=} mimetype
|
42
42
|
* @property {string} dependency
|
43
|
-
* @property {Record<string, EXPECTED_ANY
|
43
|
+
* @property {Record<string, EXPECTED_ANY>=} descriptionData
|
44
44
|
* @property {string=} compiler
|
45
45
|
* @property {string} issuer
|
46
46
|
* @property {string} issuerLayer
|
@@ -56,7 +56,9 @@ class DataUriPlugin {
|
|
56
56
|
if (match) {
|
57
57
|
resourceData.data.mimetype = match[1] || "";
|
58
58
|
resourceData.data.parameters = match[2] || "";
|
59
|
-
resourceData.data.encoding =
|
59
|
+
resourceData.data.encoding = /** @type {"base64" | false} */ (
|
60
|
+
match[3] || false
|
61
|
+
);
|
60
62
|
resourceData.data.encodedContent = match[4] || "";
|
61
63
|
}
|
62
64
|
});
|
@@ -141,7 +141,9 @@ class ProvideSharedPlugin {
|
|
141
141
|
} else if (!descriptionFileData.version) {
|
142
142
|
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
143
143
|
} else {
|
144
|
-
version =
|
144
|
+
version = /** @type {string | false | undefined} */ (
|
145
|
+
descriptionFileData.version
|
146
|
+
);
|
145
147
|
}
|
146
148
|
}
|
147
149
|
if (!version) {
|
@@ -1454,7 +1454,12 @@ const AVAILABLE_COLORS = {
|
|
1454
1454
|
magenta: "\u001B[1m\u001B[35m"
|
1455
1455
|
};
|
1456
1456
|
|
1457
|
-
/**
|
1457
|
+
/**
|
1458
|
+
* @template T
|
1459
|
+
* @typedef {T extends [infer Head, ...infer Tail] ? Tail : undefined} Tail
|
1460
|
+
*/
|
1461
|
+
|
1462
|
+
/** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }>} AvailableFormats */
|
1458
1463
|
|
1459
1464
|
/** @type {AvailableFormats} */
|
1460
1465
|
const AVAILABLE_FORMATS = {
|
@@ -1629,21 +1634,16 @@ class DefaultStatsPrinterPlugin {
|
|
1629
1634
|
context[color] = str => str;
|
1630
1635
|
}
|
1631
1636
|
}
|
1632
|
-
for (const
|
1637
|
+
for (const _format of Object.keys(AVAILABLE_FORMATS)) {
|
1638
|
+
const format =
|
1639
|
+
/** @type {keyof KnownStatsPrinterFormatters} */
|
1640
|
+
(_format);
|
1641
|
+
|
1633
1642
|
context[format] =
|
1634
|
-
/**
|
1635
|
-
* @param {string | number} content content
|
1636
|
-
* @param {...TODO} args args
|
1637
|
-
* @returns {string} result
|
1638
|
-
*/
|
1643
|
+
/** @type {(content: Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>[0], ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>>) => string} */
|
1639
1644
|
(content, ...args) =>
|
1640
1645
|
/** @type {TODO} */
|
1641
|
-
(
|
1642
|
-
AVAILABLE_FORMATS[
|
1643
|
-
/** @type {keyof AvailableFormats} */
|
1644
|
-
(format)
|
1645
|
-
]
|
1646
|
-
)(
|
1646
|
+
(AVAILABLE_FORMATS)[format](
|
1647
1647
|
content,
|
1648
1648
|
/** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
|
1649
1649
|
(context),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.99.
|
3
|
+
"version": "5.99.9",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -38,7 +38,7 @@
|
|
38
38
|
"devDependencies": {
|
39
39
|
"@babel/core": "^7.27.1",
|
40
40
|
"@babel/preset-react": "^7.27.1",
|
41
|
-
"@codspeed/
|
41
|
+
"@codspeed/tinybench-plugin": "^4.0.1",
|
42
42
|
"@eslint/js": "^9.21.0",
|
43
43
|
"@stylistic/eslint-plugin": "^4.2.0",
|
44
44
|
"@types/glob-to-regexp": "^0.4.4",
|
@@ -48,12 +48,11 @@
|
|
48
48
|
"@types/xxhashjs": "^0.2.4",
|
49
49
|
"assemblyscript": "^0.27.34",
|
50
50
|
"babel-loader": "^10.0.0",
|
51
|
-
"benchmark": "^2.1.4",
|
52
51
|
"bundle-loader": "^0.5.6",
|
53
52
|
"coffee-loader": "^5.0.0",
|
54
53
|
"coffeescript": "^2.5.1",
|
55
54
|
"core-js": "^3.6.5",
|
56
|
-
"cspell": "^
|
55
|
+
"cspell": "^9.0.1",
|
57
56
|
"css-loader": "^7.1.2",
|
58
57
|
"date-fns": "^4.0.0",
|
59
58
|
"es5-ext": "^0.10.53",
|
@@ -81,7 +80,7 @@
|
|
81
80
|
"json5": "^2.1.3",
|
82
81
|
"less": "^4.0.0",
|
83
82
|
"less-loader": "^12.2.0",
|
84
|
-
"lint-staged": "^
|
83
|
+
"lint-staged": "^16.0.0",
|
85
84
|
"lodash": "^4.17.19",
|
86
85
|
"lodash-es": "^4.17.15",
|
87
86
|
"memfs": "^4.14.0",
|
@@ -105,8 +104,9 @@
|
|
105
104
|
"style-loader": "^4.0.0",
|
106
105
|
"terser": "^5.38.1",
|
107
106
|
"three": "^0.176.0",
|
107
|
+
"tinybench": "^4.0.1",
|
108
108
|
"toml": "^3.0.0",
|
109
|
-
"tooling": "webpack/tooling#v1.23.
|
109
|
+
"tooling": "webpack/tooling#v1.23.9",
|
110
110
|
"ts-loader": "^9.5.1",
|
111
111
|
"typescript": "^5.8.2",
|
112
112
|
"url-loader": "^4.1.0",
|
@@ -170,17 +170,18 @@
|
|
170
170
|
"pretest": "yarn lint",
|
171
171
|
"test": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
|
172
172
|
"test:update-snapshots": "yarn test -u",
|
173
|
-
"test:
|
174
|
-
"test:
|
175
|
-
"test:
|
173
|
+
"test:basic": "yarn test --testMatch \"<rootDir>/test/*.basictest.js\"",
|
174
|
+
"test:unit": "yarn test --testMatch \"<rootDir>/test/*.unittest.js\"",
|
175
|
+
"test:integration": "yarn test --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
|
176
176
|
"cover": "yarn cover:all && yarn cover:report",
|
177
177
|
"cover:clean": "rimraf .nyc_output coverage",
|
178
|
-
"cover:all": "
|
179
|
-
"cover:
|
180
|
-
"cover:
|
181
|
-
"cover:integration
|
182
|
-
"cover:integration:
|
183
|
-
"cover:
|
178
|
+
"cover:all": "yarn cover:base --coverage",
|
179
|
+
"cover:unit": "yarn cover:base --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
|
180
|
+
"cover:basic": "yarn cover:base --testMatch \"<rootDir>/test/*.basictest.js\" --coverage",
|
181
|
+
"cover:integration": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" --coverage",
|
182
|
+
"cover:integration:a": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage",
|
183
|
+
"cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage",
|
184
|
+
"cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage",
|
184
185
|
"cover:types": "node node_modules/tooling/type-coverage",
|
185
186
|
"cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
|
186
187
|
"cover:report": "nyc report --reporter=lcov --reporter=text -t coverage"
|
package/types.d.ts
CHANGED
@@ -3526,7 +3526,7 @@ declare class Dependency {
|
|
3526
3526
|
getModuleEvaluationSideEffectsState(
|
3527
3527
|
moduleGraph: ModuleGraph
|
3528
3528
|
): ConnectionState;
|
3529
|
-
createIgnoredModule(context: string):
|
3529
|
+
createIgnoredModule(context: string): Module;
|
3530
3530
|
serialize(__0: ObjectSerializerContext): void;
|
3531
3531
|
deserialize(__0: ObjectDeserializerContext): void;
|
3532
3532
|
module: any;
|
@@ -3933,7 +3933,7 @@ declare interface EffectData {
|
|
3933
3933
|
assertions?: ImportAttributes;
|
3934
3934
|
mimetype?: string;
|
3935
3935
|
dependency: string;
|
3936
|
-
descriptionData
|
3936
|
+
descriptionData?: Record<string, any>;
|
3937
3937
|
compiler?: string;
|
3938
3938
|
issuer: string;
|
3939
3939
|
issuerLayer: string;
|
@@ -6501,6 +6501,7 @@ declare class JavascriptParser extends Parser {
|
|
6501
6501
|
program: SyncBailHook<[Program, Comment[]], boolean | void>;
|
6502
6502
|
terminate: SyncBailHook<[ReturnStatement | ThrowStatement], boolean | void>;
|
6503
6503
|
finish: SyncBailHook<[Program, Comment[]], boolean | void>;
|
6504
|
+
unusedStatement: SyncBailHook<[Statement], boolean | void>;
|
6504
6505
|
}>;
|
6505
6506
|
sourceType: "module" | "auto" | "script";
|
6506
6507
|
scope: ScopeInfo;
|
@@ -10110,7 +10111,7 @@ declare class NormalModule extends Module {
|
|
10110
10111
|
generator?: Generator;
|
10111
10112
|
generatorOptions?: GeneratorOptions;
|
10112
10113
|
resource: string;
|
10113
|
-
resourceResolveData
|
10114
|
+
resourceResolveData?: ResourceSchemeData & Partial<ResolveRequest>;
|
10114
10115
|
matchResource?: string;
|
10115
10116
|
loaders: LoaderItem[];
|
10116
10117
|
error: null | WebpackError;
|
@@ -10129,7 +10130,10 @@ declare class NormalModule extends Module {
|
|
10129
10130
|
sourceMap?: string | SourceMap,
|
10130
10131
|
associatedObjectForCache?: object
|
10131
10132
|
): Source;
|
10132
|
-
getCurrentLoader(
|
10133
|
+
getCurrentLoader(
|
10134
|
+
loaderContext: LoaderContextNormalModule<any>,
|
10135
|
+
index?: number
|
10136
|
+
): null | LoaderItem;
|
10133
10137
|
createSource(
|
10134
10138
|
context: string,
|
10135
10139
|
content: string | Buffer,
|
@@ -10150,7 +10154,7 @@ declare class NormalModule extends Module {
|
|
10150
10154
|
static getCompilationHooks(
|
10151
10155
|
compilation: Compilation
|
10152
10156
|
): NormalModuleCompilationHooks;
|
10153
|
-
static deserialize(context: ObjectDeserializerContext):
|
10157
|
+
static deserialize(context: ObjectDeserializerContext): NormalModule;
|
10154
10158
|
}
|
10155
10159
|
declare interface NormalModuleCompilationHooks {
|
10156
10160
|
loader: SyncHook<[LoaderContextNormalModule<any>, NormalModule]>;
|
@@ -10214,7 +10218,7 @@ declare interface NormalModuleCreateData {
|
|
10214
10218
|
/**
|
10215
10219
|
* resource resolve data
|
10216
10220
|
*/
|
10217
|
-
resourceResolveData?:
|
10221
|
+
resourceResolveData?: ResourceSchemeData & Partial<ResolveRequest>;
|
10218
10222
|
|
10219
10223
|
/**
|
10220
10224
|
* context directory for resolving
|
@@ -13569,7 +13573,28 @@ declare interface ResourceDataWithData {
|
|
13569
13573
|
query?: string;
|
13570
13574
|
fragment?: string;
|
13571
13575
|
context?: string;
|
13572
|
-
data:
|
13576
|
+
data: ResourceSchemeData & Partial<ResolveRequest>;
|
13577
|
+
}
|
13578
|
+
declare interface ResourceSchemeData {
|
13579
|
+
/**
|
13580
|
+
* mime type of the resource
|
13581
|
+
*/
|
13582
|
+
mimetype?: string;
|
13583
|
+
|
13584
|
+
/**
|
13585
|
+
* additional parameters for the resource
|
13586
|
+
*/
|
13587
|
+
parameters?: string;
|
13588
|
+
|
13589
|
+
/**
|
13590
|
+
* encoding of the resource
|
13591
|
+
*/
|
13592
|
+
encoding?: false | "base64";
|
13593
|
+
|
13594
|
+
/**
|
13595
|
+
* encoded content of the resource
|
13596
|
+
*/
|
13597
|
+
encodedContent?: string;
|
13573
13598
|
}
|
13574
13599
|
declare abstract class RestoreProvidedData {
|
13575
13600
|
exports: RestoreProvidedDataExports[];
|