webpack 5.86.0 → 5.88.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 +1 -1
- package/lib/AsyncDependenciesBlock.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/ChunkGraph.js +4 -4
- package/lib/ChunkGroup.js +10 -3
- package/lib/CompatibilityPlugin.js +50 -30
- package/lib/Compilation.js +2 -1
- package/lib/Compiler.js +3 -1
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +57 -29
- package/lib/ContextModule.js +4 -1
- package/lib/ContextReplacementPlugin.js +13 -0
- package/lib/DelegatedModule.js +15 -3
- package/lib/DelegatedModuleFactoryPlugin.js +6 -0
- package/lib/Dependency.js +11 -5
- package/lib/DllEntryPlugin.js +11 -1
- package/lib/DllReferencePlugin.js +13 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/ErrorHelpers.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +4 -0
- package/lib/ExportsInfo.js +17 -3
- package/lib/ExportsInfoApiPlugin.js +14 -5
- package/lib/ExternalModule.js +5 -0
- package/lib/FlagAllModulesAsUsedPlugin.js +6 -1
- package/lib/FlagDependencyUsagePlugin.js +3 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/HotModuleReplacementPlugin.js +8 -0
- package/lib/InitFragment.js +28 -5
- package/lib/JavascriptMetaInfoPlugin.js +11 -6
- package/lib/LibManifestPlugin.js +20 -4
- package/lib/Module.js +7 -2
- 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/ModuleProfile.js +1 -0
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +7 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/NodeStuffPlugin.js +32 -6
- package/lib/ProvidePlugin.js +13 -4
- package/lib/RawModule.js +3 -1
- package/lib/RequireJsStuffPlugin.js +7 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +3 -3
- package/lib/RuntimePlugin.js +6 -3
- package/lib/RuntimeTemplate.js +22 -4
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +7 -2
- package/lib/UseStrictPlugin.js +10 -3
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackIsIncludedPlugin.js +6 -4
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/asset/AssetGenerator.js +2 -1
- package/lib/asset/AssetParser.js +11 -6
- package/lib/asset/AssetSourceParser.js +8 -3
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/PackFileCacheStrategy.js +35 -14
- package/lib/config/browserslistTargetHandler.js +7 -7
- package/lib/config/defaults.js +43 -26
- package/lib/container/RemoteRuntimeModule.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +30 -13
- package/lib/css/CssModulesPlugin.js +5 -2
- package/lib/css/CssParser.js +22 -0
- package/lib/dependencies/AMDDefineDependency.js +34 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +5 -0
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +14 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +169 -59
- package/lib/dependencies/CommonJsPlugin.js +13 -8
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +7 -2
- package/lib/dependencies/CssImportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +5 -0
- package/lib/dependencies/CssUrlDependency.js +3 -3
- package/lib/dependencies/DllEntryDependency.js +5 -0
- package/lib/dependencies/DynamicExports.js +10 -6
- package/lib/dependencies/ExportsInfoDependency.js +14 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +2 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExports.js +9 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +32 -17
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +19 -9
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
- package/lib/dependencies/ImportDependency.js +5 -3
- package/lib/dependencies/ImportEagerDependency.js +5 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
- package/lib/dependencies/ImportMetaPlugin.js +31 -15
- package/lib/dependencies/ImportParserPlugin.js +62 -25
- package/lib/dependencies/ImportWeakDependency.js +5 -3
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ProvidedDependency.js +4 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +13 -5
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +5 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +6 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +26 -5
- package/lib/dependencies/RequireResolveHeaderDependency.js +9 -0
- package/lib/dependencies/SystemPlugin.js +17 -5
- package/lib/dependencies/SystemRuntimeModule.js +1 -1
- package/lib/dependencies/URLDependency.js +2 -2
- package/lib/dependencies/URLPlugin.js +9 -4
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +59 -22
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.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/JavascriptParser.js +135 -63
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/logging/runtime.js +1 -1
- package/lib/logging/truncateArgs.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -6
- package/lib/node/RequireChunkLoadingRuntimeModule.js +10 -6
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +2 -1
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +6 -3
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -2
- 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 +8 -5
- package/lib/runtime/AutoPublicPathRuntimeModule.js +4 -2
- package/lib/runtime/BaseUriRuntimeModule.js +3 -3
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
- package/lib/runtime/CompatRuntimeModule.js +7 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/CreateScriptRuntimeModule.js +4 -2
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +4 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +5 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +15 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -10
- package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
- package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -2
- package/lib/runtime/GlobalRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +64 -48
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/NonceRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
- package/lib/runtime/PublicPathRuntimeModule.js +4 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -3
- package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -2
- package/lib/runtime/SystemContextRuntimeModule.js +1 -1
- package/lib/serialization/ObjectMiddleware.js +6 -3
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +14 -5
- 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 +12 -5
- 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 +6 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +14 -7
- 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 +14 -4
- package/lib/webpack.js +11 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +15 -16
- package/module.d.ts +1 -0
- package/package.json +5 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +39 -5
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +519 -222
@@ -22,7 +22,9 @@ const SystemRuntimeModule = require("./SystemRuntimeModule");
|
|
22
22
|
|
23
23
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
24
24
|
/** @typedef {import("../Compiler")} Compiler */
|
25
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
25
26
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
27
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
26
28
|
|
27
29
|
const PLUGIN_NAME = "SystemPlugin";
|
28
30
|
|
@@ -58,6 +60,9 @@ class SystemPlugin {
|
|
58
60
|
return;
|
59
61
|
}
|
60
62
|
|
63
|
+
/**
|
64
|
+
* @param {string} name name
|
65
|
+
*/
|
61
66
|
const setNotSupported = name => {
|
62
67
|
parser.hooks.evaluateTypeof
|
63
68
|
.for(name)
|
@@ -97,17 +102,21 @@ class SystemPlugin {
|
|
97
102
|
setNotSupported("System.register");
|
98
103
|
|
99
104
|
parser.hooks.expression.for("System").tap(PLUGIN_NAME, expr => {
|
100
|
-
const dep = new ConstDependency(
|
101
|
-
RuntimeGlobals.system
|
102
|
-
|
103
|
-
|
105
|
+
const dep = new ConstDependency(
|
106
|
+
RuntimeGlobals.system,
|
107
|
+
/** @type {Range} */ (expr.range),
|
108
|
+
[RuntimeGlobals.system]
|
109
|
+
);
|
110
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
104
111
|
parser.state.module.addPresentationalDependency(dep);
|
105
112
|
return true;
|
106
113
|
});
|
107
114
|
|
108
115
|
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, expr => {
|
109
116
|
parser.state.module.addWarning(
|
110
|
-
new SystemImportDeprecationWarning(
|
117
|
+
new SystemImportDeprecationWarning(
|
118
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
119
|
+
)
|
111
120
|
);
|
112
121
|
|
113
122
|
return parser.hooks.importCall.call({
|
@@ -133,6 +142,9 @@ class SystemPlugin {
|
|
133
142
|
}
|
134
143
|
|
135
144
|
class SystemImportDeprecationWarning extends WebpackError {
|
145
|
+
/**
|
146
|
+
* @param {DependencyLocation} loc location
|
147
|
+
*/
|
136
148
|
constructor(loc) {
|
137
149
|
super(
|
138
150
|
"System.import() is deprecated and will be removed soon. Use import() instead.\n" +
|
@@ -42,7 +42,7 @@ class URLDependency extends ModuleDependency {
|
|
42
42
|
this.range = range;
|
43
43
|
this.outerRange = outerRange;
|
44
44
|
this.relative = relative || false;
|
45
|
-
/** @type {Set<string> | boolean} */
|
45
|
+
/** @type {Set<string> | boolean | undefined} */
|
46
46
|
this.usedByExports = undefined;
|
47
47
|
}
|
48
48
|
|
@@ -68,7 +68,7 @@ class URLDependency extends ModuleDependency {
|
|
68
68
|
|
69
69
|
/**
|
70
70
|
* @param {string} context context directory
|
71
|
-
* @returns {Module} a module
|
71
|
+
* @returns {Module | null} a module
|
72
72
|
*/
|
73
73
|
createIgnoredModule(context) {
|
74
74
|
const RawDataUrlModule = getRawDataUrlModule();
|
@@ -18,9 +18,11 @@ const URLDependency = require("./URLDependency");
|
|
18
18
|
/** @typedef {import("estree").NewExpression} NewExpressionNode */
|
19
19
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
20
20
|
/** @typedef {import("../Compiler")} Compiler */
|
21
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
21
22
|
/** @typedef {import("../NormalModule")} NormalModule */
|
22
23
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
23
24
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
25
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
24
26
|
|
25
27
|
const PLUGIN_NAME = "URLPlugin";
|
26
28
|
|
@@ -94,7 +96,7 @@ class URLPlugin {
|
|
94
96
|
|
95
97
|
return new BasicEvaluatedExpression()
|
96
98
|
.setString(url.toString())
|
97
|
-
.setRange(expr.range);
|
99
|
+
.setRange(/** @type {Range} */ (expr.range));
|
98
100
|
});
|
99
101
|
parser.hooks.new.for("URL").tap(PLUGIN_NAME, _expr => {
|
100
102
|
const expr = /** @type {NewExpressionNode} */ (_expr);
|
@@ -106,11 +108,14 @@ class URLPlugin {
|
|
106
108
|
const [arg1, arg2] = expr.arguments;
|
107
109
|
const dep = new URLDependency(
|
108
110
|
request,
|
109
|
-
[
|
110
|
-
|
111
|
+
[
|
112
|
+
/** @type {Range} */ (arg1.range)[0],
|
113
|
+
/** @type {Range} */ (arg2.range)[1]
|
114
|
+
],
|
115
|
+
/** @type {Range} */ (expr.range),
|
111
116
|
relative
|
112
117
|
);
|
113
|
-
dep.loc = expr.loc;
|
118
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
114
119
|
parser.state.current.addDependency(dep);
|
115
120
|
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e));
|
116
121
|
return true;
|
@@ -55,7 +55,7 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
|
55
55
|
/**
|
56
56
|
* Returns errors
|
57
57
|
* @param {ModuleGraph} moduleGraph module graph
|
58
|
-
* @returns {WebpackError[]} errors
|
58
|
+
* @returns {WebpackError[] | null | undefined} errors
|
59
59
|
*/
|
60
60
|
getErrors(moduleGraph) {
|
61
61
|
const module = moduleGraph.getModule(this);
|
@@ -25,20 +25,32 @@ const {
|
|
25
25
|
} = require("./HarmonyImportDependencyParserPlugin");
|
26
26
|
const WorkerDependency = require("./WorkerDependency");
|
27
27
|
|
28
|
+
/** @typedef {import("estree").CallExpression} CallExpression */
|
28
29
|
/** @typedef {import("estree").Expression} Expression */
|
29
30
|
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
30
31
|
/** @typedef {import("estree").Pattern} Pattern */
|
31
32
|
/** @typedef {import("estree").Property} Property */
|
32
33
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
34
|
+
/** @typedef {import("../../declarations/WebpackOptions").ChunkLoading} ChunkLoading */
|
33
35
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
36
|
+
/** @typedef {import("../../declarations/WebpackOptions").OutputModule} OutputModule */
|
37
|
+
/** @typedef {import("../../declarations/WebpackOptions").WasmLoading} WasmLoading */
|
38
|
+
/** @typedef {import("../../declarations/WebpackOptions").WorkerPublicPath} WorkerPublicPath */
|
34
39
|
/** @typedef {import("../Compiler")} Compiler */
|
40
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
35
41
|
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
42
|
+
/** @typedef {import("../NormalModule")} NormalModule */
|
36
43
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
37
44
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
38
45
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
39
46
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
47
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
40
48
|
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
41
49
|
|
50
|
+
/**
|
51
|
+
* @param {NormalModule} module module
|
52
|
+
* @returns {string} url
|
53
|
+
*/
|
42
54
|
const getUrl = module => {
|
43
55
|
return pathToFileURL(module.resource).toString();
|
44
56
|
};
|
@@ -58,6 +70,12 @@ const workerIndexMap = new WeakMap();
|
|
58
70
|
const PLUGIN_NAME = "WorkerPlugin";
|
59
71
|
|
60
72
|
class WorkerPlugin {
|
73
|
+
/**
|
74
|
+
* @param {ChunkLoading} chunkLoading chunk loading
|
75
|
+
* @param {WasmLoading} wasmLoading wasm loading
|
76
|
+
* @param {OutputModule} module output module
|
77
|
+
* @param {WorkerPublicPath} workerPublicPath worker public path
|
78
|
+
*/
|
61
79
|
constructor(chunkLoading, wasmLoading, module, workerPublicPath) {
|
62
80
|
this._chunkLoading = chunkLoading;
|
63
81
|
this._wasmLoading = wasmLoading;
|
@@ -99,7 +117,7 @@ class WorkerPlugin {
|
|
99
117
|
/**
|
100
118
|
* @param {JavascriptParser} parser the parser
|
101
119
|
* @param {Expression} expr expression
|
102
|
-
* @returns {[BasicEvaluatedExpression, [number, number]]} parsed
|
120
|
+
* @returns {[BasicEvaluatedExpression, [number, number]] | void} parsed
|
103
121
|
*/
|
104
122
|
const parseModuleUrl = (parser, expr) => {
|
105
123
|
if (
|
@@ -116,13 +134,19 @@ class WorkerPlugin {
|
|
116
134
|
const arg2Value = parser.evaluateExpression(arg2);
|
117
135
|
if (
|
118
136
|
!arg2Value.isString() ||
|
119
|
-
!arg2Value.string.startsWith("file://") ||
|
137
|
+
!(/** @type {string} */ (arg2Value.string).startsWith("file://")) ||
|
120
138
|
arg2Value.string !== getUrl(parser.state.module)
|
121
139
|
) {
|
122
140
|
return;
|
123
141
|
}
|
124
142
|
const arg1Value = parser.evaluateExpression(arg1);
|
125
|
-
return [
|
143
|
+
return [
|
144
|
+
arg1Value,
|
145
|
+
[
|
146
|
+
/** @type {Range} */ (arg1.range)[0],
|
147
|
+
/** @type {Range} */ (arg2.range)[1]
|
148
|
+
]
|
149
|
+
];
|
126
150
|
};
|
127
151
|
|
128
152
|
/**
|
@@ -182,6 +206,10 @@ class WorkerPlugin {
|
|
182
206
|
const options = !Array.isArray(parserOptions.worker)
|
183
207
|
? ["..."]
|
184
208
|
: parserOptions.worker;
|
209
|
+
/**
|
210
|
+
* @param {CallExpression} expr expression
|
211
|
+
* @returns {boolean | void} true when handled
|
212
|
+
*/
|
185
213
|
const handleNewWorker = expr => {
|
186
214
|
if (expr.arguments.length === 0 || expr.arguments.length > 2)
|
187
215
|
return;
|
@@ -209,10 +237,12 @@ class WorkerPlugin {
|
|
209
237
|
values: {},
|
210
238
|
spread: false,
|
211
239
|
insertType: arg2 ? "spread" : "argument",
|
212
|
-
insertLocation: arg2
|
240
|
+
insertLocation: arg2
|
241
|
+
? /** @type {Range} */ (arg2.range)
|
242
|
+
: /** @type {Range} */ (arg1.range)[1]
|
213
243
|
};
|
214
244
|
const { options: importOptions, errors: commentErrors } =
|
215
|
-
parser.parseCommentOptions(expr.range);
|
245
|
+
parser.parseCommentOptions(/** @type {Range} */ (expr.range));
|
216
246
|
|
217
247
|
if (commentErrors) {
|
218
248
|
for (const e of commentErrors) {
|
@@ -235,7 +265,7 @@ class WorkerPlugin {
|
|
235
265
|
parser.state.module.addWarning(
|
236
266
|
new UnsupportedFeatureWarning(
|
237
267
|
`\`webpackIgnore\` expected a boolean, but received: ${importOptions.webpackIgnore}.`,
|
238
|
-
expr.loc
|
268
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
239
269
|
)
|
240
270
|
);
|
241
271
|
} else {
|
@@ -252,7 +282,7 @@ class WorkerPlugin {
|
|
252
282
|
parser.state.module.addWarning(
|
253
283
|
new UnsupportedFeatureWarning(
|
254
284
|
`\`webpackEntryOptions\` expected a object, but received: ${importOptions.webpackEntryOptions}.`,
|
255
|
-
expr.loc
|
285
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
256
286
|
)
|
257
287
|
);
|
258
288
|
} else {
|
@@ -267,7 +297,7 @@ class WorkerPlugin {
|
|
267
297
|
parser.state.module.addWarning(
|
268
298
|
new UnsupportedFeatureWarning(
|
269
299
|
`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`,
|
270
|
-
expr.loc
|
300
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
271
301
|
)
|
272
302
|
);
|
273
303
|
} else {
|
@@ -310,18 +340,22 @@ class WorkerPlugin {
|
|
310
340
|
}
|
311
341
|
});
|
312
342
|
block.loc = expr.loc;
|
313
|
-
const dep = new WorkerDependency(
|
314
|
-
|
315
|
-
|
316
|
-
|
343
|
+
const dep = new WorkerDependency(
|
344
|
+
/** @type {string} */ (url.string),
|
345
|
+
range,
|
346
|
+
{
|
347
|
+
publicPath: this._workerPublicPath
|
348
|
+
}
|
349
|
+
);
|
350
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
317
351
|
block.addDependency(dep);
|
318
352
|
parser.state.module.addBlock(block);
|
319
353
|
|
320
354
|
if (compilation.outputOptions.trustedTypes) {
|
321
355
|
const dep = new CreateScriptUrlDependency(
|
322
|
-
expr.arguments[0].range
|
356
|
+
/** @type {Range} */ (expr.arguments[0].range)
|
323
357
|
);
|
324
|
-
dep.loc = expr.loc;
|
358
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
325
359
|
parser.state.module.addDependency(dep);
|
326
360
|
}
|
327
361
|
|
@@ -330,9 +364,9 @@ class WorkerPlugin {
|
|
330
364
|
if (options.type !== false) {
|
331
365
|
const dep = new ConstDependency(
|
332
366
|
this._module ? '"module"' : "undefined",
|
333
|
-
expr.range
|
367
|
+
/** @type {Range} */ (expr.range)
|
334
368
|
);
|
335
|
-
dep.loc = expr.loc;
|
369
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
336
370
|
parser.state.module.addPresentationalDependency(dep);
|
337
371
|
expressions.type = undefined;
|
338
372
|
}
|
@@ -342,20 +376,20 @@ class WorkerPlugin {
|
|
342
376
|
`, type: ${this._module ? '"module"' : "undefined"}`,
|
343
377
|
insertLocation
|
344
378
|
);
|
345
|
-
dep.loc = expr.loc;
|
379
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
346
380
|
parser.state.module.addPresentationalDependency(dep);
|
347
381
|
}
|
348
382
|
} else if (insertType === "spread") {
|
349
383
|
const dep1 = new ConstDependency(
|
350
384
|
"Object.assign({}, ",
|
351
|
-
insertLocation[0]
|
385
|
+
/** @type {Range} */ (insertLocation)[0]
|
352
386
|
);
|
353
387
|
const dep2 = new ConstDependency(
|
354
388
|
`, { type: ${this._module ? '"module"' : "undefined"} })`,
|
355
|
-
insertLocation[1]
|
389
|
+
/** @type {Range} */ (insertLocation)[1]
|
356
390
|
);
|
357
|
-
dep1.loc = expr.loc;
|
358
|
-
dep2.loc = expr.loc;
|
391
|
+
dep1.loc = /** @type {DependencyLocation} */ (expr.loc);
|
392
|
+
dep2.loc = /** @type {DependencyLocation} */ (expr.loc);
|
359
393
|
parser.state.module.addPresentationalDependency(dep1);
|
360
394
|
parser.state.module.addPresentationalDependency(dep2);
|
361
395
|
} else if (insertType === "argument") {
|
@@ -364,7 +398,7 @@ class WorkerPlugin {
|
|
364
398
|
', { type: "module" }',
|
365
399
|
insertLocation
|
366
400
|
);
|
367
|
-
dep.loc = expr.loc;
|
401
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
368
402
|
parser.state.module.addPresentationalDependency(dep);
|
369
403
|
}
|
370
404
|
}
|
@@ -382,6 +416,9 @@ class WorkerPlugin {
|
|
382
416
|
|
383
417
|
return true;
|
384
418
|
};
|
419
|
+
/**
|
420
|
+
* @param {string} item item
|
421
|
+
*/
|
385
422
|
const processItem = item => {
|
386
423
|
if (
|
387
424
|
item.startsWith("*") &&
|
@@ -14,7 +14,7 @@ class HotModuleReplacementRuntimeModule extends RuntimeModule {
|
|
14
14
|
super("hot module replacement", RuntimeModule.STAGE_BASIC);
|
15
15
|
}
|
16
16
|
/**
|
17
|
-
* @returns {string} runtime code
|
17
|
+
* @returns {string | null} runtime code
|
18
18
|
*/
|
19
19
|
generate() {
|
20
20
|
return Template.getFunctionContent(
|
@@ -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
|
)
|