webpack 5.85.0 → 5.88.1
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/AsyncDependenciesBlock.js +3 -3
- package/lib/BannerPlugin.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +35 -17
- package/lib/ChunkGraph.js +4 -4
- package/lib/ChunkGroup.js +20 -9
- package/lib/CompatibilityPlugin.js +50 -30
- package/lib/Compilation.js +2 -1
- package/lib/Compiler.js +10 -9
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +73 -32
- package/lib/ContextModule.js +8 -3
- package/lib/ContextModuleFactory.js +1 -0
- package/lib/ContextReplacementPlugin.js +13 -0
- package/lib/DelegatedModule.js +15 -3
- package/lib/DelegatedModuleFactoryPlugin.js +6 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/Dependency.js +11 -5
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllEntryPlugin.js +11 -1
- package/lib/DllModule.js +6 -0
- package/lib/DllReferencePlugin.js +13 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/ErrorHelpers.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +6 -1
- package/lib/ExportsInfo.js +22 -4
- package/lib/ExportsInfoApiPlugin.js +14 -5
- package/lib/ExternalModule.js +20 -8
- package/lib/FileSystemInfo.js +52 -24
- package/lib/FlagAllModulesAsUsedPlugin.js +6 -1
- package/lib/FlagDependencyUsagePlugin.js +3 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/Generator.js +7 -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 +14 -3
- 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/ProgressPlugin.js +71 -15
- 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/Watching.js +62 -25
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackIsIncludedPlugin.js +6 -4
- package/lib/WebpackOptionsApply.js +4 -2
- 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/buildChunkGraph.js +37 -21
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/PackFileCacheStrategy.js +53 -22
- package/lib/config/browserslistTargetHandler.js +7 -7
- package/lib/config/defaults.js +43 -26
- package/lib/container/RemoteRuntimeModule.js +1 -1
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +43 -19
- package/lib/css/CssModulesPlugin.js +42 -14
- 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 +40 -27
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +31 -21
- 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/JsonExportsDependency.js +1 -1
- 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 +28 -19
- package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
- package/lib/javascript/JavascriptModulesPlugin.js +25 -5
- package/lib/javascript/JavascriptParser.js +157 -85
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/json/JsonData.js +2 -2
- package/lib/json/JsonParser.js +25 -12
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +13 -1
- package/lib/library/EnableLibraryPlugin.js +4 -0
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +20 -2
- package/lib/logging/runtime.js +1 -1
- package/lib/logging/truncateArgs.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -6
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +10 -6
- 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 +5 -5
- package/lib/optimize/InnerGraphPlugin.js +2 -1
- 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 +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/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 +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/StackedCacheMap.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.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 +84 -21
- package/lib/util/semver.js +1 -0
- 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 +52 -6
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +606 -292
@@ -29,8 +29,14 @@ const RequireResolveContextDependency = require("./RequireResolveContextDependen
|
|
29
29
|
const RequireResolveDependency = require("./RequireResolveDependency");
|
30
30
|
const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");
|
31
31
|
|
32
|
-
/** @typedef {import("estree").CallExpression}
|
32
|
+
/** @typedef {import("estree").CallExpression} CallExpression */
|
33
|
+
/** @typedef {import("estree").Expression} Expression */
|
34
|
+
/** @typedef {import("estree").NewExpression} NewExpression */
|
33
35
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
36
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
37
|
+
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
38
|
+
/** @typedef {import("../javascript/JavascriptParser").ImportSource} ImportSource */
|
39
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
34
40
|
|
35
41
|
const createRequireSpecifierTag = Symbol("createRequire");
|
36
42
|
const createdRequireIdentifierTag = Symbol("createRequire()");
|
@@ -43,6 +49,10 @@ class CommonJsImportsParserPlugin {
|
|
43
49
|
this.options = options;
|
44
50
|
}
|
45
51
|
|
52
|
+
/**
|
53
|
+
* @param {JavascriptParser} parser the parser
|
54
|
+
* @returns {void}
|
55
|
+
*/
|
46
56
|
apply(parser) {
|
47
57
|
const options = this.options;
|
48
58
|
|
@@ -54,6 +64,10 @@ class CommonJsImportsParserPlugin {
|
|
54
64
|
};
|
55
65
|
|
56
66
|
//#region metadata
|
67
|
+
/**
|
68
|
+
* @param {TODO} expression expression
|
69
|
+
* @param {() => string[]} getMembers get members
|
70
|
+
*/
|
57
71
|
const tapRequireExpression = (expression, getMembers) => {
|
58
72
|
parser.hooks.typeof
|
59
73
|
.for(expression)
|
@@ -71,6 +85,9 @@ class CommonJsImportsParserPlugin {
|
|
71
85
|
evaluateToIdentifier(expression, "require", getMembers, true)
|
72
86
|
);
|
73
87
|
};
|
88
|
+
/**
|
89
|
+
* @param {string | symbol} tag tag
|
90
|
+
*/
|
74
91
|
const tapRequireExpressionTag = tag => {
|
75
92
|
parser.hooks.typeof
|
76
93
|
.for(tag)
|
@@ -93,7 +110,7 @@ class CommonJsImportsParserPlugin {
|
|
93
110
|
.tap("CommonJsImportsParserPlugin", expr => {
|
94
111
|
// to not leak to global "require", we need to define a local require here.
|
95
112
|
const dep = new ConstDependency("var require;", 0);
|
96
|
-
dep.loc = expr.loc;
|
113
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
97
114
|
parser.state.module.addPresentationalDependency(dep);
|
98
115
|
return true;
|
99
116
|
});
|
@@ -138,10 +155,17 @@ class CommonJsImportsParserPlugin {
|
|
138
155
|
//#endregion
|
139
156
|
|
140
157
|
//#region Renaming
|
158
|
+
/**
|
159
|
+
* @param {Expression} expr expression
|
160
|
+
* @returns {boolean} true when set undefined
|
161
|
+
*/
|
141
162
|
const defineUndefined = expr => {
|
142
163
|
// To avoid "not defined" error, replace the value with undefined
|
143
|
-
const dep = new ConstDependency(
|
144
|
-
|
164
|
+
const dep = new ConstDependency(
|
165
|
+
"undefined",
|
166
|
+
/** @type {Range} */ (expr.range)
|
167
|
+
);
|
168
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
145
169
|
parser.state.module.addPresentationalDependency(dep);
|
146
170
|
return false;
|
147
171
|
};
|
@@ -170,6 +194,10 @@ class CommonJsImportsParserPlugin {
|
|
170
194
|
//#endregion
|
171
195
|
|
172
196
|
//#region Require as expression
|
197
|
+
/**
|
198
|
+
* @param {Expression} expr expression
|
199
|
+
* @returns {boolean} true when handled
|
200
|
+
*/
|
173
201
|
const requireAsExpressionHandler = expr => {
|
174
202
|
const dep = new CommonJsRequireContextDependency(
|
175
203
|
{
|
@@ -178,7 +206,7 @@ class CommonJsImportsParserPlugin {
|
|
178
206
|
regExp: options.unknownContextRegExp,
|
179
207
|
mode: "sync"
|
180
208
|
},
|
181
|
-
expr.range,
|
209
|
+
/** @type {Range} */ (expr.range),
|
182
210
|
undefined,
|
183
211
|
parser.scope.inShorthand,
|
184
212
|
getContext()
|
@@ -186,7 +214,7 @@ class CommonJsImportsParserPlugin {
|
|
186
214
|
dep.critical =
|
187
215
|
options.unknownContextCritical &&
|
188
216
|
"require function is used in a way in which dependencies cannot be statically extracted";
|
189
|
-
dep.loc = expr.loc;
|
217
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
190
218
|
dep.optional = !!parser.scope.inTry;
|
191
219
|
parser.state.current.addDependency(dep);
|
192
220
|
return true;
|
@@ -197,23 +225,33 @@ class CommonJsImportsParserPlugin {
|
|
197
225
|
//#endregion
|
198
226
|
|
199
227
|
//#region Require
|
228
|
+
/**
|
229
|
+
* @param {CallExpression | NewExpression} expr expression
|
230
|
+
* @param {BasicEvaluatedExpression} param param
|
231
|
+
* @returns {boolean | void} true when handled
|
232
|
+
*/
|
200
233
|
const processRequireItem = (expr, param) => {
|
201
234
|
if (param.isString()) {
|
202
235
|
const dep = new CommonJsRequireDependency(
|
203
|
-
param.string,
|
204
|
-
param.range,
|
236
|
+
/** @type {string} */ (param.string),
|
237
|
+
/** @type {Range} */ (param.range),
|
205
238
|
getContext()
|
206
239
|
);
|
207
|
-
dep.loc = expr.loc;
|
240
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
208
241
|
dep.optional = !!parser.scope.inTry;
|
209
242
|
parser.state.current.addDependency(dep);
|
210
243
|
return true;
|
211
244
|
}
|
212
245
|
};
|
246
|
+
/**
|
247
|
+
* @param {CallExpression | NewExpression} expr expression
|
248
|
+
* @param {BasicEvaluatedExpression} param param
|
249
|
+
* @returns {boolean | void} true when handled
|
250
|
+
*/
|
213
251
|
const processRequireContext = (expr, param) => {
|
214
252
|
const dep = ContextDependencyHelpers.create(
|
215
253
|
CommonJsRequireContextDependency,
|
216
|
-
expr.range,
|
254
|
+
/** @type {Range} */ (expr.range),
|
217
255
|
param,
|
218
256
|
expr,
|
219
257
|
options,
|
@@ -225,15 +263,19 @@ class CommonJsImportsParserPlugin {
|
|
225
263
|
getContext()
|
226
264
|
);
|
227
265
|
if (!dep) return;
|
228
|
-
dep.loc = expr.loc;
|
266
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
229
267
|
dep.optional = !!parser.scope.inTry;
|
230
268
|
parser.state.current.addDependency(dep);
|
231
269
|
return true;
|
232
270
|
};
|
271
|
+
/**
|
272
|
+
* @param {boolean} callNew true, when require is called with new
|
273
|
+
* @returns {(expr: CallExpression | NewExpression) => (boolean | void)} handler
|
274
|
+
*/
|
233
275
|
const createRequireHandler = callNew => expr => {
|
234
276
|
if (options.commonjsMagicComments) {
|
235
277
|
const { options: requireOptions, errors: commentErrors } =
|
236
|
-
parser.parseCommentOptions(expr.range);
|
278
|
+
parser.parseCommentOptions(/** @type {Range} */ (expr.range));
|
237
279
|
|
238
280
|
if (commentErrors) {
|
239
281
|
for (const e of commentErrors) {
|
@@ -252,7 +294,7 @@ class CommonJsImportsParserPlugin {
|
|
252
294
|
parser.state.module.addWarning(
|
253
295
|
new UnsupportedFeatureWarning(
|
254
296
|
`\`webpackIgnore\` expected a boolean, but received: ${requireOptions.webpackIgnore}.`,
|
255
|
-
expr.loc
|
297
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
256
298
|
)
|
257
299
|
);
|
258
300
|
} else {
|
@@ -270,26 +312,37 @@ class CommonJsImportsParserPlugin {
|
|
270
312
|
const param = parser.evaluateExpression(expr.arguments[0]);
|
271
313
|
if (param.isConditional()) {
|
272
314
|
let isExpression = false;
|
273
|
-
for (const p of
|
315
|
+
for (const p of /** @type {BasicEvaluatedExpression[]} */ (
|
316
|
+
param.options
|
317
|
+
)) {
|
274
318
|
const result = processRequireItem(expr, p);
|
275
319
|
if (result === undefined) {
|
276
320
|
isExpression = true;
|
277
321
|
}
|
278
322
|
}
|
279
323
|
if (!isExpression) {
|
280
|
-
const dep = new RequireHeaderDependency(
|
281
|
-
|
324
|
+
const dep = new RequireHeaderDependency(
|
325
|
+
/** @type {Range} */ (expr.callee.range)
|
326
|
+
);
|
327
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
282
328
|
parser.state.module.addPresentationalDependency(dep);
|
283
329
|
return true;
|
284
330
|
}
|
285
331
|
}
|
286
332
|
if (
|
287
333
|
param.isString() &&
|
288
|
-
(localModule = getLocalModule(
|
334
|
+
(localModule = getLocalModule(
|
335
|
+
parser.state,
|
336
|
+
/** @type {string} */ (param.string)
|
337
|
+
))
|
289
338
|
) {
|
290
339
|
localModule.flagUsed();
|
291
|
-
const dep = new LocalModuleDependency(
|
292
|
-
|
340
|
+
const dep = new LocalModuleDependency(
|
341
|
+
localModule,
|
342
|
+
/** @type {Range} */ (expr.range),
|
343
|
+
callNew
|
344
|
+
);
|
345
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
293
346
|
parser.state.module.addPresentationalDependency(dep);
|
294
347
|
return true;
|
295
348
|
} else {
|
@@ -297,8 +350,10 @@ class CommonJsImportsParserPlugin {
|
|
297
350
|
if (result === undefined) {
|
298
351
|
processRequireContext(expr, param);
|
299
352
|
} else {
|
300
|
-
const dep = new RequireHeaderDependency(
|
301
|
-
|
353
|
+
const dep = new RequireHeaderDependency(
|
354
|
+
/** @type {Range} */ (expr.callee.range)
|
355
|
+
);
|
356
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
302
357
|
parser.state.module.addPresentationalDependency(dep);
|
303
358
|
}
|
304
359
|
return true;
|
@@ -319,35 +374,59 @@ class CommonJsImportsParserPlugin {
|
|
319
374
|
//#endregion
|
320
375
|
|
321
376
|
//#region Require with property access
|
377
|
+
/**
|
378
|
+
* @param {Expression} expr expression
|
379
|
+
* @param {string[]} calleeMembers callee members
|
380
|
+
* @param {CallExpression} callExpr call expression
|
381
|
+
* @param {string[]} members members
|
382
|
+
* @returns {boolean | void} true when handled
|
383
|
+
*/
|
322
384
|
const chainHandler = (expr, calleeMembers, callExpr, members) => {
|
323
385
|
if (callExpr.arguments.length !== 1) return;
|
324
386
|
const param = parser.evaluateExpression(callExpr.arguments[0]);
|
325
|
-
if (
|
387
|
+
if (
|
388
|
+
param.isString() &&
|
389
|
+
!getLocalModule(parser.state, /** @type {string} */ (param.string))
|
390
|
+
) {
|
326
391
|
const dep = new CommonJsFullRequireDependency(
|
327
|
-
param.string,
|
328
|
-
expr.range,
|
392
|
+
/** @type {string} */ (param.string),
|
393
|
+
/** @type {Range} */ (expr.range),
|
329
394
|
members
|
330
395
|
);
|
331
|
-
dep.asiSafe = !parser.isAsiPosition(
|
396
|
+
dep.asiSafe = !parser.isAsiPosition(
|
397
|
+
/** @type {Range} */ (expr.range)[0]
|
398
|
+
);
|
332
399
|
dep.optional = !!parser.scope.inTry;
|
333
|
-
dep.loc = expr.loc;
|
400
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
334
401
|
parser.state.current.addDependency(dep);
|
335
402
|
return true;
|
336
403
|
}
|
337
404
|
};
|
405
|
+
/**
|
406
|
+
* @param {CallExpression} expr expression
|
407
|
+
* @param {string[]} calleeMembers callee members
|
408
|
+
* @param {CallExpression} callExpr call expression
|
409
|
+
* @param {string[]} members members
|
410
|
+
* @returns {boolean | void} true when handled
|
411
|
+
*/
|
338
412
|
const callChainHandler = (expr, calleeMembers, callExpr, members) => {
|
339
413
|
if (callExpr.arguments.length !== 1) return;
|
340
414
|
const param = parser.evaluateExpression(callExpr.arguments[0]);
|
341
|
-
if (
|
415
|
+
if (
|
416
|
+
param.isString() &&
|
417
|
+
!getLocalModule(parser.state, /** @type {string} */ (param.string))
|
418
|
+
) {
|
342
419
|
const dep = new CommonJsFullRequireDependency(
|
343
|
-
param.string,
|
344
|
-
expr.callee.range,
|
420
|
+
/** @type {string} */ (param.string),
|
421
|
+
/** @type {Range} */ (expr.callee.range),
|
345
422
|
members
|
346
423
|
);
|
347
424
|
dep.call = true;
|
348
|
-
dep.asiSafe = !parser.isAsiPosition(
|
425
|
+
dep.asiSafe = !parser.isAsiPosition(
|
426
|
+
/** @type {Range} */ (expr.range)[0]
|
427
|
+
);
|
349
428
|
dep.optional = !!parser.scope.inTry;
|
350
|
-
dep.loc = expr.callee.loc;
|
429
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.callee.loc);
|
351
430
|
parser.state.current.addDependency(dep);
|
352
431
|
parser.walkExpressions(expr.arguments);
|
353
432
|
return true;
|
@@ -368,18 +447,27 @@ class CommonJsImportsParserPlugin {
|
|
368
447
|
//#endregion
|
369
448
|
|
370
449
|
//#region Require.resolve
|
450
|
+
/**
|
451
|
+
* @param {CallExpression} expr call expression
|
452
|
+
* @param {boolean} weak weak
|
453
|
+
* @returns {boolean | void} true when handled
|
454
|
+
*/
|
371
455
|
const processResolve = (expr, weak) => {
|
372
456
|
if (expr.arguments.length !== 1) return;
|
373
457
|
const param = parser.evaluateExpression(expr.arguments[0]);
|
374
458
|
if (param.isConditional()) {
|
375
|
-
for (const option of
|
459
|
+
for (const option of /** @type {BasicEvaluatedExpression[]} */ (
|
460
|
+
param.options
|
461
|
+
)) {
|
376
462
|
const result = processResolveItem(expr, option, weak);
|
377
463
|
if (result === undefined) {
|
378
464
|
processResolveContext(expr, option, weak);
|
379
465
|
}
|
380
466
|
}
|
381
|
-
const dep = new RequireResolveHeaderDependency(
|
382
|
-
|
467
|
+
const dep = new RequireResolveHeaderDependency(
|
468
|
+
/** @type {Range} */ (expr.callee.range)
|
469
|
+
);
|
470
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
383
471
|
parser.state.module.addPresentationalDependency(dep);
|
384
472
|
return true;
|
385
473
|
} else {
|
@@ -387,30 +475,44 @@ class CommonJsImportsParserPlugin {
|
|
387
475
|
if (result === undefined) {
|
388
476
|
processResolveContext(expr, param, weak);
|
389
477
|
}
|
390
|
-
const dep = new RequireResolveHeaderDependency(
|
391
|
-
|
478
|
+
const dep = new RequireResolveHeaderDependency(
|
479
|
+
/** @type {Range} */ (expr.callee.range)
|
480
|
+
);
|
481
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
392
482
|
parser.state.module.addPresentationalDependency(dep);
|
393
483
|
return true;
|
394
484
|
}
|
395
485
|
};
|
486
|
+
/**
|
487
|
+
* @param {CallExpression} expr call expression
|
488
|
+
* @param {BasicEvaluatedExpression} param param
|
489
|
+
* @param {boolean} weak weak
|
490
|
+
* @returns {boolean | void} true when handled
|
491
|
+
*/
|
396
492
|
const processResolveItem = (expr, param, weak) => {
|
397
493
|
if (param.isString()) {
|
398
494
|
const dep = new RequireResolveDependency(
|
399
|
-
param.string,
|
400
|
-
param.range,
|
495
|
+
/** @type {string} */ (param.string),
|
496
|
+
/** @type {Range} */ (param.range),
|
401
497
|
getContext()
|
402
498
|
);
|
403
|
-
dep.loc = expr.loc;
|
499
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
404
500
|
dep.optional = !!parser.scope.inTry;
|
405
501
|
dep.weak = weak;
|
406
502
|
parser.state.current.addDependency(dep);
|
407
503
|
return true;
|
408
504
|
}
|
409
505
|
};
|
506
|
+
/**
|
507
|
+
* @param {CallExpression} expr call expression
|
508
|
+
* @param {BasicEvaluatedExpression} param param
|
509
|
+
* @param {boolean} weak weak
|
510
|
+
* @returns {boolean | void} true when handled
|
511
|
+
*/
|
410
512
|
const processResolveContext = (expr, param, weak) => {
|
411
513
|
const dep = ContextDependencyHelpers.create(
|
412
514
|
RequireResolveContextDependency,
|
413
|
-
param.range,
|
515
|
+
/** @type {Range} */ (param.range),
|
414
516
|
param,
|
415
517
|
expr,
|
416
518
|
options,
|
@@ -422,7 +524,7 @@ class CommonJsImportsParserPlugin {
|
|
422
524
|
getContext()
|
423
525
|
);
|
424
526
|
if (!dep) return;
|
425
|
-
dep.loc = expr.loc;
|
527
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
426
528
|
dep.optional = !!parser.scope.inTry;
|
427
529
|
parser.state.current.addDependency(dep);
|
428
530
|
return true;
|
@@ -444,7 +546,9 @@ class CommonJsImportsParserPlugin {
|
|
444
546
|
|
445
547
|
if (!options.createRequire) return;
|
446
548
|
|
549
|
+
/** @type {ImportSource[]} */
|
447
550
|
let moduleName = [];
|
551
|
+
/** @type {string | undefined} */
|
448
552
|
let specifierName;
|
449
553
|
|
450
554
|
if (options.createRequire === true) {
|
@@ -481,9 +585,13 @@ class CommonJsImportsParserPlugin {
|
|
481
585
|
next: undefined
|
482
586
|
});
|
483
587
|
return new BasicEvaluatedExpression()
|
484
|
-
.setIdentifier(
|
588
|
+
.setIdentifier(
|
589
|
+
/** @type {TODO} */ (ident),
|
590
|
+
/** @type {TODO} */ (ident),
|
591
|
+
() => []
|
592
|
+
)
|
485
593
|
.setSideEffects(false)
|
486
|
-
.setRange(expr.range);
|
594
|
+
.setRange(/** @type {Range} */ (expr.range));
|
487
595
|
});
|
488
596
|
parser.hooks.unhandledExpressionMemberChain
|
489
597
|
.for(createdRequireIdentifierTag)
|
@@ -509,8 +617,8 @@ class CommonJsImportsParserPlugin {
|
|
509
617
|
.for(createdRequireIdentifierTag)
|
510
618
|
.tap("CommonJsImportsParserPlugin", createRequireHandler(false));
|
511
619
|
/**
|
512
|
-
* @param {
|
513
|
-
* @returns {string} context
|
620
|
+
* @param {CallExpression} expr call expression
|
621
|
+
* @returns {string | void} context
|
514
622
|
*/
|
515
623
|
const parseCreateRequireArguments = expr => {
|
516
624
|
const args = expr.arguments;
|
@@ -518,7 +626,7 @@ class CommonJsImportsParserPlugin {
|
|
518
626
|
const err = new WebpackError(
|
519
627
|
"module.createRequire supports only one argument."
|
520
628
|
);
|
521
|
-
err.loc = expr.loc;
|
629
|
+
err.loc = /** @type {DependencyLocation} */ (expr.loc);
|
522
630
|
parser.state.module.addWarning(err);
|
523
631
|
return;
|
524
632
|
}
|
@@ -528,13 +636,13 @@ class CommonJsImportsParserPlugin {
|
|
528
636
|
const err = new WebpackError(
|
529
637
|
"module.createRequire failed parsing argument."
|
530
638
|
);
|
531
|
-
err.loc = arg.loc;
|
639
|
+
err.loc = /** @type {DependencyLocation} */ (arg.loc);
|
532
640
|
parser.state.module.addWarning(err);
|
533
641
|
return;
|
534
642
|
}
|
535
|
-
const ctx = evaluated.string.startsWith("file://")
|
536
|
-
? fileURLToPath(evaluated.string)
|
537
|
-
: evaluated.string;
|
643
|
+
const ctx = /** @type {string} */ (evaluated.string).startsWith("file://")
|
644
|
+
? fileURLToPath(/** @type {string} */ (evaluated.string))
|
645
|
+
: /** @type {string} */ (evaluated.string);
|
538
646
|
// argument always should be a filename
|
539
647
|
return ctx.slice(0, ctx.lastIndexOf(ctx.startsWith("/") ? "/" : "\\"));
|
540
648
|
};
|
@@ -556,12 +664,14 @@ class CommonJsImportsParserPlugin {
|
|
556
664
|
// clear for 'import { createRequire as x } from "module"'
|
557
665
|
// if any other specifier was used import module
|
558
666
|
const clearDep = new ConstDependency(
|
559
|
-
parser.isAsiPosition(statement.range[0])
|
560
|
-
|
667
|
+
parser.isAsiPosition(/** @type {Range} */ (statement.range)[0])
|
668
|
+
? ";"
|
669
|
+
: "",
|
670
|
+
/** @type {Range} */ (statement.range)
|
561
671
|
);
|
562
|
-
clearDep.loc = statement.loc;
|
672
|
+
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
|
563
673
|
parser.state.module.addPresentationalDependency(clearDep);
|
564
|
-
parser.unsetAsiPosition(statement.range[1]);
|
674
|
+
parser.unsetAsiPosition(/** @type {Range} */ (statement.range)[1]);
|
565
675
|
return true;
|
566
676
|
}
|
567
677
|
);
|
@@ -586,9 +696,9 @@ class CommonJsImportsParserPlugin {
|
|
586
696
|
declarator.init.callee.type !== "Identifier"
|
587
697
|
)
|
588
698
|
return;
|
589
|
-
const variableInfo =
|
590
|
-
|
591
|
-
|
699
|
+
const variableInfo =
|
700
|
+
/** @type {TODO} */
|
701
|
+
(parser.getVariableInfo(declarator.init.callee.name));
|
592
702
|
if (
|
593
703
|
variableInfo &&
|
594
704
|
variableInfo.tagInfo &&
|
@@ -658,9 +768,9 @@ class CommonJsImportsParserPlugin {
|
|
658
768
|
.tap("CommonJsImportsParserPlugin", expr => {
|
659
769
|
const clearDep = new ConstDependency(
|
660
770
|
"/* createRequire() */ undefined",
|
661
|
-
expr.range
|
771
|
+
/** @type {Range} */ (expr.range)
|
662
772
|
);
|
663
|
-
clearDep.loc = expr.loc;
|
773
|
+
clearDep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
664
774
|
parser.state.module.addPresentationalDependency(clearDep);
|
665
775
|
return true;
|
666
776
|
});
|
@@ -35,7 +35,10 @@ const {
|
|
35
35
|
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
36
36
|
|
37
37
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
38
|
+
/** @typedef {import("../Compilation")} Compilation */
|
38
39
|
/** @typedef {import("../Compiler")} Compiler */
|
40
|
+
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
41
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
39
42
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
40
43
|
|
41
44
|
const PLUGIN_NAME = "CommonJsPlugin";
|
@@ -199,12 +202,13 @@ class CommonJsPlugin {
|
|
199
202
|
parser.hooks.expression
|
200
203
|
.for(RuntimeGlobals.moduleLoaded)
|
201
204
|
.tap(PLUGIN_NAME, expr => {
|
202
|
-
|
205
|
+
/** @type {BuildInfo} */
|
206
|
+
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
203
207
|
RuntimeGlobals.moduleLoaded;
|
204
208
|
const dep = new RuntimeRequirementsDependency([
|
205
209
|
RuntimeGlobals.moduleLoaded
|
206
210
|
]);
|
207
|
-
dep.loc = expr.loc;
|
211
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
208
212
|
parser.state.module.addPresentationalDependency(dep);
|
209
213
|
return true;
|
210
214
|
});
|
@@ -212,12 +216,13 @@ class CommonJsPlugin {
|
|
212
216
|
parser.hooks.expression
|
213
217
|
.for(RuntimeGlobals.moduleId)
|
214
218
|
.tap(PLUGIN_NAME, expr => {
|
215
|
-
|
219
|
+
/** @type {BuildInfo} */
|
220
|
+
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
216
221
|
RuntimeGlobals.moduleId;
|
217
222
|
const dep = new RuntimeRequirementsDependency([
|
218
223
|
RuntimeGlobals.moduleId
|
219
224
|
]);
|
220
|
-
dep.loc = expr.loc;
|
225
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
221
226
|
parser.state.module.addPresentationalDependency(dep);
|
222
227
|
return true;
|
223
228
|
});
|
@@ -250,10 +255,10 @@ class HarmonyModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
250
255
|
}
|
251
256
|
|
252
257
|
/**
|
253
|
-
* @returns {string} runtime code
|
258
|
+
* @returns {string | null} runtime code
|
254
259
|
*/
|
255
260
|
generate() {
|
256
|
-
const { runtimeTemplate } = this.compilation;
|
261
|
+
const { runtimeTemplate } = /** @type {Compilation} */ (this.compilation);
|
257
262
|
return Template.asString([
|
258
263
|
`${
|
259
264
|
RuntimeGlobals.harmonyModuleDecorator
|
@@ -280,10 +285,10 @@ class NodeModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
280
285
|
}
|
281
286
|
|
282
287
|
/**
|
283
|
-
* @returns {string} runtime code
|
288
|
+
* @returns {string | null} runtime code
|
284
289
|
*/
|
285
290
|
generate() {
|
286
|
-
const { runtimeTemplate } = this.compilation;
|
291
|
+
const { runtimeTemplate } = /** @type {Compilation} */ (this.compilation);
|
287
292
|
return Template.asString([
|
288
293
|
`${RuntimeGlobals.nodeModuleDecorator} = ${runtimeTemplate.basicFunction(
|
289
294
|
"module",
|
@@ -17,8 +17,8 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
|
17
17
|
/**
|
18
18
|
* @param {TODO} options options for the context module
|
19
19
|
* @param {Range} range location in source code
|
20
|
-
* @param {Range} valueRange location of the require call
|
21
|
-
* @param {boolean} inShorthand true
|
20
|
+
* @param {Range | undefined} valueRange location of the require call
|
21
|
+
* @param {boolean | string } inShorthand true or name
|
22
22
|
* @param {string} context context
|
23
23
|
*/
|
24
24
|
constructor(options, range, valueRange, inShorthand, context) {
|
@@ -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();
|
@@ -23,6 +23,10 @@ const getCriticalDependencyWarning = memoize(() =>
|
|
23
23
|
|
24
24
|
/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */
|
25
25
|
|
26
|
+
/**
|
27
|
+
* @param {RegExp | null | undefined} r regexp
|
28
|
+
* @returns {string} stringified regexp
|
29
|
+
*/
|
26
30
|
const regExpToString = r => (r ? r + "" : "");
|
27
31
|
|
28
32
|
class ContextDependency extends Dependency {
|
@@ -35,7 +39,7 @@ class ContextDependency extends Dependency {
|
|
35
39
|
|
36
40
|
this.options = options;
|
37
41
|
this.userRequest = this.options && this.options.request;
|
38
|
-
/** @type {false | string} */
|
42
|
+
/** @type {false | undefined | string} */
|
39
43
|
this.critical = false;
|
40
44
|
this.hadGlobalOrStickyRegExp = false;
|
41
45
|
|
@@ -50,6 +54,7 @@ class ContextDependency extends Dependency {
|
|
50
54
|
this.request = undefined;
|
51
55
|
this.range = undefined;
|
52
56
|
this.valueRange = undefined;
|
57
|
+
/** @type {boolean | string | undefined} */
|
53
58
|
this.inShorthand = undefined;
|
54
59
|
// TODO refactor this
|
55
60
|
this.replaces = undefined;
|
@@ -93,7 +98,7 @@ class ContextDependency extends Dependency {
|
|
93
98
|
/**
|
94
99
|
* Returns warnings
|
95
100
|
* @param {ModuleGraph} moduleGraph module graph
|
96
|
-
* @returns {WebpackError[]} warnings
|
101
|
+
* @returns {WebpackError[] | null | undefined} warnings
|
97
102
|
*/
|
98
103
|
getWarnings(moduleGraph) {
|
99
104
|
let warnings = super.getWarnings(moduleGraph);
|
@@ -75,6 +75,11 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
75
75
|
}
|
76
76
|
}
|
77
77
|
|
78
|
+
/**
|
79
|
+
* @param {string} str string
|
80
|
+
* @param {string | boolean} omitUnderscore true if you need to omit underscore
|
81
|
+
* @returns {string} escaped css identifier
|
82
|
+
*/
|
78
83
|
const escapeCssIdentifier = (str, omitUnderscore) => {
|
79
84
|
const escaped = `${str}`.replace(
|
80
85
|
// cspell:word uffff
|
@@ -48,7 +48,7 @@ class CssUrlDependency extends ModuleDependency {
|
|
48
48
|
|
49
49
|
/**
|
50
50
|
* @param {string} context context directory
|
51
|
-
* @returns {Module} a module
|
51
|
+
* @returns {Module | null} a module
|
52
52
|
*/
|
53
53
|
createIgnoredModule(context) {
|
54
54
|
const RawDataUrlModule = getRawDataUrlModule();
|
@@ -133,7 +133,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
133
133
|
newValue = cssEscapeString(
|
134
134
|
runtimeTemplate.assetUrl({
|
135
135
|
publicPath: "",
|
136
|
-
module: moduleGraph.getModule(dep),
|
136
|
+
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
137
137
|
codeGenerationResults
|
138
138
|
})
|
139
139
|
);
|
@@ -142,7 +142,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
142
142
|
newValue = `url(${cssEscapeString(
|
143
143
|
runtimeTemplate.assetUrl({
|
144
144
|
publicPath: "",
|
145
|
-
module: moduleGraph.getModule(dep),
|
145
|
+
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
146
146
|
codeGenerationResults
|
147
147
|
})
|
148
148
|
)})`;
|
@@ -10,8 +10,13 @@ const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
|
11
11
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
12
12
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
13
|
+
/** @typedef {import("./EntryDependency")} EntryDependency */
|
13
14
|
|
14
15
|
class DllEntryDependency extends Dependency {
|
16
|
+
/**
|
17
|
+
* @param {EntryDependency[]} dependencies dependencies
|
18
|
+
* @param {string} name name
|
19
|
+
*/
|
15
20
|
constructor(dependencies, name) {
|
16
21
|
super();
|
17
22
|
|