webpack 5.107.2 → 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 +25 -11
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- 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 +2 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +142 -80
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +8 -0
- 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 +3 -5
- 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 +64 -7
- 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/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 +18 -15
- 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} +261 -109
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +17 -13
- package/lib/dependencies/HtmlInlineStyleDependency.js +45 -11
- 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 +22 -6
- 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 +30 -6
- package/lib/html/HtmlGenerator.js +217 -23
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +219 -55
- 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 +285 -158
- 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 +24 -5
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +1 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +395 -77
- 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 +10 -5
- 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 +35 -27
- 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 +1456 -290
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
|
@@ -39,7 +39,11 @@ const { compareModulesByFullName } = require("../util/comparators");
|
|
|
39
39
|
const createHash = require("../util/createHash");
|
|
40
40
|
const { getUndoPath } = require("../util/identifier");
|
|
41
41
|
const memoize = require("../util/memoize");
|
|
42
|
-
const
|
|
42
|
+
const { digestNonNumericOnlyWithFull } = require("../util/nonNumericOnlyHash");
|
|
43
|
+
const {
|
|
44
|
+
PUBLIC_PATH_AUTO,
|
|
45
|
+
walkFullHashPlaceholders
|
|
46
|
+
} = require("../util/publicPathPlaceholder");
|
|
43
47
|
const removeBOM = require("../util/removeBOM");
|
|
44
48
|
const CssGenerator = require("./CssGenerator");
|
|
45
49
|
const CssModule = require("./CssModule");
|
|
@@ -56,6 +60,7 @@ const CssParser = require("./CssParser");
|
|
|
56
60
|
/** @typedef {import("./CssModule").CssModuleCreateData} CssModuleCreateData */
|
|
57
61
|
/** @typedef {import("../Module")} Module */
|
|
58
62
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
63
|
+
/** @typedef {import("./CssModule").CssModuleBuildInfo} CssModuleBuildInfo */
|
|
59
64
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
60
65
|
/** @typedef {import("../Template").RuntimeTemplate} RuntimeTemplate */
|
|
61
66
|
/** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
|
|
@@ -112,6 +117,45 @@ const getCssInjectStyleRuntimeModule = memoize(() =>
|
|
|
112
117
|
require("./CssInjectStyleRuntimeModule")
|
|
113
118
|
);
|
|
114
119
|
|
|
120
|
+
/**
|
|
121
|
+
* @typedef {object} PublicPathPlaceholderPlan
|
|
122
|
+
* @property {number[]} autos start offsets of each `PUBLIC_PATH_AUTO` placeholder
|
|
123
|
+
* @property {{ start: number, end: number, length: number }[]} hashes `[start, end)` ranges of each `PUBLIC_PATH_FULL_HASH` placeholder and its requested hash length
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Public-path placeholder offsets are invariant for a given module source —
|
|
128
|
+
* they don't depend on `undoPath`/`hash`/`inheritance`/runtime — so scan once
|
|
129
|
+
* and reuse across renders instead of re-materializing and re-scanning the
|
|
130
|
+
* source on every cache miss. Weakly keyed so entries release with the source.
|
|
131
|
+
* @type {WeakMap<Source, PublicPathPlaceholderPlan>}
|
|
132
|
+
*/
|
|
133
|
+
const publicPathPlaceholderPlans = new WeakMap();
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Locate the public-path placeholders in a materialized module source.
|
|
137
|
+
* @param {string} content materialized module source
|
|
138
|
+
* @returns {PublicPathPlaceholderPlan} placeholder offsets
|
|
139
|
+
*/
|
|
140
|
+
const computePublicPathPlaceholderPlan = (content) => {
|
|
141
|
+
/** @type {number[]} */
|
|
142
|
+
const autos = [];
|
|
143
|
+
const autoLen = PUBLIC_PATH_AUTO.length;
|
|
144
|
+
for (
|
|
145
|
+
let idx = content.indexOf(PUBLIC_PATH_AUTO);
|
|
146
|
+
idx !== -1;
|
|
147
|
+
idx = content.indexOf(PUBLIC_PATH_AUTO, idx + autoLen)
|
|
148
|
+
) {
|
|
149
|
+
autos.push(idx);
|
|
150
|
+
}
|
|
151
|
+
/** @type {{ start: number, end: number, length: number }[]} */
|
|
152
|
+
const hashes = [];
|
|
153
|
+
walkFullHashPlaceholders(content, (start, end, length) => {
|
|
154
|
+
hashes.push({ start, end, length });
|
|
155
|
+
});
|
|
156
|
+
return { autos, hashes };
|
|
157
|
+
};
|
|
158
|
+
|
|
115
159
|
/**
|
|
116
160
|
* Returns ], definitions: import("../../schemas/WebpackOptions.json")["definitions"] }} schema.
|
|
117
161
|
* @param {string} name name
|
|
@@ -361,67 +405,24 @@ class CssModulesPlugin {
|
|
|
361
405
|
const exportType =
|
|
362
406
|
/** @type {CssParser} */
|
|
363
407
|
(createData.parser).options.exportType;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
if (!inheritance) {
|
|
383
|
-
inheritance = [];
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
inheritance.push([
|
|
387
|
-
parent.cssLayer,
|
|
388
|
-
parent.supports,
|
|
389
|
-
parent.media
|
|
390
|
-
]);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (parent.inheritance) {
|
|
394
|
-
if (!inheritance) {
|
|
395
|
-
inheritance = [];
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
inheritance.push(...parent.inheritance);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return new CssModule(
|
|
402
|
-
/** @type {CssModuleCreateData} */
|
|
403
|
-
({
|
|
404
|
-
...createData,
|
|
405
|
-
cssLayer: dependency.layer,
|
|
406
|
-
supports: dependency.supports,
|
|
407
|
-
media: dependency.media,
|
|
408
|
-
inheritance,
|
|
409
|
-
exportType: parent.exportType || exportType
|
|
410
|
-
})
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
return new CssModule(
|
|
415
|
-
/** @type {CssModuleCreateData} */
|
|
416
|
-
({
|
|
417
|
-
...createData,
|
|
418
|
-
cssLayer: dependency.layer,
|
|
419
|
-
supports: dependency.supports,
|
|
420
|
-
media: dependency.media,
|
|
421
|
-
exportType
|
|
422
|
-
})
|
|
423
|
-
);
|
|
424
|
-
}
|
|
408
|
+
// When CSS is imported from CSS there is only one dependency
|
|
409
|
+
const dependency =
|
|
410
|
+
resolveData.dependencies.length > 0
|
|
411
|
+
? resolveData.dependencies[0]
|
|
412
|
+
: undefined;
|
|
413
|
+
|
|
414
|
+
if (dependency instanceof CssImportDependency) {
|
|
415
|
+
return new CssModule(
|
|
416
|
+
/** @type {CssModuleCreateData} */
|
|
417
|
+
({
|
|
418
|
+
...createData,
|
|
419
|
+
cssLayer: dependency.layer,
|
|
420
|
+
supports: dependency.supports,
|
|
421
|
+
media: dependency.media,
|
|
422
|
+
inheritance: dependency.inheritance,
|
|
423
|
+
exportType: dependency.exportType || exportType
|
|
424
|
+
})
|
|
425
|
+
);
|
|
425
426
|
}
|
|
426
427
|
|
|
427
428
|
return new CssModule(
|
|
@@ -451,7 +452,7 @@ class CssModulesPlugin {
|
|
|
451
452
|
|
|
452
453
|
JavascriptModulesPlugin.getCompilationHooks(
|
|
453
454
|
compilation
|
|
454
|
-
).renderModuleContent.tap(PLUGIN_NAME, (source, module) => {
|
|
455
|
+
).renderModuleContent.tap(PLUGIN_NAME, (source, module, ctx) => {
|
|
455
456
|
const injectCssStylesVar =
|
|
456
457
|
module instanceof ConcatenatedModule &&
|
|
457
458
|
module.modules.find(
|
|
@@ -481,8 +482,9 @@ class CssModulesPlugin {
|
|
|
481
482
|
// When exportType !== "link", modules behave like JavaScript modules
|
|
482
483
|
if (["link", "style"].includes(exportType)) {
|
|
483
484
|
// For exportType === "link", we can optimize with self-acceptance
|
|
484
|
-
const cssData = /** @type {
|
|
485
|
-
.
|
|
485
|
+
const cssData = /** @type {CssModuleBuildInfo} */ (
|
|
486
|
+
module.buildInfo
|
|
487
|
+
).cssData;
|
|
486
488
|
if (!cssData) {
|
|
487
489
|
return source;
|
|
488
490
|
}
|
|
@@ -500,7 +502,7 @@ class CssModulesPlugin {
|
|
|
500
502
|
"",
|
|
501
503
|
`var __webpack_css_exports__ = ${stringifiedExports};`,
|
|
502
504
|
"// only invalidate when locals change",
|
|
503
|
-
|
|
505
|
+
`if (${ctx.runtimeTemplate.optionalChaining("module.hot.data", "__webpack_css_exports__")} && module.hot.data.__webpack_css_exports__ != __webpack_css_exports__) {`,
|
|
504
506
|
Template.indent("module.hot.invalidate();"),
|
|
505
507
|
"} else {",
|
|
506
508
|
Template.indent("module.hot.accept();"),
|
|
@@ -571,8 +573,8 @@ class CssModulesPlugin {
|
|
|
571
573
|
hash.update(chunkGraph.getModuleHash(module, chunk.runtime));
|
|
572
574
|
}
|
|
573
575
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
+
[chunk.contentHash.css, chunk.contentHashFull.css] =
|
|
577
|
+
digestNonNumericOnlyWithFull(hash, hashDigest, hashDigestLength);
|
|
576
578
|
});
|
|
577
579
|
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
|
|
578
580
|
const { chunkGraph } = compilation;
|
|
@@ -900,18 +902,20 @@ class CssModulesPlugin {
|
|
|
900
902
|
)
|
|
901
903
|
).map((module) => {
|
|
902
904
|
if (
|
|
903
|
-
typeof (
|
|
904
|
-
|
|
905
|
+
typeof (
|
|
906
|
+
/** @type {CssModuleBuildInfo} */ (module.buildInfo).charset
|
|
907
|
+
) !== "undefined"
|
|
905
908
|
) {
|
|
906
909
|
if (
|
|
907
910
|
typeof charset !== "undefined" &&
|
|
908
|
-
charset !==
|
|
911
|
+
charset !==
|
|
912
|
+
/** @type {CssModuleBuildInfo} */ (module.buildInfo).charset
|
|
909
913
|
) {
|
|
910
914
|
const err = new WebpackError(
|
|
911
915
|
`Conflicting @charset at-rules detected: the module ${module.readableIdentifier(
|
|
912
916
|
compilation.requestShortener
|
|
913
917
|
)} (in chunk ${chunk.name || chunk.id}) specifies "${
|
|
914
|
-
/** @type {
|
|
918
|
+
/** @type {CssModuleBuildInfo} */ (module.buildInfo).charset
|
|
915
919
|
}", but "${charset}" was expected, all modules must use the same character set`
|
|
916
920
|
);
|
|
917
921
|
|
|
@@ -923,7 +927,8 @@ class CssModulesPlugin {
|
|
|
923
927
|
}
|
|
924
928
|
|
|
925
929
|
if (typeof charset === "undefined") {
|
|
926
|
-
charset = /** @type {
|
|
930
|
+
charset = /** @type {CssModuleBuildInfo} */ (module.buildInfo)
|
|
931
|
+
.charset;
|
|
927
932
|
}
|
|
928
933
|
}
|
|
929
934
|
|
|
@@ -968,63 +973,40 @@ class CssModulesPlugin {
|
|
|
968
973
|
source = cacheEntry.source;
|
|
969
974
|
} else {
|
|
970
975
|
if (!moduleSourceContent) return null;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
(
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const autoPlaceholderLen = autoPlaceholder.length;
|
|
978
|
-
for (
|
|
979
|
-
let idx = moduleSourceCode.indexOf(autoPlaceholder);
|
|
980
|
-
idx !== -1;
|
|
981
|
-
idx = moduleSourceCode.indexOf(
|
|
982
|
-
autoPlaceholder,
|
|
983
|
-
idx + autoPlaceholderLen
|
|
984
|
-
)
|
|
985
|
-
) {
|
|
986
|
-
replaceSource.replace(idx, idx + autoPlaceholderLen - 1, undoPath);
|
|
976
|
+
let plan = publicPathPlaceholderPlans.get(moduleSourceContent);
|
|
977
|
+
if (plan === undefined) {
|
|
978
|
+
plan = computePublicPathPlaceholderPlan(
|
|
979
|
+
/** @type {string} */ (moduleSourceContent.source())
|
|
980
|
+
);
|
|
981
|
+
publicPathPlaceholderPlans.set(moduleSourceContent, plan);
|
|
987
982
|
}
|
|
988
983
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
moduleSourceCode.charCodeAt(digitEnd) === 95 &&
|
|
1006
|
-
moduleSourceCode.charCodeAt(digitEnd + 1) === 95
|
|
1007
|
-
) {
|
|
1008
|
-
const length = Number.parseInt(
|
|
1009
|
-
moduleSourceCode.slice(idx + hashPrefixLen, digitEnd),
|
|
1010
|
-
10
|
|
1011
|
-
);
|
|
984
|
+
/** @type {Source} */
|
|
985
|
+
let moduleSource = moduleSourceContent;
|
|
986
|
+
|
|
987
|
+
// Apply placeholder substitutions only when present; the common
|
|
988
|
+
// (no-placeholder) case skips the ReplaceSource wrapper entirely.
|
|
989
|
+
if (plan.autos.length > 0 || (hash && plan.hashes.length > 0)) {
|
|
990
|
+
const replaceSource = new ReplaceSource(moduleSourceContent);
|
|
991
|
+
const autoLen = PUBLIC_PATH_AUTO.length;
|
|
992
|
+
for (let i = 0; i < plan.autos.length; i++) {
|
|
993
|
+
const start = plan.autos[i];
|
|
994
|
+
replaceSource.replace(start, start + autoLen - 1, undoPath);
|
|
995
|
+
}
|
|
996
|
+
if (hash) {
|
|
997
|
+
for (let i = 0; i < plan.hashes.length; i++) {
|
|
998
|
+
const { start, end, length } = plan.hashes[i];
|
|
999
|
+
// `end` is exclusive; ReplaceSource.replace takes an inclusive end.
|
|
1012
1000
|
replaceSource.replace(
|
|
1013
|
-
|
|
1014
|
-
|
|
1001
|
+
start,
|
|
1002
|
+
end - 1,
|
|
1015
1003
|
length === 0 ? hash : hash.slice(0, length)
|
|
1016
1004
|
);
|
|
1017
|
-
nextSearch = digitEnd + 2;
|
|
1018
|
-
} else {
|
|
1019
|
-
nextSearch = idx + hashPrefixLen;
|
|
1020
1005
|
}
|
|
1021
|
-
idx = moduleSourceCode.indexOf(hashPrefix, nextSearch);
|
|
1022
1006
|
}
|
|
1007
|
+
moduleSource = replaceSource;
|
|
1023
1008
|
}
|
|
1024
1009
|
|
|
1025
|
-
/** @type {Source} */
|
|
1026
|
-
let moduleSource = replaceSource;
|
|
1027
|
-
|
|
1028
1010
|
for (let i = 0; i < inheritance.length; i++) {
|
|
1029
1011
|
const layer = inheritance[i][0];
|
|
1030
1012
|
const supports = inheritance[i][1];
|
|
@@ -1100,11 +1082,12 @@ class CssModulesPlugin {
|
|
|
1100
1082
|
|
|
1101
1083
|
for (const module of modules) {
|
|
1102
1084
|
if (
|
|
1103
|
-
typeof (
|
|
1104
|
-
|
|
1085
|
+
typeof (
|
|
1086
|
+
/** @type {CssModuleBuildInfo} */ (module.buildInfo).charset
|
|
1087
|
+
) !== "undefined" &&
|
|
1105
1088
|
typeof charset === "undefined"
|
|
1106
1089
|
) {
|
|
1107
|
-
charset = /** @type {
|
|
1090
|
+
charset = /** @type {CssModuleBuildInfo} */ (module.buildInfo).charset;
|
|
1108
1091
|
}
|
|
1109
1092
|
|
|
1110
1093
|
try {
|