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
package/lib/ExternalModule.js
CHANGED
|
@@ -65,8 +65,8 @@ const { register } = require("./util/serialization");
|
|
|
65
65
|
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
66
66
|
/** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
67
67
|
/** @typedef {import("./dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
|
|
68
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
69
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
68
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext<[ExternalModuleRequest, ExternalsType, string, DependencyMeta | undefined]>} ObjectDeserializerContext */
|
|
69
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext<[ExternalModuleRequest, ExternalsType, string, DependencyMeta | undefined]>} ObjectSerializerContext */
|
|
70
70
|
/** @typedef {import("./util/Hash")} Hash */
|
|
71
71
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
72
72
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -148,18 +148,36 @@ const getSourceForCommonJsExternal = (moduleAndSpecifiers) => {
|
|
|
148
148
|
/**
|
|
149
149
|
* Gets external module node commonjs init fragment.
|
|
150
150
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
|
151
|
+
* @param {boolean=} universal target may also run outside node (e.g. `["node", "web"]`)
|
|
151
152
|
* @returns {InitFragment<ChunkRenderContext>} code
|
|
152
153
|
*/
|
|
153
|
-
const getExternalModuleNodeCommonjsInitFragment = (
|
|
154
|
+
const getExternalModuleNodeCommonjsInitFragment = (
|
|
155
|
+
runtimeTemplate,
|
|
156
|
+
universal = false
|
|
157
|
+
) => {
|
|
154
158
|
const importMetaName = runtimeTemplate.outputOptions.importMetaName;
|
|
159
|
+
const moduleId = runtimeTemplate.renderNodePrefixForCoreModule("module");
|
|
160
|
+
|
|
161
|
+
if (!universal) {
|
|
162
|
+
return new InitFragment(
|
|
163
|
+
`import { createRequire as __WEBPACK_EXTERNAL_createRequire } from ${moduleId};\n${runtimeTemplate.renderConst()} __WEBPACK_EXTERNAL_createRequire_require = __WEBPACK_EXTERNAL_createRequire(${importMetaName}.url);\n`,
|
|
164
|
+
InitFragment.STAGE_HARMONY_IMPORTS,
|
|
165
|
+
0,
|
|
166
|
+
"external module node-commonjs"
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// defensively obtain `createRequire` so the universal bundle still loads off node
|
|
171
|
+
const content = `${runtimeTemplate.renderConst()} __WEBPACK_EXTERNAL_createRequire_require = ${runtimeTemplate.getBuiltinModule(
|
|
172
|
+
moduleId,
|
|
173
|
+
`.createRequire(${importMetaName}.url)`
|
|
174
|
+
)};\n`;
|
|
155
175
|
|
|
156
176
|
return new InitFragment(
|
|
157
|
-
|
|
158
|
-
"module"
|
|
159
|
-
)};\n${runtimeTemplate.renderConst()} __WEBPACK_EXTERNAL_createRequire_require = __WEBPACK_EXTERNAL_createRequire(${importMetaName}.url);\n`,
|
|
177
|
+
content,
|
|
160
178
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
|
161
179
|
0,
|
|
162
|
-
"external module node-commonjs"
|
|
180
|
+
"external module node-commonjs universal"
|
|
163
181
|
);
|
|
164
182
|
};
|
|
165
183
|
|
|
@@ -167,14 +185,16 @@ const getExternalModuleNodeCommonjsInitFragment = (runtimeTemplate) => {
|
|
|
167
185
|
* Gets source for common js external in node module.
|
|
168
186
|
* @param {ModuleAndSpecifiers} moduleAndSpecifiers the module request
|
|
169
187
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
|
188
|
+
* @param {boolean=} universal target may also run outside node (e.g. `["node", "web"]`)
|
|
170
189
|
* @returns {SourceData} the generated source
|
|
171
190
|
*/
|
|
172
191
|
const getSourceForCommonJsExternalInNodeModule = (
|
|
173
192
|
moduleAndSpecifiers,
|
|
174
|
-
runtimeTemplate
|
|
193
|
+
runtimeTemplate,
|
|
194
|
+
universal = false
|
|
175
195
|
) => {
|
|
176
196
|
const chunkInitFragments = [
|
|
177
|
-
getExternalModuleNodeCommonjsInitFragment(runtimeTemplate)
|
|
197
|
+
getExternalModuleNodeCommonjsInitFragment(runtimeTemplate, universal)
|
|
178
198
|
];
|
|
179
199
|
if (!Array.isArray(moduleAndSpecifiers)) {
|
|
180
200
|
return {
|
|
@@ -310,10 +330,15 @@ class ModuleExternalInitFragment extends InitFragment {
|
|
|
310
330
|
imported === true ? imported : imported.join(" ")
|
|
311
331
|
}`
|
|
312
332
|
);
|
|
333
|
+
/** @type {string} */
|
|
313
334
|
this._ident = ident;
|
|
335
|
+
/** @type {string} */
|
|
314
336
|
this._request = request;
|
|
337
|
+
/** @type {ImportDependencyMeta | undefined} */
|
|
315
338
|
this._dependencyMeta = dependencyMeta;
|
|
339
|
+
/** @type {string} */
|
|
316
340
|
this._identifier = this.buildIdentifier(ident);
|
|
341
|
+
/** @type {Imported} */
|
|
317
342
|
this._imported = this.buildImported(imported);
|
|
318
343
|
}
|
|
319
344
|
|
|
@@ -562,10 +587,10 @@ const getSourceForModuleExternal = (
|
|
|
562
587
|
return {
|
|
563
588
|
expression,
|
|
564
589
|
init: moduleRemapping
|
|
565
|
-
?
|
|
590
|
+
? `${runtimeTemplate.renderConst()} x = ${runtimeTemplate.basicFunction(
|
|
566
591
|
"y",
|
|
567
|
-
|
|
568
|
-
)} \
|
|
592
|
+
`${runtimeTemplate.renderConst()} x = {}; ${RuntimeGlobals.definePropertyGetters}(x, y); return x`
|
|
593
|
+
)} \n${runtimeTemplate.renderConst()} y = ${runtimeTemplate.returningFunction(
|
|
569
594
|
runtimeTemplate.returningFunction("x"),
|
|
570
595
|
"x"
|
|
571
596
|
)}`
|
|
@@ -593,7 +618,7 @@ const getSourceForScriptExternal = (urlAndGlobal, runtimeTemplate) => {
|
|
|
593
618
|
const url = urlAndGlobal[0];
|
|
594
619
|
const globalName = urlAndGlobal[1];
|
|
595
620
|
return {
|
|
596
|
-
init:
|
|
621
|
+
init: `${runtimeTemplate.renderConst()} __webpack_error__ = new Error();`,
|
|
597
622
|
expression: `new Promise(${runtimeTemplate.basicFunction(
|
|
598
623
|
"resolve, reject",
|
|
599
624
|
[
|
|
@@ -602,8 +627,8 @@ const getSourceForScriptExternal = (urlAndGlobal, runtimeTemplate) => {
|
|
|
602
627
|
url
|
|
603
628
|
)}, ${runtimeTemplate.basicFunction("event", [
|
|
604
629
|
`if(typeof ${globalName} !== "undefined") return resolve();`,
|
|
605
|
-
|
|
606
|
-
|
|
630
|
+
`${runtimeTemplate.renderConst()} errorType = event && (event.type === 'load' ? 'missing' : event.type);`,
|
|
631
|
+
`${runtimeTemplate.renderConst()} realSrc = event && event.target && event.target.src;`,
|
|
607
632
|
"__webpack_error__.message = 'Loading script failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
|
608
633
|
"__webpack_error__.name = 'ScriptExternalLoadError';",
|
|
609
634
|
"__webpack_error__.type = errorType;",
|
|
@@ -694,6 +719,14 @@ const getSourceForDefaultCase = (optional, request, runtimeTemplate) => {
|
|
|
694
719
|
/** @type {WeakMap<Compilation, ExternalModuleHooks>} */
|
|
695
720
|
const compilationHooksMap = new WeakMap();
|
|
696
721
|
|
|
722
|
+
/**
|
|
723
|
+
* Defines the build info properties specific to external modules.
|
|
724
|
+
* @typedef {object} KnownExternalModuleBuildInfo
|
|
725
|
+
* @property {boolean=} javascriptModule true when emitting an ESM external (`output.module`)
|
|
726
|
+
*/
|
|
727
|
+
|
|
728
|
+
/** @typedef {BuildInfo & KnownExternalModuleBuildInfo} ExternalModuleBuildInfo */
|
|
729
|
+
|
|
697
730
|
class ExternalModule extends Module {
|
|
698
731
|
/**
|
|
699
732
|
* Creates an instance of ExternalModule.
|
|
@@ -705,6 +738,10 @@ class ExternalModule extends Module {
|
|
|
705
738
|
constructor(request, type, userRequest, dependencyMeta) {
|
|
706
739
|
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
|
707
740
|
|
|
741
|
+
// Redeclared with the external module specific shape
|
|
742
|
+
/** @type {ExternalModuleBuildInfo | undefined} */
|
|
743
|
+
this.buildInfo = undefined;
|
|
744
|
+
|
|
708
745
|
// Info from Factory
|
|
709
746
|
/** @type {ExternalModuleRequest} */
|
|
710
747
|
this.request = request;
|
|
@@ -1019,11 +1056,22 @@ class ExternalModule extends Module {
|
|
|
1019
1056
|
case "commonjs2":
|
|
1020
1057
|
case "commonjs-module":
|
|
1021
1058
|
case "commonjs-static":
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1059
|
+
case "node-commonjs": {
|
|
1060
|
+
const { node } = runtimeTemplate.compilation.options.externalsPresets;
|
|
1061
|
+
// ESM has no `require`; load via `createRequire` when the target is node
|
|
1062
|
+
const createRequireInModule =
|
|
1063
|
+
/** @type {BuildInfo} */ (this.buildInfo).javascriptModule &&
|
|
1064
|
+
(externalType === "node-commonjs" || Boolean(node));
|
|
1065
|
+
if (!createRequireInModule) {
|
|
1066
|
+
return getSourceForCommonJsExternal(request);
|
|
1067
|
+
}
|
|
1068
|
+
// for a universal target (e.g. `["node", "web"]`) load defensively so the browser doesn't crash
|
|
1069
|
+
return getSourceForCommonJsExternalInNodeModule(
|
|
1070
|
+
request,
|
|
1071
|
+
runtimeTemplate,
|
|
1072
|
+
runtimeTemplate.isUniversalTarget()
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1027
1075
|
case "amd":
|
|
1028
1076
|
case "amd-require":
|
|
1029
1077
|
case "umd":
|
|
@@ -1271,12 +1319,11 @@ class ExternalModule extends Module {
|
|
|
1271
1319
|
* @param {ObjectSerializerContext} context context
|
|
1272
1320
|
*/
|
|
1273
1321
|
serialize(context) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
write(this.dependencyMeta);
|
|
1322
|
+
context
|
|
1323
|
+
.write(this.request)
|
|
1324
|
+
.write(this.externalType)
|
|
1325
|
+
.write(this.userRequest)
|
|
1326
|
+
.write(this.dependencyMeta);
|
|
1280
1327
|
|
|
1281
1328
|
super.serialize(context);
|
|
1282
1329
|
}
|
|
@@ -1286,14 +1333,15 @@ class ExternalModule extends Module {
|
|
|
1286
1333
|
* @param {ObjectDeserializerContext} context context
|
|
1287
1334
|
*/
|
|
1288
1335
|
deserialize(context) {
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
this.
|
|
1292
|
-
|
|
1293
|
-
this.userRequest = read();
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1336
|
+
this.request = context.read();
|
|
1337
|
+
const c1 = context.rest;
|
|
1338
|
+
this.externalType = c1.read();
|
|
1339
|
+
const c2 = c1.rest;
|
|
1340
|
+
this.userRequest = c2.read();
|
|
1341
|
+
const c3 = c2.rest;
|
|
1342
|
+
this.dependencyMeta = c3.read();
|
|
1343
|
+
|
|
1344
|
+
super.deserialize(c3.rest);
|
|
1297
1345
|
}
|
|
1298
1346
|
}
|
|
1299
1347
|
|
package/lib/ExternalsPlugin.js
CHANGED
package/lib/FileSystemInfo.js
CHANGED
|
@@ -201,7 +201,9 @@ class SnapshotIterable {
|
|
|
201
201
|
* @param {GetMapsFunction<T>} getMaps get maps function
|
|
202
202
|
*/
|
|
203
203
|
constructor(snapshot, getMaps) {
|
|
204
|
+
/** @type {Snapshot} */
|
|
204
205
|
this.snapshot = snapshot;
|
|
206
|
+
/** @type {GetMapsFunction<T>} */
|
|
205
207
|
this.getMaps = getMaps;
|
|
206
208
|
}
|
|
207
209
|
|
|
@@ -297,6 +299,7 @@ class SnapshotIterable {
|
|
|
297
299
|
|
|
298
300
|
class Snapshot {
|
|
299
301
|
constructor() {
|
|
302
|
+
/** @type {number} */
|
|
300
303
|
this._flags = 0;
|
|
301
304
|
/** @type {Iterable<string> | undefined} */
|
|
302
305
|
this._cachedFileIterable = undefined;
|
|
@@ -672,14 +675,19 @@ class SnapshotOptimization {
|
|
|
672
675
|
this._has = has;
|
|
673
676
|
this._get = get;
|
|
674
677
|
this._set = set;
|
|
678
|
+
/** @type {boolean} */
|
|
675
679
|
this._useStartTime = useStartTime;
|
|
676
680
|
/** @type {U} */
|
|
677
681
|
this._isSet = isSet;
|
|
678
682
|
/** @type {Map<string, SnapshotOptimizationEntry>} */
|
|
679
683
|
this._map = new Map();
|
|
684
|
+
/** @type {number} */
|
|
680
685
|
this._statItemsShared = 0;
|
|
686
|
+
/** @type {number} */
|
|
681
687
|
this._statItemsUnshared = 0;
|
|
688
|
+
/** @type {number} */
|
|
682
689
|
this._statSharedSnapshots = 0;
|
|
690
|
+
/** @type {number} */
|
|
683
691
|
this._statReusedSharedSnapshots = 0;
|
|
684
692
|
}
|
|
685
693
|
|
|
@@ -929,16 +937,120 @@ class SnapshotOptimization {
|
|
|
929
937
|
}
|
|
930
938
|
}
|
|
931
939
|
|
|
940
|
+
/** @type {Record<string, string>} */
|
|
941
|
+
const ESCAPES = {
|
|
942
|
+
n: "\n",
|
|
943
|
+
r: "\r",
|
|
944
|
+
t: "\t",
|
|
945
|
+
b: "\b",
|
|
946
|
+
f: "\f",
|
|
947
|
+
v: "\v"
|
|
948
|
+
};
|
|
949
|
+
|
|
932
950
|
/**
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
* @
|
|
951
|
+
* Cooks a JS string/template literal specifier into its evaluated value,
|
|
952
|
+
* matching ECMAScript escape semantics (sloppy-mode for string literals).
|
|
953
|
+
* @param {string} str input including the surrounding quotes
|
|
954
|
+
* @returns {string | null} result, or null when not a quoted literal
|
|
955
|
+
* @throws {Error} on a malformed escape sequence, like the JS parser would
|
|
936
956
|
*/
|
|
937
957
|
const parseString = (str) => {
|
|
938
|
-
|
|
939
|
-
|
|
958
|
+
const q = str[0];
|
|
959
|
+
|
|
960
|
+
if (q !== '"' && q !== "'" && q !== "`") {
|
|
961
|
+
return null;
|
|
940
962
|
}
|
|
941
|
-
|
|
963
|
+
|
|
964
|
+
const template = q === "`";
|
|
965
|
+
const inner = str.slice(1, -1);
|
|
966
|
+
const len = inner.length;
|
|
967
|
+
let result = "";
|
|
968
|
+
let i = 0;
|
|
969
|
+
|
|
970
|
+
while (i < len) {
|
|
971
|
+
const ch = inner[i];
|
|
972
|
+
if (ch !== "\\") {
|
|
973
|
+
// Template value normalizes raw <CR> and <CRLF> to <LF>
|
|
974
|
+
if (template && ch === "\r") {
|
|
975
|
+
result += "\n";
|
|
976
|
+
i += inner[i + 1] === "\n" ? 2 : 1;
|
|
977
|
+
} else {
|
|
978
|
+
result += ch;
|
|
979
|
+
i++;
|
|
980
|
+
}
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
i++;
|
|
985
|
+
if (i >= len) throw new Error("Unterminated escape sequence");
|
|
986
|
+
const esc = inner[i];
|
|
987
|
+
|
|
988
|
+
if (esc === "x") {
|
|
989
|
+
const hex = inner.slice(i + 1, i + 3);
|
|
990
|
+
if (!/^[0-9a-fA-F]{2}$/.test(hex)) {
|
|
991
|
+
throw new Error("Invalid hexadecimal escape sequence");
|
|
992
|
+
}
|
|
993
|
+
result += String.fromCharCode(Number.parseInt(hex, 16));
|
|
994
|
+
i += 3;
|
|
995
|
+
} else if (esc === "u") {
|
|
996
|
+
if (inner[i + 1] === "{") {
|
|
997
|
+
// \u{N...}
|
|
998
|
+
const closeIdx = inner.indexOf("}", i + 2);
|
|
999
|
+
const codeStr = closeIdx === -1 ? "" : inner.slice(i + 2, closeIdx);
|
|
1000
|
+
const code = Number.parseInt(codeStr, 16);
|
|
1001
|
+
if (!/^[0-9a-fA-F]+$/.test(codeStr) || code > 0x10ffff) {
|
|
1002
|
+
throw new Error("Invalid Unicode escape sequence");
|
|
1003
|
+
}
|
|
1004
|
+
result += String.fromCodePoint(code);
|
|
1005
|
+
i = closeIdx + 1;
|
|
1006
|
+
} else {
|
|
1007
|
+
// \uNNNN
|
|
1008
|
+
const hex = inner.slice(i + 1, i + 5);
|
|
1009
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
|
|
1010
|
+
throw new Error("Invalid Unicode escape sequence");
|
|
1011
|
+
}
|
|
1012
|
+
result += String.fromCharCode(Number.parseInt(hex, 16));
|
|
1013
|
+
i += 5;
|
|
1014
|
+
}
|
|
1015
|
+
} else if (esc === "\r") {
|
|
1016
|
+
// Line continuation: \<CR> or \<CRLF>
|
|
1017
|
+
i += inner[i + 1] === "\n" ? 2 : 1;
|
|
1018
|
+
} else if (esc === "\n" || esc === "\u2028" || esc === "\u2029") {
|
|
1019
|
+
// Line continuation: \<LF>, \<LS>, \<PS>
|
|
1020
|
+
i++;
|
|
1021
|
+
} else if (ESCAPES[esc] !== undefined) {
|
|
1022
|
+
result += ESCAPES[esc];
|
|
1023
|
+
i++;
|
|
1024
|
+
} else if (esc >= "0" && esc <= "7") {
|
|
1025
|
+
// \0 not followed by a digit is NUL, otherwise a legacy octal escape
|
|
1026
|
+
const next = inner[i + 1];
|
|
1027
|
+
if (esc === "0" && !(next >= "0" && next <= "9")) {
|
|
1028
|
+
result += "\0";
|
|
1029
|
+
i++;
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
if (template) throw new Error("Octal escape not allowed in template");
|
|
1033
|
+
// Up to 3 octal digits, value capped at \377
|
|
1034
|
+
let oct = esc;
|
|
1035
|
+
i++;
|
|
1036
|
+
const max = esc <= "3" ? 3 : 2;
|
|
1037
|
+
while (oct.length < max && inner[i] >= "0" && inner[i] <= "7") {
|
|
1038
|
+
oct += inner[i];
|
|
1039
|
+
i++;
|
|
1040
|
+
}
|
|
1041
|
+
result += String.fromCharCode(Number.parseInt(oct, 8));
|
|
1042
|
+
} else if (esc === "8" || esc === "9") {
|
|
1043
|
+
if (template) throw new Error("\\8 and \\9 not allowed in template");
|
|
1044
|
+
result += esc;
|
|
1045
|
+
i++;
|
|
1046
|
+
} else {
|
|
1047
|
+
// \', \", \\, \`, and any other NonEscapeCharacter — the char itself
|
|
1048
|
+
result += esc;
|
|
1049
|
+
i++;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
return result;
|
|
942
1054
|
};
|
|
943
1055
|
|
|
944
1056
|
/* istanbul ignore next */
|
|
@@ -1157,52 +1269,63 @@ class FileSystemInfo {
|
|
|
1157
1269
|
hashFunction = DEFAULTS.HASH_FUNCTION
|
|
1158
1270
|
} = {}
|
|
1159
1271
|
) {
|
|
1272
|
+
/** @type {InputFileSystem} */
|
|
1160
1273
|
this.fs = fs;
|
|
1161
1274
|
this.logger = logger;
|
|
1275
|
+
/** @type {number} */
|
|
1162
1276
|
this._remainingLogs = logger ? 40 : 0;
|
|
1163
1277
|
/** @type {LoggedPaths | undefined} */
|
|
1164
1278
|
this._loggedPaths = logger ? new Set() : undefined;
|
|
1279
|
+
/** @type {HashFunction} */
|
|
1165
1280
|
this._hashFunction = hashFunction;
|
|
1166
1281
|
/** @type {WeakMap<Snapshot, boolean | CheckSnapshotValidCallback[]>} */
|
|
1167
1282
|
this._snapshotCache = new WeakMap();
|
|
1283
|
+
/** @type {SnapshotOptimization<FileSystemInfoEntry | null, false>} */
|
|
1168
1284
|
this._fileTimestampsOptimization = new SnapshotOptimization(
|
|
1169
1285
|
(s) => s.hasFileTimestamps(),
|
|
1170
1286
|
(s) => s.fileTimestamps,
|
|
1171
1287
|
(s, v) => s.setFileTimestamps(v)
|
|
1172
1288
|
);
|
|
1289
|
+
/** @type {SnapshotOptimization<string | null, false>} */
|
|
1173
1290
|
this._fileHashesOptimization = new SnapshotOptimization(
|
|
1174
1291
|
(s) => s.hasFileHashes(),
|
|
1175
1292
|
(s) => s.fileHashes,
|
|
1176
1293
|
(s, v) => s.setFileHashes(v),
|
|
1177
1294
|
false
|
|
1178
1295
|
);
|
|
1296
|
+
/** @type {SnapshotOptimization<string | TimestampAndHash | null, false>} */
|
|
1179
1297
|
this._fileTshsOptimization = new SnapshotOptimization(
|
|
1180
1298
|
(s) => s.hasFileTshs(),
|
|
1181
1299
|
(s) => s.fileTshs,
|
|
1182
1300
|
(s, v) => s.setFileTshs(v)
|
|
1183
1301
|
);
|
|
1302
|
+
/** @type {SnapshotOptimization<ResolvedContextFileSystemInfoEntry | null, false>} */
|
|
1184
1303
|
this._contextTimestampsOptimization = new SnapshotOptimization(
|
|
1185
1304
|
(s) => s.hasContextTimestamps(),
|
|
1186
1305
|
(s) => s.contextTimestamps,
|
|
1187
1306
|
(s, v) => s.setContextTimestamps(v)
|
|
1188
1307
|
);
|
|
1308
|
+
/** @type {SnapshotOptimization<string | null, false>} */
|
|
1189
1309
|
this._contextHashesOptimization = new SnapshotOptimization(
|
|
1190
1310
|
(s) => s.hasContextHashes(),
|
|
1191
1311
|
(s) => s.contextHashes,
|
|
1192
1312
|
(s, v) => s.setContextHashes(v),
|
|
1193
1313
|
false
|
|
1194
1314
|
);
|
|
1315
|
+
/** @type {SnapshotOptimization<ResolvedContextTimestampAndHash | null, false>} */
|
|
1195
1316
|
this._contextTshsOptimization = new SnapshotOptimization(
|
|
1196
1317
|
(s) => s.hasContextTshs(),
|
|
1197
1318
|
(s) => s.contextTshs,
|
|
1198
1319
|
(s, v) => s.setContextTshs(v)
|
|
1199
1320
|
);
|
|
1321
|
+
/** @type {SnapshotOptimization<boolean, false>} */
|
|
1200
1322
|
this._missingExistenceOptimization = new SnapshotOptimization(
|
|
1201
1323
|
(s) => s.hasMissingExistence(),
|
|
1202
1324
|
(s) => s.missingExistence,
|
|
1203
1325
|
(s, v) => s.setMissingExistence(v),
|
|
1204
1326
|
false
|
|
1205
1327
|
);
|
|
1328
|
+
/** @type {SnapshotOptimization<string, false>} */
|
|
1206
1329
|
this._managedItemInfoOptimization = new SnapshotOptimization(
|
|
1207
1330
|
(s) => s.hasManagedItemInfo(),
|
|
1208
1331
|
(s) => s.managedItemInfo,
|
|
@@ -1316,16 +1439,25 @@ class FileSystemInfo {
|
|
|
1316
1439
|
(p) => typeof p !== "string"
|
|
1317
1440
|
);
|
|
1318
1441
|
|
|
1442
|
+
/** @type {Map<string, number | null> | undefined} */
|
|
1319
1443
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1444
|
+
/** @type {Map<string, number | null> | undefined} */
|
|
1320
1445
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
1321
1446
|
|
|
1447
|
+
/** @type {boolean} */
|
|
1322
1448
|
this._warnAboutExperimentalEsmTracking = false;
|
|
1323
1449
|
|
|
1450
|
+
/** @type {number} */
|
|
1324
1451
|
this._statCreatedSnapshots = 0;
|
|
1452
|
+
/** @type {number} */
|
|
1325
1453
|
this._statTestedSnapshotsCached = 0;
|
|
1454
|
+
/** @type {number} */
|
|
1326
1455
|
this._statTestedSnapshotsNotCached = 0;
|
|
1456
|
+
/** @type {number} */
|
|
1327
1457
|
this._statTestedChildrenCached = 0;
|
|
1458
|
+
/** @type {number} */
|
|
1328
1459
|
this._statTestedChildrenNotCached = 0;
|
|
1460
|
+
/** @type {number} */
|
|
1329
1461
|
this._statTestedEntries = 0;
|
|
1330
1462
|
}
|
|
1331
1463
|
|
|
@@ -2084,19 +2216,17 @@ class FileSystemInfo {
|
|
|
2084
2216
|
const added = new Set();
|
|
2085
2217
|
for (const imp of imports) {
|
|
2086
2218
|
try {
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
} else {
|
|
2099
|
-
// e.g. import.meta
|
|
2219
|
+
// import.meta
|
|
2220
|
+
if (imp.d === -2) {
|
|
2221
|
+
continue;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
/** @type {string | null} */
|
|
2225
|
+
const dependency =
|
|
2226
|
+
imp.n ||
|
|
2227
|
+
parseString(source.slice(imp.s, imp.e).trim());
|
|
2228
|
+
|
|
2229
|
+
if (!dependency) {
|
|
2100
2230
|
continue;
|
|
2101
2231
|
}
|
|
2102
2232
|
|
|
@@ -3411,7 +3541,6 @@ class FileSystemInfo {
|
|
|
3411
3541
|
if (
|
|
3412
3542
|
!checkContext(
|
|
3413
3543
|
path,
|
|
3414
|
-
// TODO: test with `"ignore"`
|
|
3415
3544
|
/** @type {ResolvedContextFileSystemInfoEntry | null} */
|
|
3416
3545
|
(entry),
|
|
3417
3546
|
tsh,
|
|
@@ -3875,6 +4004,8 @@ class FileSystemInfo {
|
|
|
3875
4004
|
/** @type {string[]} */
|
|
3876
4005
|
const hashes = [];
|
|
3877
4006
|
let safeTime = 0;
|
|
4007
|
+
// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
|
|
4008
|
+
const seen = new Set(entry.symlinks);
|
|
3878
4009
|
processAsyncTree(
|
|
3879
4010
|
/** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
|
|
3880
4011
|
10,
|
|
@@ -3887,7 +4018,12 @@ class FileSystemInfo {
|
|
|
3887
4018
|
safeTime = Math.max(safeTime, entry.safeTime);
|
|
3888
4019
|
}
|
|
3889
4020
|
if (entry.symlinks !== undefined) {
|
|
3890
|
-
for (const target of entry.symlinks)
|
|
4021
|
+
for (const target of entry.symlinks) {
|
|
4022
|
+
if (!seen.has(target)) {
|
|
4023
|
+
seen.add(target);
|
|
4024
|
+
push(target);
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
3891
4027
|
}
|
|
3892
4028
|
}
|
|
3893
4029
|
callback();
|
|
@@ -3997,6 +4133,8 @@ class FileSystemInfo {
|
|
|
3997
4133
|
_resolveContextHash(entry, callback) {
|
|
3998
4134
|
/** @type {string[]} */
|
|
3999
4135
|
const hashes = [];
|
|
4136
|
+
// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
|
|
4137
|
+
const seen = new Set(entry.symlinks);
|
|
4000
4138
|
processAsyncTree(
|
|
4001
4139
|
/** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
|
|
4002
4140
|
10,
|
|
@@ -4006,7 +4144,12 @@ class FileSystemInfo {
|
|
|
4006
4144
|
if (hash) {
|
|
4007
4145
|
hashes.push(hash.hash);
|
|
4008
4146
|
if (hash.symlinks !== undefined) {
|
|
4009
|
-
for (const target of hash.symlinks)
|
|
4147
|
+
for (const target of hash.symlinks) {
|
|
4148
|
+
if (!seen.has(target)) {
|
|
4149
|
+
seen.add(target);
|
|
4150
|
+
push(target);
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4010
4153
|
}
|
|
4011
4154
|
}
|
|
4012
4155
|
callback();
|
|
@@ -4170,6 +4313,8 @@ class FileSystemInfo {
|
|
|
4170
4313
|
/** @type {string[]} */
|
|
4171
4314
|
const tsHashes = [];
|
|
4172
4315
|
let safeTime = 0;
|
|
4316
|
+
// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
|
|
4317
|
+
const seen = new Set(entry.symlinks);
|
|
4173
4318
|
processAsyncTree(
|
|
4174
4319
|
/** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
|
|
4175
4320
|
10,
|
|
@@ -4183,7 +4328,12 @@ class FileSystemInfo {
|
|
|
4183
4328
|
safeTime = Math.max(safeTime, entry.safeTime);
|
|
4184
4329
|
}
|
|
4185
4330
|
if (entry.symlinks !== undefined) {
|
|
4186
|
-
for (const target of entry.symlinks)
|
|
4331
|
+
for (const target of entry.symlinks) {
|
|
4332
|
+
if (!seen.has(target)) {
|
|
4333
|
+
seen.add(target);
|
|
4334
|
+
push(target);
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4187
4337
|
}
|
|
4188
4338
|
}
|
|
4189
4339
|
callback();
|
|
@@ -18,6 +18,7 @@ class FlagAllModulesAsUsedPlugin {
|
|
|
18
18
|
* @param {string} explanation explanation
|
|
19
19
|
*/
|
|
20
20
|
constructor(explanation) {
|
|
21
|
+
/** @type {string} */
|
|
21
22
|
this.explanation = explanation;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -42,11 +43,6 @@ class FlagAllModulesAsUsedPlugin {
|
|
|
42
43
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
43
44
|
exportsInfo.setUsedInUnknownWay(runtime);
|
|
44
45
|
moduleGraph.addExtraReason(module, this.explanation);
|
|
45
|
-
if (module.factoryMeta === undefined) {
|
|
46
|
-
module.factoryMeta = {};
|
|
47
|
-
}
|
|
48
|
-
/** @type {FactoryMeta} */
|
|
49
|
-
(module.factoryMeta).sideEffectFree = false;
|
|
50
46
|
}
|
|
51
47
|
});
|
|
52
48
|
});
|
|
@@ -166,6 +166,7 @@ class FlagDependencyExportsPlugin {
|
|
|
166
166
|
const globalPriority = exportDesc.priority;
|
|
167
167
|
const globalTerminalBinding =
|
|
168
168
|
exportDesc.terminalBinding || false;
|
|
169
|
+
const globalPure = exportDesc.isPure || false;
|
|
169
170
|
const exportDeps = exportDesc.dependencies;
|
|
170
171
|
if (exportDesc.hideExports) {
|
|
171
172
|
for (const name of exportDesc.hideExports) {
|
|
@@ -198,6 +199,7 @@ class FlagDependencyExportsPlugin {
|
|
|
198
199
|
let name;
|
|
199
200
|
let canMangle = globalCanMangle;
|
|
200
201
|
let terminalBinding = globalTerminalBinding;
|
|
202
|
+
let pure = globalPure;
|
|
201
203
|
/** @type {ExportSpec["exports"]} */
|
|
202
204
|
let exports;
|
|
203
205
|
let from = globalFrom;
|
|
@@ -205,6 +207,8 @@ class FlagDependencyExportsPlugin {
|
|
|
205
207
|
let fromExport;
|
|
206
208
|
let priority = globalPriority;
|
|
207
209
|
let hidden = false;
|
|
210
|
+
/** @type {ExportSpec["inlined"]} */
|
|
211
|
+
let inlined;
|
|
208
212
|
if (typeof exportNameOrSpec === "string") {
|
|
209
213
|
name = exportNameOrSpec;
|
|
210
214
|
} else {
|
|
@@ -227,9 +231,15 @@ class FlagDependencyExportsPlugin {
|
|
|
227
231
|
if (exportNameOrSpec.terminalBinding !== undefined) {
|
|
228
232
|
terminalBinding = exportNameOrSpec.terminalBinding;
|
|
229
233
|
}
|
|
234
|
+
if (exportNameOrSpec.isPure !== undefined) {
|
|
235
|
+
pure = exportNameOrSpec.isPure;
|
|
236
|
+
}
|
|
230
237
|
if (exportNameOrSpec.hidden !== undefined) {
|
|
231
238
|
hidden = exportNameOrSpec.hidden;
|
|
232
239
|
}
|
|
240
|
+
if (exportNameOrSpec.inlined !== undefined) {
|
|
241
|
+
inlined = exportNameOrSpec.inlined;
|
|
242
|
+
}
|
|
233
243
|
}
|
|
234
244
|
const exportInfo = exportsInfo.getExportInfo(name);
|
|
235
245
|
|
|
@@ -249,11 +259,24 @@ class FlagDependencyExportsPlugin {
|
|
|
249
259
|
changed = true;
|
|
250
260
|
}
|
|
251
261
|
|
|
262
|
+
if (
|
|
263
|
+
inlined !== undefined &&
|
|
264
|
+
exportInfo.canInlineProvide === undefined
|
|
265
|
+
) {
|
|
266
|
+
exportInfo.canInlineProvide = inlined;
|
|
267
|
+
changed = true;
|
|
268
|
+
}
|
|
269
|
+
|
|
252
270
|
if (terminalBinding && !exportInfo.terminalBinding) {
|
|
253
271
|
exportInfo.terminalBinding = true;
|
|
254
272
|
changed = true;
|
|
255
273
|
}
|
|
256
274
|
|
|
275
|
+
if (pure && exportInfo.pureProvide !== true) {
|
|
276
|
+
exportInfo.pureProvide = true;
|
|
277
|
+
changed = true;
|
|
278
|
+
}
|
|
279
|
+
|
|
257
280
|
if (exports) {
|
|
258
281
|
const nestedExportsInfo =
|
|
259
282
|
exportInfo.createNestedExportsInfo();
|