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
package/hot/dev-server.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Author Tobias Koppers @sokra
|
|
4
4
|
*/
|
|
5
5
|
/* globals __webpack_hash__ */
|
|
6
|
+
// Universal regular-HMR client (web + Node): runs `module.hot.check` whenever a
|
|
7
|
+
// `webpackHotUpdate` signal arrives on ./emitter (pushed by the dev-server).
|
|
6
8
|
if (module.hot) {
|
|
7
9
|
/** @type {undefined|string} */
|
|
8
10
|
var lastHash;
|
package/lib/APIPlugin.js
CHANGED
|
@@ -30,6 +30,7 @@ const GetFullHashRuntimeModule = require("./runtime/GetFullHashRuntimeModule");
|
|
|
30
30
|
/** @typedef {import("./Compiler")} Compiler */
|
|
31
31
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
32
32
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
33
|
+
/** @typedef {import("./javascript/JavascriptModule").JavascriptModuleBuildInfo} JavascriptModuleBuildInfo */
|
|
33
34
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
34
35
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
35
36
|
|
|
@@ -190,7 +191,10 @@ class APIPlugin {
|
|
|
190
191
|
hooks.renderModuleContent.tap(
|
|
191
192
|
PLUGIN_NAME,
|
|
192
193
|
(source, module, renderContext) => {
|
|
193
|
-
if (
|
|
194
|
+
if (
|
|
195
|
+
/** @type {JavascriptModuleBuildInfo} */ (module.buildInfo)
|
|
196
|
+
.needCreateRequire
|
|
197
|
+
) {
|
|
194
198
|
const chunkInitFragments = [
|
|
195
199
|
getExternalModuleNodeCommonjsInitFragment(
|
|
196
200
|
renderContext.runtimeTemplate
|
|
@@ -250,7 +254,7 @@ class APIPlugin {
|
|
|
250
254
|
|
|
251
255
|
if (key === "__non_webpack_require__" && moduleOutput) {
|
|
252
256
|
if (nodeTarget) {
|
|
253
|
-
/** @type {
|
|
257
|
+
/** @type {JavascriptModuleBuildInfo} */
|
|
254
258
|
(parser.state.module.buildInfo).needCreateRequire = true;
|
|
255
259
|
} else {
|
|
256
260
|
const warning = new WebpackError(
|
|
@@ -314,7 +318,7 @@ class APIPlugin {
|
|
|
314
318
|
parser.hooks.expression
|
|
315
319
|
.for("__webpack_module__.id")
|
|
316
320
|
.tap(PLUGIN_NAME, (expr) => {
|
|
317
|
-
/** @type {
|
|
321
|
+
/** @type {JavascriptModuleBuildInfo} */
|
|
318
322
|
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
319
323
|
"__webpack_module__.id";
|
|
320
324
|
const moduleArgument = parser.state.module.moduleArgument;
|
|
@@ -345,7 +349,7 @@ class APIPlugin {
|
|
|
345
349
|
parser.hooks.expression
|
|
346
350
|
.for("__webpack_module__")
|
|
347
351
|
.tap(PLUGIN_NAME, (expr) => {
|
|
348
|
-
/** @type {
|
|
352
|
+
/** @type {JavascriptModuleBuildInfo} */
|
|
349
353
|
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
350
354
|
"__webpack_module__";
|
|
351
355
|
const moduleArgument = parser.state.module.moduleArgument;
|
package/lib/CacheFacade.js
CHANGED
|
@@ -39,6 +39,7 @@ class MultiItemCache {
|
|
|
39
39
|
* @param {ItemCacheFacade[]} items item caches
|
|
40
40
|
*/
|
|
41
41
|
constructor(items) {
|
|
42
|
+
/** @type {ItemCacheFacade[]} */
|
|
42
43
|
this._items = items;
|
|
43
44
|
// @ts-expect-error expected - returns the single ItemCacheFacade when passed an array of length 1
|
|
44
45
|
// eslint-disable-next-line no-constructor-return
|
|
@@ -110,8 +111,11 @@ class ItemCacheFacade {
|
|
|
110
111
|
* @param {Etag | null} etag the etag
|
|
111
112
|
*/
|
|
112
113
|
constructor(cache, name, etag) {
|
|
114
|
+
/** @type {Cache} */
|
|
113
115
|
this._cache = cache;
|
|
116
|
+
/** @type {string} */
|
|
114
117
|
this._name = name;
|
|
118
|
+
/** @type {Etag | null} */
|
|
115
119
|
this._etag = etag;
|
|
116
120
|
}
|
|
117
121
|
|
|
@@ -215,8 +219,11 @@ class CacheFacade {
|
|
|
215
219
|
* @param {HashFunction=} hashFunction the hash function to use
|
|
216
220
|
*/
|
|
217
221
|
constructor(cache, name, hashFunction) {
|
|
222
|
+
/** @type {Cache} */
|
|
218
223
|
this._cache = cache;
|
|
224
|
+
/** @type {string} */
|
|
219
225
|
this._name = name;
|
|
226
|
+
/** @type {HashFunction | undefined} */
|
|
220
227
|
this._hashFunction = hashFunction;
|
|
221
228
|
}
|
|
222
229
|
|
package/lib/Chunk.js
CHANGED
|
@@ -121,6 +121,10 @@ class Chunk {
|
|
|
121
121
|
this.hash = undefined;
|
|
122
122
|
/** @type {Record<string, string>} */
|
|
123
123
|
this.contentHash = Object.create(null);
|
|
124
|
+
// Full (untruncated) content digests, so `[contenthash:<digest>]` re-encodes
|
|
125
|
+
// from full entropy. Transient: repopulated by the `contentHash` hook each seal.
|
|
126
|
+
/** @type {Record<string, string>} */
|
|
127
|
+
this.contentHashFull = Object.create(null);
|
|
124
128
|
/** @type {string=} */
|
|
125
129
|
this.renderedHash = undefined;
|
|
126
130
|
/** @type {string=} */
|
package/lib/ChunkGraph.js
CHANGED
|
@@ -45,6 +45,7 @@ const {
|
|
|
45
45
|
/** @typedef {import("./RuntimeModule")} RuntimeModule */
|
|
46
46
|
/** @typedef {import("./util/Hash").HashFunction} HashFunction */
|
|
47
47
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
48
|
+
/** @typedef {import("./javascript/JavascriptModule").JavascriptModuleBuildMeta} JavascriptModuleBuildMeta */
|
|
48
49
|
|
|
49
50
|
/** @type {ReadonlySet<string>} */
|
|
50
51
|
const EMPTY_SET = new Set();
|
|
@@ -304,9 +305,17 @@ class ChunkGraph {
|
|
|
304
305
|
* @type {Map<string, RuntimeId>}
|
|
305
306
|
*/
|
|
306
307
|
this._runtimeIds = new Map();
|
|
308
|
+
/**
|
|
309
|
+
* Module runtime requirement Sets stored without copying (ownership not
|
|
310
|
+
* transferred). They must be copied before being mutated.
|
|
311
|
+
* @private
|
|
312
|
+
* @type {WeakSet<RuntimeRequirements>}
|
|
313
|
+
*/
|
|
314
|
+
this._sharedModuleRuntimeRequirements = new WeakSet();
|
|
307
315
|
/** @type {ModuleGraph} */
|
|
308
316
|
this.moduleGraph = moduleGraph;
|
|
309
317
|
|
|
318
|
+
/** @type {HashFunction} */
|
|
310
319
|
this._hashFunction = hashFunction;
|
|
311
320
|
|
|
312
321
|
this._getGraphRoots = this._getGraphRoots.bind(this);
|
|
@@ -1661,24 +1670,33 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1661
1670
|
) {
|
|
1662
1671
|
const cgm = this._getChunkGraphModule(module);
|
|
1663
1672
|
const runtimeRequirementsMap = cgm.runtimeRequirements;
|
|
1673
|
+
if (!transferOwnership) this._sharedModuleRuntimeRequirements.add(items);
|
|
1664
1674
|
if (runtimeRequirementsMap === undefined) {
|
|
1665
1675
|
/** @type {ChunkGraphRuntimeRequirements} */
|
|
1666
1676
|
const map = new RuntimeSpecMap();
|
|
1667
|
-
|
|
1668
|
-
map.set(runtime, transferOwnership ? items : new Set(items));
|
|
1677
|
+
map.set(runtime, items);
|
|
1669
1678
|
cgm.runtimeRequirements = map;
|
|
1670
1679
|
return;
|
|
1671
1680
|
}
|
|
1672
1681
|
runtimeRequirementsMap.update(runtime, (runtimeRequirements) => {
|
|
1673
|
-
if (runtimeRequirements === undefined)
|
|
1674
|
-
|
|
1675
|
-
|
|
1682
|
+
if (runtimeRequirements === undefined) return items;
|
|
1683
|
+
const owned =
|
|
1684
|
+
!this._sharedModuleRuntimeRequirements.has(runtimeRequirements);
|
|
1685
|
+
// Merge into whichever owned Set is larger; otherwise copy-on-write.
|
|
1686
|
+
if (owned && runtimeRequirements.size >= items.size) {
|
|
1687
|
+
for (const item of items) runtimeRequirements.add(item);
|
|
1688
|
+
return runtimeRequirements;
|
|
1689
|
+
} else if (transferOwnership) {
|
|
1690
|
+
for (const item of runtimeRequirements) items.add(item);
|
|
1691
|
+
this._sharedModuleRuntimeRequirements.delete(items);
|
|
1692
|
+
return items;
|
|
1693
|
+
} else if (owned) {
|
|
1676
1694
|
for (const item of items) runtimeRequirements.add(item);
|
|
1677
1695
|
return runtimeRequirements;
|
|
1678
1696
|
}
|
|
1679
|
-
|
|
1680
|
-
for (const item of
|
|
1681
|
-
return
|
|
1697
|
+
const merged = new Set(runtimeRequirements);
|
|
1698
|
+
for (const item of items) merged.add(item);
|
|
1699
|
+
return merged;
|
|
1682
1700
|
});
|
|
1683
1701
|
}
|
|
1684
1702
|
|
|
@@ -1814,7 +1832,10 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
1814
1832
|
if (state === ModuleGraphConnection.TRANSITIVE_ONLY) return "O";
|
|
1815
1833
|
throw new Error("Not implemented active state");
|
|
1816
1834
|
};
|
|
1817
|
-
const strict =
|
|
1835
|
+
const strict =
|
|
1836
|
+
module.buildMeta &&
|
|
1837
|
+
/** @type {JavascriptModuleBuildMeta} */ (module.buildMeta)
|
|
1838
|
+
.strictHarmonyModule;
|
|
1818
1839
|
return cgm.graphHashesWithConnections.provide(runtime, () => {
|
|
1819
1840
|
const graphHash = this._getModuleGraphHashBigInt(
|
|
1820
1841
|
cgm,
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Natsu @xiaoxiaojx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/** @typedef {import("./Compiler")} Compiler */
|
|
9
|
+
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
10
|
+
/** @typedef {import("./Module")} Module */
|
|
11
|
+
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
12
|
+
|
|
13
|
+
const PLUGIN_NAME = "CircularModulesPlugin";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Detects circular dependencies among synchronous module imports.
|
|
17
|
+
*
|
|
18
|
+
* Builds an adjacency layout from each module's synchronous outgoing
|
|
19
|
+
* connections (skipping weak and async-block edges), then runs an iterative
|
|
20
|
+
* SCC algorithm to find circular modules.
|
|
21
|
+
*
|
|
22
|
+
* Use the static `build()` method to create an instance. All intermediate data
|
|
23
|
+
* (adjacency layout, index mappings) is local to `build()` and released on
|
|
24
|
+
* return. The instance only holds the result.
|
|
25
|
+
*/
|
|
26
|
+
class CycleGraph {
|
|
27
|
+
/**
|
|
28
|
+
* @param {Set<Module>} circularModules modules involved in circular dependencies
|
|
29
|
+
*/
|
|
30
|
+
constructor(circularModules) {
|
|
31
|
+
/** @type {Set<Module>} */
|
|
32
|
+
this.circularModules = circularModules;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Builds a CycleGraph by constructing the synchronous outgoing-connection
|
|
37
|
+
* adjacency list and running iterative SCC to detect circular modules.
|
|
38
|
+
* @param {Iterable<Module>} modules the set of modules
|
|
39
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
40
|
+
* @returns {CycleGraph} the result
|
|
41
|
+
*/
|
|
42
|
+
static build(modules, moduleGraph) {
|
|
43
|
+
/** @type {Module[]} */
|
|
44
|
+
const moduleList = [];
|
|
45
|
+
/** @type {Map<Module, number>} */
|
|
46
|
+
const moduleToIndex = new Map();
|
|
47
|
+
for (const module of modules) {
|
|
48
|
+
moduleToIndex.set(module, moduleList.length);
|
|
49
|
+
moduleList.push(module);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const size = moduleList.length;
|
|
53
|
+
if (size === 0) return new CycleGraph(new Set());
|
|
54
|
+
|
|
55
|
+
/** @type {number[][]} */
|
|
56
|
+
const edges = Array.from({ length: size });
|
|
57
|
+
/** @type {boolean[]} */
|
|
58
|
+
const selfLoops = Array.from({ length: size }, () => false);
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < size; i++) {
|
|
61
|
+
const module = moduleList[i];
|
|
62
|
+
/** @type {number[]} */
|
|
63
|
+
const deps = [];
|
|
64
|
+
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
|
65
|
+
const dep = connection.dependency;
|
|
66
|
+
if (!dep) continue;
|
|
67
|
+
const target = connection.module;
|
|
68
|
+
if (!target) continue;
|
|
69
|
+
// Weak references don't synchronously evaluate the target.
|
|
70
|
+
if (connection.weak) continue;
|
|
71
|
+
// Async edges (dynamic import & friends) live in AsyncDependenciesBlock,
|
|
72
|
+
// so a synchronous dep's parent block is the module itself.
|
|
73
|
+
if (moduleGraph.getParentBlock(dep) !== module) continue;
|
|
74
|
+
if (target === module) {
|
|
75
|
+
selfLoops[i] = true;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const targetIdx = moduleToIndex.get(target);
|
|
79
|
+
if (targetIdx !== undefined) {
|
|
80
|
+
deps.push(targetIdx);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
edges[i] = deps;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Iterative SCC algorithm
|
|
87
|
+
/** @type {Set<Module>} */
|
|
88
|
+
const circular = new Set();
|
|
89
|
+
let nextIndex = 0;
|
|
90
|
+
const nodeIndex = new Int32Array(size).fill(-1);
|
|
91
|
+
const nodeLowLink = new Int32Array(size);
|
|
92
|
+
const nodeOnStack = new Uint8Array(size);
|
|
93
|
+
/** @type {number[]} */
|
|
94
|
+
const sccStack = [];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {object} Frame
|
|
98
|
+
* @property {number} node
|
|
99
|
+
* @property {number} edgeIdx
|
|
100
|
+
* @property {number} parent
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
for (let root = 0; root < size; root++) {
|
|
104
|
+
if (nodeIndex[root] !== -1) continue;
|
|
105
|
+
|
|
106
|
+
nodeIndex[root] = nextIndex;
|
|
107
|
+
nodeLowLink[root] = nextIndex;
|
|
108
|
+
nextIndex++;
|
|
109
|
+
nodeOnStack[root] = 1;
|
|
110
|
+
sccStack.push(root);
|
|
111
|
+
|
|
112
|
+
/** @type {Frame[]} */
|
|
113
|
+
const callStack = [{ node: root, edgeIdx: 0, parent: -1 }];
|
|
114
|
+
|
|
115
|
+
while (callStack.length > 0) {
|
|
116
|
+
const frame = /** @type {Frame} */ (callStack[callStack.length - 1]);
|
|
117
|
+
const v = frame.node;
|
|
118
|
+
const vEdges = edges[v];
|
|
119
|
+
|
|
120
|
+
if (frame.edgeIdx < vEdges.length) {
|
|
121
|
+
const w = vEdges[frame.edgeIdx++];
|
|
122
|
+
if (nodeIndex[w] === -1) {
|
|
123
|
+
nodeIndex[w] = nextIndex;
|
|
124
|
+
nodeLowLink[w] = nextIndex;
|
|
125
|
+
nextIndex++;
|
|
126
|
+
nodeOnStack[w] = 1;
|
|
127
|
+
sccStack.push(w);
|
|
128
|
+
callStack.push({ node: w, edgeIdx: 0, parent: v });
|
|
129
|
+
} else if (nodeOnStack[w] && nodeIndex[w] < nodeLowLink[v]) {
|
|
130
|
+
nodeLowLink[v] = nodeIndex[w];
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
if (nodeLowLink[v] === nodeIndex[v]) {
|
|
134
|
+
/** @type {number[]} */
|
|
135
|
+
const component = [];
|
|
136
|
+
let w;
|
|
137
|
+
do {
|
|
138
|
+
w = /** @type {number} */ (sccStack.pop());
|
|
139
|
+
nodeOnStack[w] = 0;
|
|
140
|
+
component.push(w);
|
|
141
|
+
} while (w !== v);
|
|
142
|
+
|
|
143
|
+
if (component.length > 1 || selfLoops[v]) {
|
|
144
|
+
for (const idx of component) {
|
|
145
|
+
circular.add(moduleList[idx]);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
callStack.pop();
|
|
151
|
+
if (
|
|
152
|
+
frame.parent !== -1 &&
|
|
153
|
+
nodeLowLink[v] < nodeLowLink[frame.parent]
|
|
154
|
+
) {
|
|
155
|
+
nodeLowLink[frame.parent] = nodeLowLink[v];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return new CycleGraph(circular);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Detects circular dependencies and marks each circular module
|
|
167
|
+
* via buildInfo.isCircular for downstream consumers.
|
|
168
|
+
*/
|
|
169
|
+
class CircularModulesPlugin {
|
|
170
|
+
/**
|
|
171
|
+
* @param {Compiler} compiler the compiler instance
|
|
172
|
+
* @returns {void}
|
|
173
|
+
*/
|
|
174
|
+
apply(compiler) {
|
|
175
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
176
|
+
compilation.hooks.optimizeModules.tap(PLUGIN_NAME, (modules) => {
|
|
177
|
+
const { circularModules } = CycleGraph.build(
|
|
178
|
+
modules,
|
|
179
|
+
compilation.moduleGraph
|
|
180
|
+
);
|
|
181
|
+
for (const m of modules) {
|
|
182
|
+
/** @type {BuildInfo} */
|
|
183
|
+
(m.buildInfo).isCircular = circularModules.has(m);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
module.exports = CircularModulesPlugin;
|
package/lib/CleanPlugin.js
CHANGED
|
@@ -10,6 +10,7 @@ const asyncLib = require("neo-async");
|
|
|
10
10
|
const { SyncBailHook } = require("tapable");
|
|
11
11
|
const Compilation = require("./Compilation");
|
|
12
12
|
const { join } = require("./util/fs");
|
|
13
|
+
const { ABSOLUTE_PATH_REGEXP } = require("./util/identifier");
|
|
13
14
|
const processAsyncTree = require("./util/processAsyncTree");
|
|
14
15
|
|
|
15
16
|
/** @typedef {import("../declarations/WebpackOptions").CleanOptions} CleanOptions */
|
|
@@ -433,7 +434,7 @@ class CleanPlugin {
|
|
|
433
434
|
const currentAssets = new Map();
|
|
434
435
|
const now = Date.now();
|
|
435
436
|
for (const asset of Object.keys(compilation.assets)) {
|
|
436
|
-
if (
|
|
437
|
+
if (ABSOLUTE_PATH_REGEXP.test(asset)) continue;
|
|
437
438
|
/** @type {string} */
|
|
438
439
|
let normalizedAsset;
|
|
439
440
|
let newNormalizedAsset = asset.replace(/\\/g, "/");
|