webpack 5.112.0 → 5.112.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.
- package/bin/webpack.js +13 -7
- package/lib/Compilation.js +152 -60
- package/lib/Compiler.js +12 -25
- package/lib/asset/AssetBytesGenerator.js +14 -6
- package/lib/asset/AssetBytesParser.js +10 -8
- package/lib/asset/AssetGenerator.js +36 -48
- package/lib/asset/AssetModule.js +11 -0
- package/lib/asset/AssetModulesPlugin.js +5 -4
- package/lib/asset/AssetParser.js +8 -8
- package/lib/asset/AssetSourceGenerator.js +16 -8
- package/lib/asset/AssetSourceParser.js +10 -8
- package/lib/asset/WebManifestGenerator.js +11 -6
- package/lib/asset/WebManifestParser.js +3 -3
- package/lib/async-modules/AsyncModuleHelpers.js +8 -2
- package/lib/async-modules/InferAsyncModulesPlugin.js +7 -2
- package/lib/cache/CacheFacade.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +6 -10
- package/lib/cache/ResolverCachePlugin.js +58 -8
- package/lib/config/WebpackOptionsApply.js +8 -28
- package/lib/config/cli.js +9 -6
- package/lib/config/defaults.js +24 -13
- package/lib/config/getClaimedAssetTypes.js +2 -2
- package/lib/config/target.js +1 -1
- package/lib/context/ContextModule.js +1 -1
- package/lib/context/ContextModuleFactory.js +1 -1
- package/lib/context/ContextReplacementPlugin.js +3 -9
- package/lib/css/CssGenerator.js +40 -37
- package/lib/css/CssModule.js +10 -0
- package/lib/css/CssModulesPlugin.js +2 -2
- package/lib/css/CssParser.js +33 -32
- package/lib/css/conventions.js +1 -1
- package/lib/css/data.js +224 -219
- package/lib/css/syntax-parser.js +1159 -298
- package/lib/css/syntax-printer.js +90 -35
- package/lib/debug/ProfilingPlugin.js +65 -43
- package/lib/define/DefinePlugin.js +10 -15
- package/lib/define/DotenvPlugin.js +10 -6
- package/lib/define/EnvironmentPlugin.js +4 -2
- package/lib/dependencies/amd/AMDDefineDependencyParserPlugin.js +1 -2
- package/lib/dependencies/amd/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/commonjs/CommonJsExportRequireDependency.js +1 -4
- package/lib/dependencies/commonjs/CommonJsExportsParserPlugin.js +18 -33
- package/lib/dependencies/commonjs/CommonJsImportsParserPlugin.js +1 -3
- package/lib/dependencies/commonjs/CommonJsObjectExportDependency.js +4 -4
- package/lib/dependencies/commonjs/CommonJsPlugin.js +2 -5
- package/lib/dependencies/commonjs/RequireEnsureDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js +1 -2
- package/lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js +4 -7
- package/lib/dependencies/context/ImportMetaGlobHelpers.js +8 -10
- package/lib/dependencies/core/CachedConstDependency.js +9 -6
- package/lib/dependencies/css/CssIcssExportDependency.js +6 -7
- package/lib/dependencies/css/CssIcssImportDependency.js +1 -3
- package/lib/dependencies/css/CssUrlDependency.js +2 -6
- package/lib/dependencies/esm/ESMDetectionParserPlugin.js +2 -4
- package/lib/dependencies/esm/ESMExportExpressionDependency.js +2 -2
- package/lib/dependencies/esm/ESMExportImportedSpecifierDependency.js +16 -18
- package/lib/dependencies/esm/ESMExportSpecifierDependency.js +20 -3
- package/lib/dependencies/esm/ESMExports.js +2 -10
- package/lib/dependencies/esm/ESMImportDependency.js +17 -2
- package/lib/dependencies/esm/ESMImportDependencyParserPlugin.js +6 -17
- package/lib/dependencies/esm/ESMImportGuard.js +11 -23
- package/lib/dependencies/esm/ESMImportSideEffectDependency.js +1 -1
- package/lib/dependencies/esm/ESMImportSpecifierDependency.js +4 -1
- package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
- package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
- package/lib/dependencies/esm/ESMModulesPlugin.js +1 -3
- package/lib/dependencies/esm/TopLevelAwaitDependency.js +1 -8
- package/lib/dependencies/helpers/DynamicExports.js +4 -6
- package/lib/dependencies/html/HtmlEntryDependency.js +5 -14
- package/lib/dependencies/html/HtmlInlineHtmlDependency.js +1 -4
- package/lib/dependencies/html/HtmlInlineScriptDependency.js +2 -6
- package/lib/dependencies/html/HtmlInlineStyleDependency.js +1 -4
- package/lib/dependencies/import/ImportParserPlugin.js +3 -6
- package/lib/dependencies/import-meta/ImportMetaPlugin.js +4 -6
- package/lib/dependencies/url/URLParserPlugin.js +1 -1
- package/lib/dependencies/worker/WorkerAndWorkletPlugin.js +51 -20
- package/lib/devtool/ModuleFilenameHelpers.js +1 -1
- package/lib/devtool/SourceMapDevToolPlugin.js +1 -1
- package/lib/dll/DelegatedModule.js +3 -3
- package/lib/dll/DllModule.js +3 -1
- package/lib/dll/DllReferencePlugin.js +1 -4
- package/lib/errors/AbstractMethodError.js +1 -1
- package/lib/errors/ErrorHelpers.js +2 -1
- package/lib/errors/HookWebpackError.js +2 -1
- package/lib/errors/JSONParseError.js +4 -4
- package/lib/errors/WebpackError.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +36 -1
- package/lib/externals/ExternalModule.js +12 -9
- package/lib/externals/ExternalModuleFactoryPlugin.js +1 -2
- package/lib/externals/ExternalsPlugin.js +1 -1
- package/lib/fs/FileSystemInfo.js +4 -4
- package/lib/graph/AsyncDependenciesBlock.js +1 -1
- package/lib/graph/ChunkGraph.js +5 -0
- package/lib/graph/Dependency.js +8 -2
- package/lib/graph/ExportsInfo.js +1 -1
- package/lib/graph/ModuleGraph.js +14 -3
- package/lib/graph/buildChunkGraph.js +17 -19
- package/lib/graph/findGraphRoots.js +1 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +10 -9
- package/lib/hmr/HotModuleReplacementPlugin.js +5 -11
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +16 -19
- package/lib/hmr/LazyCompilationPlugin.js +1 -7
- package/lib/html/HtmlGenerator.js +25 -17
- package/lib/html/HtmlModule.js +11 -1
- package/lib/html/HtmlModulesPlugin.js +12 -11
- package/lib/html/HtmlParser.js +10 -9
- package/lib/html/builtinEmbeddedRenderer.js +31 -33
- package/lib/html/data.js +42 -21
- package/lib/html/htmlMinify.js +4 -1
- package/lib/html/syntax-parser.js +34 -35
- package/lib/html/syntax-printer.js +2 -3
- package/lib/html/xmlMinify.js +4 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -12
- package/lib/javascript/APIPlugin.js +7 -13
- package/lib/javascript/BasicEvaluatedExpression.js +5 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -7
- package/lib/javascript/ConstPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +16 -11
- package/lib/javascript/JavascriptMetaInfoPlugin.js +3 -15
- package/lib/javascript/JavascriptModule.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +2 -4
- package/lib/javascript/JavascriptParser.js +99 -11
- package/lib/javascript/ScopeAnalyzer.js +183 -107
- package/lib/javascript/UseStrictPlugin.js +2 -5
- package/lib/javascript/jsMinify.js +1 -1
- package/lib/javascript/regexp.js +2 -2
- package/lib/javascript/syntax-parser.js +2114 -1506
- package/lib/javascript/syntax-printer-data.js +167 -1
- package/lib/javascript/syntax-printer.js +9554 -2782
- package/lib/json/JsonGenerator.js +15 -7
- package/lib/json/JsonModule.js +11 -0
- package/lib/json/JsonParser.js +7 -6
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +399 -23
- package/lib/loaders/LoaderRunner.js +76 -38
- package/lib/loaders/loadLoader.js +16 -10
- package/lib/module/Generator.js +17 -9
- package/lib/module/Module.js +2 -2
- package/lib/module/NormalModule.js +7 -5
- package/lib/module/NormalModuleFactory.js +11 -17
- package/lib/module/Parser.js +9 -2
- package/lib/module/extractSourceMap.js +69 -18
- package/lib/module/findCaseMismatch.js +2 -2
- package/lib/node/ExternalModuleInitFragment.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -12
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -6
- package/lib/node/nodeConsole.js +4 -3
- package/lib/optimize/CircularModulesPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +2 -6
- package/lib/optimize/FlagDependencyExportsPlugin.js +6 -11
- package/lib/optimize/FlagDependencyUsagePlugin.js +28 -3
- package/lib/optimize/InlineExports.js +4 -7
- package/lib/optimize/LazyBarrels.js +41 -5
- package/lib/optimize/ModuleConcatenationPlugin.js +8 -10
- package/lib/optimize/RealContentHashPlugin.js +2 -6
- package/lib/optimize/SideEffectsFlagPlugin.js +7 -21
- package/lib/optimize/SplitChunksPlugin.js +11 -24
- package/lib/optimize/TupleQueue.js +1 -1
- package/lib/output/CleanPlugin.js +3 -1
- package/lib/output/CopyPlugin.js +3 -4
- package/lib/performance/EvalUsagePlugin.js +1 -3
- package/lib/performance/HotspotsPlugin.js +33 -9
- package/lib/performance/PureAnnotationsPlugin.js +16 -10
- package/lib/performance/TopLevelThisPlugin.js +17 -9
- package/lib/prefetch/ResourceHintPlugin.js +1 -1
- package/lib/provide/ProvidedDependency.js +36 -4
- package/lib/rules/BasicEffectRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +15 -5
- package/lib/rules/UseEffectRulePlugin.js +1 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +7 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -5
- package/lib/runtime/RuntimeGlobals.js +6 -0
- package/lib/runtime/RuntimePlugin.js +2 -0
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/schemes/VirtualUrlPlugin.js +3 -1
- package/lib/serialization/AggregateErrorSerializer.js +3 -3
- package/lib/serialization/BinaryMiddleware.js +4 -1
- package/lib/serialization/ErrorObjectSerializer.js +2 -5
- package/lib/serialization/ObjectMiddleware.js +17 -15
- package/lib/serialization/PlainObjectSerializer.js +3 -7
- package/lib/serialization/Serializer.js +21 -11
- package/lib/serialization/SerializerMiddleware.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +35 -35
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -11
- package/lib/stats/StatsFactory.js +194 -24
- package/lib/stats/StatsPrinter.js +126 -13
- package/lib/template/DependencyTemplate.js +1 -1
- package/lib/template/RuntimeTemplate.js +13 -32
- package/lib/template/Template.js +1 -1
- package/lib/util/SourceProcessor.js +98 -15
- package/lib/util/WeakTupleMap.js +10 -4
- package/lib/util/cleverMerge.js +61 -33
- package/lib/util/comparators.js +9 -5
- package/lib/util/dataURL.js +2 -0
- package/lib/util/deprecation.js +4 -3
- package/lib/util/globUtils.js +1 -4
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/makeSerializable.js +6 -4
- package/lib/util/memoize.js +1 -1
- package/lib/util/parseJson.js +2 -2
- package/lib/util/serialization.js +31 -27
- package/lib/wasm/AsyncWasmModule.js +12 -2
- package/lib/wasm/AsyncWebAssemblyGenerator.js +12 -4
- package/lib/wasm/AsyncWebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm/AsyncWebAssemblyParser.js +7 -5
- package/lib/wasm/UniversalCompileAsyncWasmPlugin.js +2 -6
- package/lib/wasm-sync/SyncWasmModule.js +16 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +15 -10
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +13 -5
- package/lib/wasm-sync/WebAssemblyParser.js +10 -12
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -12
- package/lib/web/FetchCompileWasmPlugin.js +2 -6
- package/package.json +16 -18
- package/schemas/WebpackOptions.check.js +3 -3
- package/schemas/WebpackOptions.json +2 -2
- package/schemas/plugins/BannerPlugin.check.js +3 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +3 -3
- package/schemas/plugins/HtmlParserOptions.check.js +3 -3
- package/schemas/plugins/IgnorePlugin.check.js +3 -3
- package/schemas/plugins/LoaderOptionsPlugin.check.js +3 -3
- package/schemas/plugins/ManifestPlugin.check.js +3 -3
- package/schemas/plugins/ProgressPlugin.check.js +3 -3
- package/schemas/plugins/SSRManifestPlugin.check.js +3 -3
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +3 -3
- package/schemas/plugins/WatchIgnorePlugin.check.js +3 -3
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetParserOptions.check.js +3 -3
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +3 -3
- package/schemas/plugins/container/ContainerPlugin.check.js +3 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +3 -3
- package/schemas/plugins/container/ExternalsType.check.js +3 -3
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +3 -3
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +3 -3
- package/schemas/plugins/css/CssModuleParserOptions.check.js +3 -3
- package/schemas/plugins/css/CssParserOptions.check.js +3 -3
- package/schemas/plugins/debug/ProfilingPlugin.check.js +3 -3
- package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
- package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.js +3 -3
- package/schemas/plugins/dll/DllReferencePlugin.check.js +3 -3
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +3 -3
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +3 -3
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +3 -3
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +3 -3
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +3 -3
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +3 -3
- package/schemas/plugins/output/CleanOptions.check.js +7 -0
- package/schemas/plugins/output/CleanOptions.json +3 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +3 -3
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +3 -3
- package/schemas/plugins/sharing/SharePlugin.check.js +3 -3
- package/types.d.ts +1482 -358
|
@@ -42,6 +42,7 @@ const { updateHashFromSource } = require("../util/source");
|
|
|
42
42
|
|
|
43
43
|
const getMimeTypes = memoize(() => require("../util/mimeTypes"));
|
|
44
44
|
|
|
45
|
+
/** @import { BuiltAssetModule, AssetNormalModule } from "./AssetModule" */
|
|
45
46
|
/** @import { Source } from "webpack-sources" */
|
|
46
47
|
/**
|
|
47
48
|
* @import {
|
|
@@ -63,9 +64,7 @@ const getMimeTypes = memoize(() => require("../util/mimeTypes"));
|
|
|
63
64
|
* SourceTypes
|
|
64
65
|
* } from "../module/Module"
|
|
65
66
|
*/
|
|
66
|
-
/** @import { AssetModuleBuildInfo } from "./AssetModule" */
|
|
67
67
|
/** @import ModuleGraph from "../graph/ModuleGraph" */
|
|
68
|
-
/** @import NormalModule from "../module/NormalModule" */
|
|
69
68
|
/** @import RuntimeTemplate from "../template/RuntimeTemplate" */
|
|
70
69
|
/** @import Hash from "../util/Hash" */
|
|
71
70
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
@@ -206,6 +205,14 @@ const decodeDataUriContent = (encoding, content) => {
|
|
|
206
205
|
|
|
207
206
|
const DEFAULT_ENCODING = "base64";
|
|
208
207
|
|
|
208
|
+
/**
|
|
209
|
+
* The module type the JSDoc inherited from `Generator` names.
|
|
210
|
+
* @typedef {AssetNormalModule} TModule
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @extends {Generator<TModule>}
|
|
215
|
+
*/
|
|
209
216
|
class AssetGenerator extends Generator {
|
|
210
217
|
/**
|
|
211
218
|
* Creates an instance of AssetGenerator.
|
|
@@ -245,7 +252,7 @@ class AssetGenerator extends Generator {
|
|
|
245
252
|
|
|
246
253
|
/**
|
|
247
254
|
* Gets source file name.
|
|
248
|
-
* @param {
|
|
255
|
+
* @param {TModule} module module
|
|
249
256
|
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
250
257
|
* @returns {string} source file name
|
|
251
258
|
*/
|
|
@@ -260,13 +267,11 @@ class AssetGenerator extends Generator {
|
|
|
260
267
|
/**
|
|
261
268
|
* The resource this asset is named after, which something that re-encoded it
|
|
262
269
|
* may have changed. Its emitted name and inlined media type both read this.
|
|
263
|
-
* @param {
|
|
270
|
+
* @param {TModule} module module
|
|
264
271
|
* @returns {string} the resource
|
|
265
272
|
*/
|
|
266
273
|
static getAssetResource(module) {
|
|
267
|
-
const buildInfo =
|
|
268
|
-
module.buildInfo
|
|
269
|
-
);
|
|
274
|
+
const buildInfo = module.buildInfo;
|
|
270
275
|
|
|
271
276
|
return /** @type {string} */ (
|
|
272
277
|
(buildInfo && buildInfo.assetResource) || module.getResource()
|
|
@@ -278,7 +283,7 @@ class AssetGenerator extends Generator {
|
|
|
278
283
|
* `experiments.futureDefaults` (the next major release's default) `[path]` and `[file]` of a
|
|
279
284
|
* module outside of `context` behave like `[containedpath]`/`[containedfile]`,
|
|
280
285
|
* so they can't emit the asset outside of `output.path`.
|
|
281
|
-
* @param {
|
|
286
|
+
* @param {TModule} module module
|
|
282
287
|
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
283
288
|
* @returns {string} source file name for the filename template
|
|
284
289
|
*/
|
|
@@ -291,7 +296,7 @@ class AssetGenerator extends Generator {
|
|
|
291
296
|
|
|
292
297
|
/**
|
|
293
298
|
* Gets full content hash.
|
|
294
|
-
* @param {
|
|
299
|
+
* @param {TModule} module module
|
|
295
300
|
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
296
301
|
* @returns {[string, string]} return full hash and non-numeric full hash
|
|
297
302
|
*/
|
|
@@ -326,7 +331,7 @@ class AssetGenerator extends Generator {
|
|
|
326
331
|
|
|
327
332
|
/**
|
|
328
333
|
* Gets filename with info.
|
|
329
|
-
* @param {
|
|
334
|
+
* @param {TModule} module module for which the code should be generated
|
|
330
335
|
* @param {Pick<AssetResourceGeneratorOptions, "filename" | "outputPath">} generatorOptions generator options
|
|
331
336
|
* @param {{ runtime: RuntimeSpec, runtimeTemplate: RuntimeTemplate, chunkGraph: ChunkGraph }} generateContext context for generate
|
|
332
337
|
* @param {string} contentHash the content hash
|
|
@@ -384,7 +389,7 @@ class AssetGenerator extends Generator {
|
|
|
384
389
|
|
|
385
390
|
/**
|
|
386
391
|
* Gets asset path with info.
|
|
387
|
-
* @param {
|
|
392
|
+
* @param {TModule} module module for which the code should be generated
|
|
388
393
|
* @param {Pick<AssetResourceGeneratorOptions, "publicPath">} generatorOptions generator options
|
|
389
394
|
* @param {GenerateContext} generateContext context for generate
|
|
390
395
|
* @param {string} filename the filename
|
|
@@ -496,7 +501,7 @@ class AssetGenerator extends Generator {
|
|
|
496
501
|
|
|
497
502
|
/**
|
|
498
503
|
* Returns the reason this module cannot be concatenated, when one exists.
|
|
499
|
-
* @param {
|
|
504
|
+
* @param {TModule} module module for which the bailout reason should be determined
|
|
500
505
|
* @param {ConcatenationBailoutReasonContext} context context
|
|
501
506
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
|
502
507
|
*/
|
|
@@ -506,7 +511,7 @@ class AssetGenerator extends Generator {
|
|
|
506
511
|
|
|
507
512
|
/**
|
|
508
513
|
* Returns mime type.
|
|
509
|
-
* @param {
|
|
514
|
+
* @param {TModule} module module
|
|
510
515
|
* @returns {string} mime type
|
|
511
516
|
*/
|
|
512
517
|
getMimeType(module) {
|
|
@@ -557,14 +562,14 @@ class AssetGenerator extends Generator {
|
|
|
557
562
|
);
|
|
558
563
|
}
|
|
559
564
|
|
|
560
|
-
return
|
|
565
|
+
return mimeType;
|
|
561
566
|
}
|
|
562
567
|
|
|
563
568
|
/**
|
|
564
569
|
* Offer the payload to `renderEmbeddedSource` before it is encoded, so the
|
|
565
570
|
* encoding covers what came back. Declines what names no language, and a
|
|
566
571
|
* `dataUrl` function, which is handed the source itself.
|
|
567
|
-
* @param {
|
|
572
|
+
* @param {TModule} module the module holding the payload
|
|
568
573
|
* @param {GenerateContext["runtimeTemplate"]} runtimeTemplate runtime template
|
|
569
574
|
* @returns {Source | undefined} the rendered payload, when one came back
|
|
570
575
|
*/
|
|
@@ -592,7 +597,7 @@ class AssetGenerator extends Generator {
|
|
|
592
597
|
|
|
593
598
|
/**
|
|
594
599
|
* Generates data uri.
|
|
595
|
-
* @param {
|
|
600
|
+
* @param {TModule} module module for which the code should be generated
|
|
596
601
|
* @param {Source=} renderedSource the payload to encode, when a hook rendered it
|
|
597
602
|
* @returns {string} DataURI
|
|
598
603
|
*/
|
|
@@ -650,10 +655,7 @@ class AssetGenerator extends Generator {
|
|
|
650
655
|
/** @type {string} */ (source.source())
|
|
651
656
|
);
|
|
652
657
|
} else {
|
|
653
|
-
encodedContent = encodeDataUri(
|
|
654
|
-
/** @type {"base64" | false} */ (encoding),
|
|
655
|
-
source
|
|
656
|
-
);
|
|
658
|
+
encodedContent = encodeDataUri(encoding, source);
|
|
657
659
|
}
|
|
658
660
|
|
|
659
661
|
encodedSource = `data:${mimeType}${
|
|
@@ -666,7 +668,7 @@ class AssetGenerator extends Generator {
|
|
|
666
668
|
|
|
667
669
|
/**
|
|
668
670
|
* Generates generated code for this runtime module.
|
|
669
|
-
* @param {
|
|
671
|
+
* @param {TModule} module module for which the code should be generated
|
|
670
672
|
* @param {GenerateContext} generateContext context for generate
|
|
671
673
|
* @returns {Source | null} generated code
|
|
672
674
|
*/
|
|
@@ -684,12 +686,9 @@ class AssetGenerator extends Generator {
|
|
|
684
686
|
|
|
685
687
|
const needContent = type === JAVASCRIPT_TYPE || type === ASSET_URL_TYPE;
|
|
686
688
|
const data = getData ? getData() : undefined;
|
|
689
|
+
const { buildInfo } = /** @type {BuiltAssetModule} */ (module);
|
|
687
690
|
|
|
688
|
-
if (
|
|
689
|
-
/** @type {AssetModuleBuildInfo} */
|
|
690
|
-
(module.buildInfo).dataUrl &&
|
|
691
|
-
needContent
|
|
692
|
-
) {
|
|
691
|
+
if (buildInfo.dataUrl && needContent) {
|
|
693
692
|
// WHY: CSS and HTML serializers offer the payload in the `url()` or
|
|
694
693
|
// attribute it lands in, but the `asset-url` value is also what an
|
|
695
694
|
// analyzable `new URL` copies into JavaScript, which nothing re-reads.
|
|
@@ -716,8 +715,7 @@ class AssetGenerator extends Generator {
|
|
|
716
715
|
data.set("contentHash", contentHash);
|
|
717
716
|
}
|
|
718
717
|
|
|
719
|
-
|
|
720
|
-
(module.buildInfo).fullContentHash = fullContentHash;
|
|
718
|
+
buildInfo.fullContentHash = fullContentHash;
|
|
721
719
|
|
|
722
720
|
const { originalFilename, filename, assetInfo } =
|
|
723
721
|
AssetGenerator.getFilenameWithInfo(
|
|
@@ -762,11 +760,9 @@ class AssetGenerator extends Generator {
|
|
|
762
760
|
// Due to code generation caching module.buildInfo.XXX can't used to store such information
|
|
763
761
|
// It need to be stored in the code generation results instead, where it's cached too
|
|
764
762
|
// TODO in the next major release: remove the back-compat writes to module.buildInfo
|
|
765
|
-
|
|
766
|
-
(module.buildInfo).filename = filename;
|
|
763
|
+
buildInfo.filename = filename;
|
|
767
764
|
|
|
768
|
-
|
|
769
|
-
(module.buildInfo).assetInfo = newAssetInfo;
|
|
765
|
+
buildInfo.assetInfo = newAssetInfo;
|
|
770
766
|
|
|
771
767
|
content = assetPath;
|
|
772
768
|
}
|
|
@@ -797,7 +793,7 @@ class AssetGenerator extends Generator {
|
|
|
797
793
|
/**
|
|
798
794
|
* Generates fallback output for the provided error condition.
|
|
799
795
|
* @param {Error} error the error
|
|
800
|
-
* @param {
|
|
796
|
+
* @param {TModule} module module for which the code should be generated
|
|
801
797
|
* @param {GenerateContext} generateContext context for generate
|
|
802
798
|
* @returns {Source | null} generated code
|
|
803
799
|
*/
|
|
@@ -847,7 +843,7 @@ class AssetGenerator extends Generator {
|
|
|
847
843
|
|
|
848
844
|
/**
|
|
849
845
|
* Returns the source types available for this module.
|
|
850
|
-
* @param {
|
|
846
|
+
* @param {TModule} module fresh module
|
|
851
847
|
* @returns {SourceTypes} available types (do not mutate)
|
|
852
848
|
*/
|
|
853
849
|
getTypes(module) {
|
|
@@ -855,10 +851,7 @@ class AssetGenerator extends Generator {
|
|
|
855
851
|
|
|
856
852
|
// One that emits nothing has no name to build a literal from, so expose its url.
|
|
857
853
|
const emits =
|
|
858
|
-
!(
|
|
859
|
-
module.buildInfo &&
|
|
860
|
-
/** @type {AssetModuleBuildInfo} */ (module.buildInfo).dataUrl
|
|
861
|
-
) && this.emit !== false;
|
|
854
|
+
!(module.buildInfo && module.buildInfo.dataUrl) && this.emit !== false;
|
|
862
855
|
|
|
863
856
|
// WHY: only analyzable ESM output can drop a bare `new URL()` to an asset
|
|
864
857
|
// url; without it every JS consumer needs the wrapper, so the per-connection
|
|
@@ -960,7 +953,7 @@ class AssetGenerator extends Generator {
|
|
|
960
953
|
|
|
961
954
|
/**
|
|
962
955
|
* Returns the estimated size for the requested source type.
|
|
963
|
-
* @param {
|
|
956
|
+
* @param {TModule} module the module
|
|
964
957
|
* @param {SourceType=} type source type
|
|
965
958
|
* @returns {number} estimate size of the module
|
|
966
959
|
*/
|
|
@@ -976,10 +969,7 @@ class AssetGenerator extends Generator {
|
|
|
976
969
|
return originalSource.size();
|
|
977
970
|
}
|
|
978
971
|
default:
|
|
979
|
-
if (
|
|
980
|
-
module.buildInfo &&
|
|
981
|
-
/** @type {AssetModuleBuildInfo} */ (module.buildInfo).dataUrl
|
|
982
|
-
) {
|
|
972
|
+
if (module.buildInfo && module.buildInfo.dataUrl) {
|
|
983
973
|
const originalSource = module.originalSource();
|
|
984
974
|
|
|
985
975
|
if (!originalSource) {
|
|
@@ -999,15 +989,13 @@ class AssetGenerator extends Generator {
|
|
|
999
989
|
/**
|
|
1000
990
|
* Updates the hash with the data contributed by this instance.
|
|
1001
991
|
* @param {Hash} hash hash that will be modified
|
|
1002
|
-
* @param {UpdateHashContext} updateHashContext context for updating hash
|
|
992
|
+
* @param {UpdateHashContext<TModule>} updateHashContext context for updating hash
|
|
1003
993
|
*/
|
|
1004
994
|
updateHash(hash, updateHashContext) {
|
|
1005
995
|
const { module } = updateHashContext;
|
|
996
|
+
const { buildInfo } = /** @type {BuiltAssetModule} */ (module);
|
|
1006
997
|
|
|
1007
|
-
if (
|
|
1008
|
-
/** @type {AssetModuleBuildInfo} */
|
|
1009
|
-
(module.buildInfo).dataUrl
|
|
1010
|
-
) {
|
|
998
|
+
if (buildInfo.dataUrl) {
|
|
1011
999
|
hash.update("data-url");
|
|
1012
1000
|
// What a tap varies on has to reach the key, or a changed option replays.
|
|
1013
1001
|
const { runtimeTemplate } = updateHashContext;
|
package/lib/asset/AssetModule.js
CHANGED
|
@@ -8,6 +8,7 @@ const NormalModule = require("../module/NormalModule");
|
|
|
8
8
|
const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
|
|
10
10
|
/** @import { AssetInfo } from "../Compilation" */
|
|
11
|
+
/** @import { BuildMeta } from "../module/Module" */
|
|
11
12
|
/**
|
|
12
13
|
* @import {
|
|
13
14
|
* NormalModuleBuildInfo,
|
|
@@ -29,6 +30,16 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
29
30
|
|
|
30
31
|
/** @typedef {NormalModuleBuildInfo & KnownAssetModuleBuildInfo} AssetModuleBuildInfo */
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* An asset module before or after its build, typed with its build info.
|
|
35
|
+
* @typedef {NormalModule & { buildInfo?: AssetModuleBuildInfo }} AssetNormalModule
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A built asset module, typed with its build info and build meta.
|
|
40
|
+
* @typedef {NormalModule & { buildInfo: AssetModuleBuildInfo, buildMeta: BuildMeta }} BuiltAssetModule
|
|
41
|
+
*/
|
|
42
|
+
|
|
32
43
|
/**
|
|
33
44
|
* Module class for all `asset/*` modules. Asset-specific properties should live here instead of `NormalModule`.
|
|
34
45
|
*/
|
|
@@ -43,9 +43,8 @@ const { PUBLIC_PATH_AUTO } = require("../util/publicPathPlaceholder");
|
|
|
43
43
|
* } from "../Compilation"
|
|
44
44
|
*/
|
|
45
45
|
/** @import Compiler from "../Compiler" */
|
|
46
|
-
/** @import { AssetModuleBuildInfo } from "./AssetModule" */
|
|
46
|
+
/** @import { AssetModuleBuildInfo, BuiltAssetModule } from "./AssetModule" */
|
|
47
47
|
/** @import { CodeGenerationResult } from "../module/Module" */
|
|
48
|
-
/** @import NormalModule from "../module/NormalModule" */
|
|
49
48
|
|
|
50
49
|
/**
|
|
51
50
|
* Returns definition.
|
|
@@ -345,7 +344,9 @@ class AssetModulesPlugin {
|
|
|
345
344
|
let entryHash;
|
|
346
345
|
|
|
347
346
|
if (errored) {
|
|
348
|
-
const erroredModule = /** @type {
|
|
347
|
+
const erroredModule = /** @type {BuiltAssetModule} */ (
|
|
348
|
+
module
|
|
349
|
+
);
|
|
349
350
|
const AssetGenerator = getAssetGenerator.loaded();
|
|
350
351
|
const [fullContentHash, contentHash] =
|
|
351
352
|
AssetGenerator.getFullContentHash(
|
|
@@ -454,7 +455,7 @@ class AssetModulesPlugin {
|
|
|
454
455
|
// Icon URLs resolve relative to the manifest's own location.
|
|
455
456
|
const undoPath = getUndoPath(
|
|
456
457
|
filename,
|
|
457
|
-
|
|
458
|
+
outputOptions.path,
|
|
458
459
|
false
|
|
459
460
|
);
|
|
460
461
|
const content = source
|
package/lib/asset/AssetParser.js
CHANGED
|
@@ -7,18 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
const Parser = require("../module/Parser");
|
|
9
9
|
|
|
10
|
+
/** @import { BuiltAssetModule } from "./AssetModule" */
|
|
10
11
|
/**
|
|
11
12
|
* @import {
|
|
12
13
|
* AssetParserDataUrlOptions,
|
|
13
14
|
* AssetParserOptions
|
|
14
15
|
* } from "../../declarations/WebpackOptions"
|
|
15
16
|
*/
|
|
16
|
-
/** @import Module
|
|
17
|
-
/** @import { AssetModuleBuildInfo } from "./AssetModule" */
|
|
17
|
+
/** @import Module from "../module/Module" */
|
|
18
18
|
/** @import { ParserState, PreparsedAst } from "../module/Parser" */
|
|
19
19
|
|
|
20
20
|
/** @typedef {((source: string | Buffer, context: { filename: string, module: Module }) => boolean)} AssetParserDataUrlFunction */
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @extends {Parser<BuiltAssetModule>}
|
|
24
|
+
*/
|
|
22
25
|
class AssetParser extends Parser {
|
|
23
26
|
/**
|
|
24
27
|
* Creates an instance of AssetParser.
|
|
@@ -41,13 +44,10 @@ class AssetParser extends Parser {
|
|
|
41
44
|
throw new Error("AssetParser doesn't accept preparsed AST");
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
const buildInfo =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const { buildInfo, buildMeta } = /** @type {BuiltAssetModule} */ (
|
|
48
|
+
state.module
|
|
49
|
+
);
|
|
47
50
|
buildInfo.strict = true;
|
|
48
|
-
const buildMeta =
|
|
49
|
-
/** @type {BuildMeta} */
|
|
50
|
-
(state.module.buildMeta);
|
|
51
51
|
buildMeta.exportsType = "default";
|
|
52
52
|
buildMeta.defaultObject = false;
|
|
53
53
|
|
|
@@ -21,6 +21,7 @@ const ConcatenationScope = require("../optimize/ConcatenationScope");
|
|
|
21
21
|
const RuntimeGlobals = require("../runtime/RuntimeGlobals");
|
|
22
22
|
const { languageOfFilename } = require("../util/dataURL");
|
|
23
23
|
|
|
24
|
+
/** @import { AssetNormalModule } from "./AssetModule" */
|
|
24
25
|
/** @import { Source } from "webpack-sources" */
|
|
25
26
|
/** @import { GenerateContext, UpdateHashContext } from "../module/Generator" */
|
|
26
27
|
/** @import Hash from "../util/Hash" */
|
|
@@ -32,8 +33,15 @@ const { languageOfFilename } = require("../util/dataURL");
|
|
|
32
33
|
* } from "../module/Module"
|
|
33
34
|
*/
|
|
34
35
|
/** @import ModuleGraph from "../graph/ModuleGraph" */
|
|
35
|
-
/** @import NormalModule from "../module/NormalModule" */
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The module type the JSDoc inherited from `Generator` names.
|
|
39
|
+
* @typedef {AssetNormalModule} TModule
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @extends {Generator<TModule>}
|
|
44
|
+
*/
|
|
37
45
|
class AssetSourceGenerator extends Generator {
|
|
38
46
|
/**
|
|
39
47
|
* Creates an instance of AssetSourceGenerator.
|
|
@@ -48,7 +56,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
48
56
|
|
|
49
57
|
/**
|
|
50
58
|
* Generates generated code for this runtime module.
|
|
51
|
-
* @param {
|
|
59
|
+
* @param {TModule} module module for which the code should be generated
|
|
52
60
|
* @param {GenerateContext} generateContext context for generate
|
|
53
61
|
* @returns {Source | null} generated code
|
|
54
62
|
*/
|
|
@@ -111,7 +119,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
111
119
|
/**
|
|
112
120
|
* Offer the file's text to `renderEmbeddedSource` before it is embedded in
|
|
113
121
|
* JavaScript. Declines a file whose name names no language webpack knows.
|
|
114
|
-
* @param {
|
|
122
|
+
* @param {TModule} module the module holding the text
|
|
115
123
|
* @param {string} text the file's text
|
|
116
124
|
* @param {GenerateContext["runtimeTemplate"]} runtimeTemplate runtime template
|
|
117
125
|
* @returns {string} the rendered text, or `text` when nothing rendered it
|
|
@@ -134,7 +142,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
134
142
|
/**
|
|
135
143
|
* Updates the hash with the data contributed by this instance.
|
|
136
144
|
* @param {Hash} hash hash that will be modified
|
|
137
|
-
* @param {UpdateHashContext} updateHashContext context for updating hash
|
|
145
|
+
* @param {UpdateHashContext<TModule>} updateHashContext context for updating hash
|
|
138
146
|
*/
|
|
139
147
|
updateHash(hash, updateHashContext) {
|
|
140
148
|
const { module, runtimeTemplate } = updateHashContext;
|
|
@@ -151,7 +159,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
151
159
|
/**
|
|
152
160
|
* Generates fallback output for the provided error condition.
|
|
153
161
|
* @param {Error} error the error
|
|
154
|
-
* @param {
|
|
162
|
+
* @param {TModule} module module for which the code should be generated
|
|
155
163
|
* @param {GenerateContext} generateContext context for generate
|
|
156
164
|
* @returns {Source | null} generated code
|
|
157
165
|
*/
|
|
@@ -173,7 +181,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
173
181
|
|
|
174
182
|
/**
|
|
175
183
|
* Returns the reason this module cannot be concatenated, when one exists.
|
|
176
|
-
* @param {
|
|
184
|
+
* @param {TModule} module module for which the bailout reason should be determined
|
|
177
185
|
* @param {ConcatenationBailoutReasonContext} context context
|
|
178
186
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
|
179
187
|
*/
|
|
@@ -183,7 +191,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
183
191
|
|
|
184
192
|
/**
|
|
185
193
|
* Returns the source types available for this module.
|
|
186
|
-
* @param {
|
|
194
|
+
* @param {TModule} module fresh module
|
|
187
195
|
* @returns {SourceTypes} available types (do not mutate)
|
|
188
196
|
*/
|
|
189
197
|
getTypes(module) {
|
|
@@ -223,7 +231,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
223
231
|
|
|
224
232
|
/**
|
|
225
233
|
* Returns the estimated size for the requested source type.
|
|
226
|
-
* @param {
|
|
234
|
+
* @param {TModule} module the module
|
|
227
235
|
* @param {SourceType=} type source type
|
|
228
236
|
* @returns {number} estimate size of the module
|
|
229
237
|
*/
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
const Parser = require("../module/Parser");
|
|
9
9
|
|
|
10
|
-
/** @import {
|
|
10
|
+
/** @import { BuiltAssetModule } from "./AssetModule" */
|
|
11
11
|
/** @import { ParserState, PreparsedAst } from "../module/Parser" */
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @extends {Parser<BuiltAssetModule>}
|
|
15
|
+
*/
|
|
13
16
|
class AssetSourceParser extends Parser {
|
|
14
17
|
/**
|
|
15
18
|
* Parses the provided source and updates the parser state.
|
|
@@ -21,13 +24,12 @@ class AssetSourceParser extends Parser {
|
|
|
21
24
|
if (typeof source === "object" && !Buffer.isBuffer(source)) {
|
|
22
25
|
throw new Error("AssetSourceParser doesn't accept preparsed AST");
|
|
23
26
|
}
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(state.module.buildMeta).defaultObject = false;
|
|
27
|
+
const { buildInfo, buildMeta } = /** @type {BuiltAssetModule} */ (
|
|
28
|
+
state.module
|
|
29
|
+
);
|
|
30
|
+
buildInfo.strict = true;
|
|
31
|
+
buildMeta.exportsType = "default";
|
|
32
|
+
buildMeta.defaultObject = false;
|
|
31
33
|
|
|
32
34
|
return state;
|
|
33
35
|
}
|
|
@@ -19,7 +19,7 @@ const AssetGenerator = require("./AssetGenerator");
|
|
|
19
19
|
/** @import { GenerateContext } from "../module/Generator" */
|
|
20
20
|
/** @import { SourceType, SourceTypes } from "../module/Module" */
|
|
21
21
|
/** @import ModuleGraph from "../graph/ModuleGraph" */
|
|
22
|
-
/** @import
|
|
22
|
+
/** @import { AssetNormalModule } from "./AssetModule" */
|
|
23
23
|
|
|
24
24
|
const WEBMANIFEST_TYPE = "webmanifest";
|
|
25
25
|
const WEBMANIFEST_TYPES = new Set([WEBMANIFEST_TYPE]);
|
|
@@ -28,6 +28,11 @@ const WEBMANIFEST_AND_ASSET_URL_TYPES = new Set([
|
|
|
28
28
|
ASSET_URL_TYPE
|
|
29
29
|
]);
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The module type the JSDoc inherited from `Generator` names.
|
|
33
|
+
* @typedef {AssetNormalModule} TModule
|
|
34
|
+
*/
|
|
35
|
+
|
|
31
36
|
/**
|
|
32
37
|
* A Web App Manifest is a "typed asset": a variant of `AssetGenerator` (reusing
|
|
33
38
|
* its filename/hash and `ASSET_URL_TYPE` machinery) whose emitted content is the
|
|
@@ -46,7 +51,7 @@ class WebManifestGenerator extends AssetGenerator {
|
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* Returns the source types available for this module.
|
|
49
|
-
* @param {
|
|
54
|
+
* @param {TModule} module fresh module
|
|
50
55
|
* @returns {SourceTypes} available types (do not mutate)
|
|
51
56
|
*/
|
|
52
57
|
getTypes(module) {
|
|
@@ -58,7 +63,7 @@ class WebManifestGenerator extends AssetGenerator {
|
|
|
58
63
|
|
|
59
64
|
/**
|
|
60
65
|
* Returns the estimated size for the requested source type.
|
|
61
|
-
* @param {
|
|
66
|
+
* @param {TModule} module the module
|
|
62
67
|
* @param {SourceType=} type source type
|
|
63
68
|
* @returns {number} estimate size of the module
|
|
64
69
|
*/
|
|
@@ -69,7 +74,7 @@ class WebManifestGenerator extends AssetGenerator {
|
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
76
|
* Rewrites each icon `src` in the raw manifest to its emitted asset URL.
|
|
72
|
-
* @param {
|
|
77
|
+
* @param {TModule} module the manifest module
|
|
73
78
|
* @param {GenerateContext} generateContext context for generate
|
|
74
79
|
* @returns {string} the rewritten manifest content
|
|
75
80
|
*/
|
|
@@ -111,7 +116,7 @@ class WebManifestGenerator extends AssetGenerator {
|
|
|
111
116
|
|
|
112
117
|
/**
|
|
113
118
|
* Generates generated code for this runtime module.
|
|
114
|
-
* @param {
|
|
119
|
+
* @param {TModule} module module for which the code should be generated
|
|
115
120
|
* @param {GenerateContext} generateContext context for generate
|
|
116
121
|
* @returns {Source | null} generated code
|
|
117
122
|
*/
|
|
@@ -133,7 +138,7 @@ class WebManifestGenerator extends AssetGenerator {
|
|
|
133
138
|
);
|
|
134
139
|
const contentHash = nonNumericOnlyHash(
|
|
135
140
|
fullContentHash,
|
|
136
|
-
|
|
141
|
+
outputOptions.hashDigestLength
|
|
137
142
|
);
|
|
138
143
|
const { filename, assetInfo } = AssetGenerator.getFilenameWithInfo(
|
|
139
144
|
module,
|
|
@@ -51,7 +51,7 @@ class WebManifestParser extends Parser {
|
|
|
51
51
|
source = source.slice(1);
|
|
52
52
|
leadingBytes = binary ? BOM_BYTE_LENGTH : 1;
|
|
53
53
|
}
|
|
54
|
-
const text =
|
|
54
|
+
const text = source;
|
|
55
55
|
const asciiOnly = !binary || Buffer.byteLength(text) === text.length;
|
|
56
56
|
/**
|
|
57
57
|
* @param {number} offset offset in UTF-16 code units into `text`
|
|
@@ -121,8 +121,8 @@ class WebManifestParser extends Parser {
|
|
|
121
121
|
if (!buildHttp && ABSOLUTE_URL_SCHEME_REGEXP.test(url)) continue;
|
|
122
122
|
// acorn offsets are into `(${source})`; the leading `(` and the
|
|
123
123
|
// opening quote cancel, so the inner span is [start, end - 2].
|
|
124
|
-
const { start, end } = /** @type {Positioned} */ (
|
|
125
|
-
|
|
124
|
+
const { start, end } = /** @type {Expression & Positioned} */ (
|
|
125
|
+
value
|
|
126
126
|
);
|
|
127
127
|
const dep = new HtmlSourceDependency(url, [
|
|
128
128
|
toSourceOffset(start),
|
|
@@ -35,7 +35,12 @@ const getOutgoingAsyncModules = (moduleGraph, module) => {
|
|
|
35
35
|
// Walk the imports in source order: the spec gathers these from
|
|
36
36
|
// `[[RequestedModules]]`, and their evaluation order is observable.
|
|
37
37
|
for (const dependency of module.dependencies) {
|
|
38
|
-
if (
|
|
38
|
+
if (
|
|
39
|
+
!isDependencyKind(dependency, "esm-import") &&
|
|
40
|
+
!isDependencyKind(dependency, "provided")
|
|
41
|
+
) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
39
44
|
const referenced = moduleGraph.getModule(dependency);
|
|
40
45
|
if (!referenced || seen.has(referenced)) continue;
|
|
41
46
|
const connections = outgoingConnectionMap.get(referenced);
|
|
@@ -44,7 +49,8 @@ const getOutgoingAsyncModules = (moduleGraph, module) => {
|
|
|
44
49
|
connections.some(
|
|
45
50
|
(c) =>
|
|
46
51
|
c.dependency !== null &&
|
|
47
|
-
isDependencyKind(c.dependency, "esm-import")
|
|
52
|
+
(isDependencyKind(c.dependency, "esm-import") ||
|
|
53
|
+
isDependencyKind(c.dependency, "provided")) &&
|
|
48
54
|
c.isTargetActive(undefined)
|
|
49
55
|
)
|
|
50
56
|
) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const isDependencyKind = require("../graph/isDependencyKind");
|
|
9
9
|
|
|
10
10
|
/** @import Compiler from "../Compiler" */
|
|
11
|
-
/** @import Module from "../module/Module" */
|
|
11
|
+
/** @import Module, { BuildMeta } from "../module/Module" */
|
|
12
12
|
|
|
13
13
|
const PLUGIN_NAME = "InferAsyncModulesPlugin";
|
|
14
14
|
|
|
@@ -39,7 +39,12 @@ class InferAsyncModulesPlugin {
|
|
|
39
39
|
connections.some(
|
|
40
40
|
(c) =>
|
|
41
41
|
c.dependency !== null &&
|
|
42
|
-
isDependencyKind(c.dependency, "esm-import")
|
|
42
|
+
(isDependencyKind(c.dependency, "esm-import") ||
|
|
43
|
+
// only an ESM module has the async wrapper to await it in
|
|
44
|
+
(isDependencyKind(c.dependency, "provided") &&
|
|
45
|
+
/** @type {BuildMeta} */
|
|
46
|
+
(/** @type {Module} */ (originModule).buildMeta)
|
|
47
|
+
.exportsType === "namespace")) &&
|
|
43
48
|
c.isTargetActive(undefined)
|
|
44
49
|
)
|
|
45
50
|
) {
|
package/lib/cache/CacheFacade.js
CHANGED
|
@@ -42,7 +42,7 @@ class MultiItemCache {
|
|
|
42
42
|
this._items = items;
|
|
43
43
|
// @ts-expect-error expected - returns the single ItemCacheFacade when passed an array of length 1
|
|
44
44
|
// eslint-disable-next-line no-constructor-return
|
|
45
|
-
if (items.length === 1) return
|
|
45
|
+
if (items.length === 1) return items[0];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -215,7 +215,7 @@ class Pack {
|
|
|
215
215
|
if (!this.content[loc]) {
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
-
return
|
|
218
|
+
return this.content[loc].get(identifier);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/**
|
|
@@ -328,7 +328,9 @@ class Pack {
|
|
|
328
328
|
let ignoreNextTimeTick = false;
|
|
329
329
|
const createNextPack = () => {
|
|
330
330
|
const loc = this._findLocation();
|
|
331
|
-
this.content[loc] = /** @type {
|
|
331
|
+
this.content[loc] = /** @type {PackContent} */ (
|
|
332
|
+
/** @type {PackContent | null} */ (null)
|
|
333
|
+
); // reserve
|
|
332
334
|
/** @type {PackItem} */
|
|
333
335
|
const pack = {
|
|
334
336
|
items: new Set(),
|
|
@@ -1010,9 +1012,7 @@ class PackContent {
|
|
|
1010
1012
|
);
|
|
1011
1013
|
logger.time(timeMessage);
|
|
1012
1014
|
}
|
|
1013
|
-
const value =
|
|
1014
|
-
/** @type {PackContentItems | Promise<PackContentItems>} */
|
|
1015
|
-
(this.lazy());
|
|
1015
|
+
const value = this.lazy();
|
|
1016
1016
|
if ("then" in value) {
|
|
1017
1017
|
return value.then((data) => {
|
|
1018
1018
|
if (timeMessage) {
|
|
@@ -1789,11 +1789,7 @@ class PackFileCacheStrategy {
|
|
|
1789
1789
|
const mtimeMs = await new Promise((resolve, reject) => {
|
|
1790
1790
|
fs.stat(file, (err, stats) => {
|
|
1791
1791
|
if (err) return reject(err);
|
|
1792
|
-
resolve(
|
|
1793
|
-
/** @type {number} */ (
|
|
1794
|
-
/** @type {import("../fs/fs").IStats} */ (stats).mtimeMs
|
|
1795
|
-
)
|
|
1796
|
-
);
|
|
1792
|
+
resolve(/** @type {import("../fs/fs").IStats} */ (stats).mtimeMs);
|
|
1797
1793
|
});
|
|
1798
1794
|
});
|
|
1799
1795
|
const entry = referencedFilesCache.get(name);
|