webpack 5.107.1 → 5.108.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.
- package/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +52 -14
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +16 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +557 -77
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +9 -1
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +105 -30
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +88 -9
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +22 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +267 -154
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +20 -27
- package/lib/dependencies/HtmlInlineStyleDependency.js +62 -11
- package/lib/dependencies/HtmlSourceDependency.js +18 -0
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +40 -10
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +134 -6
- package/lib/html/HtmlGenerator.js +292 -50
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +287 -60
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +286 -159
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +54 -29
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +38 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +397 -78
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +16 -6
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +36 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1592 -314
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
|
@@ -11,6 +11,7 @@ const Compilation = require("./Compilation");
|
|
|
11
11
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
|
12
12
|
const ProgressPlugin = require("./ProgressPlugin");
|
|
13
13
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
|
14
|
+
const { getPresentKinds } = require("./TemplatedPathPlugin");
|
|
14
15
|
const createHash = require("./util/createHash");
|
|
15
16
|
const { dirname, relative } = require("./util/fs");
|
|
16
17
|
const generateDebugId = require("./util/generateDebugId");
|
|
@@ -36,17 +37,16 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
|
36
37
|
/**
|
|
37
38
|
* Defines the source map task type used by this module.
|
|
38
39
|
* @typedef {object} SourceMapTask
|
|
39
|
-
* @property {Source} asset
|
|
40
40
|
* @property {AssetInfo} assetInfo
|
|
41
41
|
* @property {(string | Module)[]} modules
|
|
42
42
|
* @property {string} source
|
|
43
43
|
* @property {string} file
|
|
44
44
|
* @property {RawSourceMap} sourceMap
|
|
45
|
+
* @property {Source} mapSource the Source instance whose `sourceAndMap` we called (the current asset or, when its map was already stripped, the pinned original from `originalSources`) — what `clearCache` should target
|
|
45
46
|
* @property {ItemCacheFacade} cacheItem cache item
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
49
|
const METACHARACTERS_REGEXP = /[-[\]\\/{}()*+?.^$|]/g;
|
|
49
|
-
const CONTENT_HASH_DETECT_REGEXP = /\[contenthash(?::\w+)?\]/;
|
|
50
50
|
const CSS_AND_JS_MODULE_EXTENSIONS_REGEXP = /\.((c|m)?js|css)($|\?)/i;
|
|
51
51
|
const CSS_EXTENSION_DETECT_REGEXP = /\.css(?:$|\?)/i;
|
|
52
52
|
const MAP_URL_COMMENT_REGEXP = /\[map\]/g;
|
|
@@ -111,12 +111,14 @@ const getOriginalSourceRegistry = (compilation) => {
|
|
|
111
111
|
* The returned source is read from the asset as it currently stands — that way
|
|
112
112
|
* any `sourceMappingURL` comments appended by earlier plugin instances survive
|
|
113
113
|
* — while the map is taken from the pinned original Source when the current
|
|
114
|
-
* one no longer carries it.
|
|
114
|
+
* one no longer carries it. `mapSource` identifies which Source instance was
|
|
115
|
+
* actually queried for the map (the current asset, or the pinned original);
|
|
116
|
+
* that's the one whose internal caches the caller should release.
|
|
115
117
|
* @param {string} file file name
|
|
116
118
|
* @param {Source} asset source object as currently held by the compilation
|
|
117
119
|
* @param {MapOptions} options map extraction options
|
|
118
120
|
* @param {Map<string, Source>} registry compilation-scoped original-source registry
|
|
119
|
-
* @returns {{ source: string, sourceMap: RawSourceMap } | undefined} extracted pair or `undefined` when no map is recoverable
|
|
121
|
+
* @returns {{ source: string, sourceMap: RawSourceMap, mapSource: Source } | undefined} extracted pair or `undefined` when no map is recoverable
|
|
120
122
|
*/
|
|
121
123
|
const extractSourceAndMap = (file, asset, options, registry) => {
|
|
122
124
|
/** @type {string | Buffer} */
|
|
@@ -139,20 +141,20 @@ const extractSourceAndMap = (file, asset, options, registry) => {
|
|
|
139
141
|
// that a later plugin instance (which will see a rewrapped asset
|
|
140
142
|
// without a map) can recover it on demand.
|
|
141
143
|
if (!registry.has(file)) registry.set(file, asset);
|
|
142
|
-
|
|
143
|
-
// The current asset (typically a `RawSource` left by an earlier
|
|
144
|
-
// SourceMapDevToolPlugin instance) has no internal map. Re-extract
|
|
145
|
-
// the map from the original Source we pinned earlier. We keep using
|
|
146
|
-
// `source` from the current asset so that any prior wrappers (e.g.
|
|
147
|
-
// appended sourceMappingURL comments) are preserved.
|
|
148
|
-
const original = registry.get(file);
|
|
149
|
-
if (!original) return;
|
|
150
|
-
sourceMap = original.sourceAndMap
|
|
151
|
-
? original.sourceAndMap(options).map
|
|
152
|
-
: original.map(options);
|
|
153
|
-
if (!sourceMap) return;
|
|
144
|
+
return { source, sourceMap, mapSource: asset };
|
|
154
145
|
}
|
|
155
|
-
|
|
146
|
+
// The current asset (typically a `RawSource` left by an earlier
|
|
147
|
+
// SourceMapDevToolPlugin instance) has no internal map. Re-extract
|
|
148
|
+
// the map from the original Source we pinned earlier. We keep using
|
|
149
|
+
// `source` from the current asset so that any prior wrappers (e.g.
|
|
150
|
+
// appended sourceMappingURL comments) are preserved.
|
|
151
|
+
const original = registry.get(file);
|
|
152
|
+
if (!original) return;
|
|
153
|
+
sourceMap = original.sourceAndMap
|
|
154
|
+
? original.sourceAndMap(options).map
|
|
155
|
+
: original.map(options);
|
|
156
|
+
if (!sourceMap) return;
|
|
157
|
+
return { source, sourceMap, mapSource: original };
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
/**
|
|
@@ -177,7 +179,7 @@ const getTaskForFile = (
|
|
|
177
179
|
) => {
|
|
178
180
|
const extracted = extractSourceAndMap(file, asset, options, registry);
|
|
179
181
|
if (!extracted) return;
|
|
180
|
-
const { source, sourceMap } = extracted;
|
|
182
|
+
const { source, sourceMap, mapSource } = extracted;
|
|
181
183
|
const context = compilation.options.context;
|
|
182
184
|
const root = compilation.compiler.root;
|
|
183
185
|
const cachedAbsolutify = makePathsAbsolute.bindContextCache(context, root);
|
|
@@ -190,10 +192,10 @@ const getTaskForFile = (
|
|
|
190
192
|
|
|
191
193
|
return {
|
|
192
194
|
file,
|
|
193
|
-
asset,
|
|
194
195
|
source: /** @type {string} */ (source),
|
|
195
196
|
assetInfo,
|
|
196
197
|
sourceMap,
|
|
198
|
+
mapSource,
|
|
197
199
|
modules,
|
|
198
200
|
cacheItem
|
|
199
201
|
};
|
|
@@ -360,6 +362,25 @@ class SourceMapDevToolPlugin {
|
|
|
360
362
|
const tasks = [];
|
|
361
363
|
let fileIndex = 0;
|
|
362
364
|
|
|
365
|
+
// Shared deduplication set for `Source#clearCache` calls below.
|
|
366
|
+
// Webpack chunks routinely share module-level `CachedSource`
|
|
367
|
+
// instances. A per-call WeakSet would re-walk those shared
|
|
368
|
+
// subtrees once per chunk — 50 chunks × thousands of shared
|
|
369
|
+
// modules in dev/non-minified setups — and worse, every
|
|
370
|
+
// chunk's `sourceAndMap` would have to recompute the cleared
|
|
371
|
+
// caches, churning allocations (measured: +700 MB peak RSS,
|
|
372
|
+
// +6 s wall time on a 50×1000 synthetic build).
|
|
373
|
+
//
|
|
374
|
+
// Sharing one set lets each shared subtree be walked exactly
|
|
375
|
+
// once. The trade-off is that subsequent chunks' `sourceAndMap`
|
|
376
|
+
// calls can repopulate a shared module's `_cachedMaps` after
|
|
377
|
+
// its own clear was skipped (because the module is already in
|
|
378
|
+
// the visited set), leaving at most one populated cache entry
|
|
379
|
+
// per shared module at the end of the run — bounded to a few
|
|
380
|
+
// MB even at the scale of #20961. That's strictly preferable
|
|
381
|
+
// to the alternative's hundreds of MB of transient peak RSS.
|
|
382
|
+
const clearCacheVisited = new WeakSet();
|
|
383
|
+
|
|
363
384
|
asyncLib.each(
|
|
364
385
|
files,
|
|
365
386
|
(file, callback) => {
|
|
@@ -458,6 +479,44 @@ class SourceMapDevToolPlugin {
|
|
|
458
479
|
originalSources
|
|
459
480
|
);
|
|
460
481
|
|
|
482
|
+
// Release the per-instance caches that `sourceAndMap`
|
|
483
|
+
// just populated. The composed map (and, for
|
|
484
|
+
// `SourceMapSource`, the parsed `_sourceMapAsObject` /
|
|
485
|
+
// `_innerSourceMapAsObject`) otherwise sit on the
|
|
486
|
+
// CachedSource — and every shared child — until phase
|
|
487
|
+
// 2 replaces the asset, which is what causes the OOM
|
|
488
|
+
// spike on builds with thousands of chunks
|
|
489
|
+
// (webpack#20961). Keep `source` since downstream
|
|
490
|
+
// consumers reading the original asset still need it;
|
|
491
|
+
// `hash`/`size` default to retained because they're
|
|
492
|
+
// cheap to keep but expensive to rebuild.
|
|
493
|
+
// `clearCacheVisited` is shared across every call (see
|
|
494
|
+
// its declaration above for the rationale).
|
|
495
|
+
//
|
|
496
|
+
// Target `task.mapSource` (not `asset.source`): when
|
|
497
|
+
// `extractSourceAndMap` falls back to the pinned
|
|
498
|
+
// original (the current asset is a `RawSource` left
|
|
499
|
+
// by an earlier plugin instance), the `sourceAndMap`
|
|
500
|
+
// call populated the original's caches, not the
|
|
501
|
+
// current asset's.
|
|
502
|
+
//
|
|
503
|
+
// Feature-detected: `clearCache` landed in
|
|
504
|
+
// `webpack-sources` 3.5, but `compilation.assets` may
|
|
505
|
+
// hold `Source`-like instances from a third-party
|
|
506
|
+
// plugin built against an older copy of
|
|
507
|
+
// `webpack-sources` (or a hand-rolled implementation).
|
|
508
|
+
// Calling it unconditionally would throw on those.
|
|
509
|
+
if (task && typeof task.mapSource.clearCache === "function") {
|
|
510
|
+
task.mapSource.clearCache(
|
|
511
|
+
{
|
|
512
|
+
maps: true,
|
|
513
|
+
source: false,
|
|
514
|
+
parsedMap: true
|
|
515
|
+
},
|
|
516
|
+
clearCacheVisited
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
|
|
461
520
|
if (task) {
|
|
462
521
|
const modules = task.modules;
|
|
463
522
|
|
|
@@ -622,10 +681,8 @@ class SourceMapDevToolPlugin {
|
|
|
622
681
|
}
|
|
623
682
|
|
|
624
683
|
const usesContentHash =
|
|
625
|
-
sourceMapFilename &&
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
resetRegexpState(CONTENT_HASH_DETECT_REGEXP);
|
|
684
|
+
typeof sourceMapFilename === "string" &&
|
|
685
|
+
getPresentKinds(sourceMapFilename).has("contenthash");
|
|
629
686
|
|
|
630
687
|
let outputFile = file;
|
|
631
688
|
// If SourceMap and asset uses contenthash, avoid a circular dependency by hiding hash in `file`
|
|
@@ -698,12 +755,23 @@ class SourceMapDevToolPlugin {
|
|
|
698
755
|
outputSourceMap.debugId = debugIdValue;
|
|
699
756
|
}
|
|
700
757
|
|
|
701
|
-
const sourceMapString = JSON.stringify(outputSourceMap);
|
|
702
758
|
if (sourceMapFilename) {
|
|
759
|
+
// External `.map` file: hold the serialized map as a
|
|
760
|
+
// `Buffer` instead of a V8 string. `RawSource` accepts
|
|
761
|
+
// a buffer directly, and the emitted asset stays in
|
|
762
|
+
// `compilation.assets` until the build finishes — so
|
|
763
|
+
// storing the bytes off the V8 heap (where Buffers
|
|
764
|
+
// live, accounted as `external` memory) avoids keeping
|
|
765
|
+
// a large V8 string alive for the rest of the build
|
|
766
|
+
// and reduces heap pressure on `--max-old-space-size`.
|
|
767
|
+
const sourceMapBuffer = Buffer.from(
|
|
768
|
+
JSON.stringify(outputSourceMap),
|
|
769
|
+
"utf8"
|
|
770
|
+
);
|
|
703
771
|
const filename = file;
|
|
704
772
|
const sourceMapContentHash = usesContentHash
|
|
705
773
|
? createHash(compilation.outputOptions.hashFunction)
|
|
706
|
-
.update(
|
|
774
|
+
.update(sourceMapBuffer)
|
|
707
775
|
.digest("hex")
|
|
708
776
|
: undefined;
|
|
709
777
|
|
|
@@ -775,7 +843,7 @@ class SourceMapDevToolPlugin {
|
|
|
775
843
|
assetsInfo[file] = assetInfo;
|
|
776
844
|
compilation.updateAsset(file, asset, assetInfo);
|
|
777
845
|
// Add source map file to compilation assets and chunk files
|
|
778
|
-
const sourceMapAsset = new RawSource(
|
|
846
|
+
const sourceMapAsset = new RawSource(sourceMapBuffer);
|
|
779
847
|
const sourceMapAssetInfo = {
|
|
780
848
|
...sourceMapInfo,
|
|
781
849
|
development: true
|
|
@@ -801,6 +869,16 @@ class SourceMapDevToolPlugin {
|
|
|
801
869
|
`${PLUGIN_NAME}: append can't be a function when no filename is provided`
|
|
802
870
|
);
|
|
803
871
|
}
|
|
872
|
+
// Inline data-URL form: `[map]` gets the raw JSON, `[url]`
|
|
873
|
+
// gets the same JSON base64-encoded. `URL_COMMENT_REGEXP`
|
|
874
|
+
// is a `/g` regex, so a user `append` template with more
|
|
875
|
+
// than one `[url]` placeholder would otherwise re-encode
|
|
876
|
+
// the same JSON per match. Pre-compute both once.
|
|
877
|
+
const sourceMapString = JSON.stringify(outputSourceMap);
|
|
878
|
+
const sourceMapBase64 = Buffer.from(
|
|
879
|
+
sourceMapString,
|
|
880
|
+
"utf8"
|
|
881
|
+
).toString("base64");
|
|
804
882
|
/**
|
|
805
883
|
* Add source map as data url to asset
|
|
806
884
|
*/
|
|
@@ -811,10 +889,7 @@ class SourceMapDevToolPlugin {
|
|
|
811
889
|
.replace(
|
|
812
890
|
URL_COMMENT_REGEXP,
|
|
813
891
|
() =>
|
|
814
|
-
`data:application/json;charset=utf-8;base64,${
|
|
815
|
-
sourceMapString,
|
|
816
|
-
"utf8"
|
|
817
|
-
).toString("base64")}`
|
|
892
|
+
`data:application/json;charset=utf-8;base64,${sourceMapBase64}`
|
|
818
893
|
)
|
|
819
894
|
);
|
|
820
895
|
assets[file] = asset;
|
package/lib/Stats.js
CHANGED
package/lib/Template.js
CHANGED
|
@@ -34,6 +34,10 @@ const NUMBER_OF_IDENTIFIER_START_CHARS = DELTA_A_TO_Z * 2 + 2; // a-z A-Z _ $
|
|
|
34
34
|
const NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
|
|
35
35
|
NUMBER_OF_IDENTIFIER_START_CHARS + 10; // a-z A-Z _ $ 0-9
|
|
36
36
|
const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g;
|
|
37
|
+
// JSDoc type annotations exist only to type the runtime template; strip them so
|
|
38
|
+
// they are never emitted into the bundle. Whole-line blocks drop the line too.
|
|
39
|
+
const JSDOC_LINE_REGEX = /^[ \t]*\/\*\*(?:[^*]|\*(?!\/))*\*\/[ \t]*\r?\n/gm;
|
|
40
|
+
const JSDOC_INLINE_REGEX = /\/\*\*(?:[^*]|\*(?!\/))*\*\/[ \t]*/g;
|
|
37
41
|
const INDENT_MULTILINE_REGEX = /^\t/gm;
|
|
38
42
|
const LINE_SEPARATOR_REGEX = /\r?\n/g;
|
|
39
43
|
const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-z$_])/i;
|
|
@@ -102,6 +106,8 @@ class Template {
|
|
|
102
106
|
static getFunctionContent(fn) {
|
|
103
107
|
return fn
|
|
104
108
|
.toString()
|
|
109
|
+
.replace(JSDOC_LINE_REGEX, "")
|
|
110
|
+
.replace(JSDOC_INLINE_REGEX, "")
|
|
105
111
|
.replace(FUNCTION_CONTENT_REGEX, "")
|
|
106
112
|
.replace(INDENT_MULTILINE_REGEX, "")
|
|
107
113
|
.replace(LINE_SEPARATOR_REGEX, "\n");
|
|
@@ -126,7 +132,7 @@ class Template {
|
|
|
126
132
|
*/
|
|
127
133
|
static toComment(str) {
|
|
128
134
|
if (!str) return "";
|
|
129
|
-
return `/*! ${str.replace(COMMENT_END_REGEX, "* /")} */`;
|
|
135
|
+
return `/*! ${str.includes("*/") ? str.replace(COMMENT_END_REGEX, "* /") : str} */`;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
/**
|
|
@@ -136,7 +142,7 @@ class Template {
|
|
|
136
142
|
*/
|
|
137
143
|
static toNormalComment(str) {
|
|
138
144
|
if (!str) return "";
|
|
139
|
-
return `/* ${str.replace(COMMENT_END_REGEX, "* /")} */`;
|
|
145
|
+
return `/* ${str.includes("*/") ? str.replace(COMMENT_END_REGEX, "* /") : str} */`;
|
|
140
146
|
}
|
|
141
147
|
|
|
142
148
|
/**
|