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/lib/buildChunkGraph.js
CHANGED
|
@@ -16,6 +16,7 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
|
16
16
|
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
|
17
17
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
18
18
|
/** @typedef {import("./Entrypoint")} Entrypoint */
|
|
19
|
+
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
19
20
|
/** @typedef {import("./Module")} Module */
|
|
20
21
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
21
22
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
@@ -241,6 +242,44 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
|
241
242
|
}
|
|
242
243
|
};
|
|
243
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Derives block modules for another runtime from an already extracted result.
|
|
247
|
+
* Only the merged active state of each connection group can differ per
|
|
248
|
+
* runtime; modules and connection groups are reused. When all states turn
|
|
249
|
+
* out equal, the tuple array is shared instead of copied.
|
|
250
|
+
* @param {Module} module the root module
|
|
251
|
+
* @param {BlockModulesMap} source map containing the extracted result for all blocks of the module
|
|
252
|
+
* @param {RuntimeSpec} runtime runtime to derive for
|
|
253
|
+
* @param {BlockModulesMap} blockModulesMap block modules map to fill
|
|
254
|
+
*/
|
|
255
|
+
const deriveBlockModules = (module, source, runtime, blockModulesMap) => {
|
|
256
|
+
/** @type {DependenciesBlock[]} */
|
|
257
|
+
const queue = [module];
|
|
258
|
+
while (queue.length > 0) {
|
|
259
|
+
const block = /** @type {DependenciesBlock} */ (queue.pop());
|
|
260
|
+
const sourceModules =
|
|
261
|
+
/** @type {BlockModulesInFlattenTuples} */
|
|
262
|
+
(source.get(block));
|
|
263
|
+
let target = sourceModules;
|
|
264
|
+
for (let i = 0, len = sourceModules.length; i < len; i += 3) {
|
|
265
|
+
const state = getActiveStateOfConnections(
|
|
266
|
+
/** @type {ModuleGraphConnection[]} */ (sourceModules[i + 2]),
|
|
267
|
+
runtime
|
|
268
|
+
);
|
|
269
|
+
if (target === sourceModules) {
|
|
270
|
+
if (state === sourceModules[i + 1]) continue;
|
|
271
|
+
// states diverged, copy (states before i are identical)
|
|
272
|
+
target = [...sourceModules];
|
|
273
|
+
}
|
|
274
|
+
target[i + 1] = state;
|
|
275
|
+
}
|
|
276
|
+
blockModulesMap.set(block, target);
|
|
277
|
+
for (const b of block.blocks) {
|
|
278
|
+
queue.push(b);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
244
283
|
/**
|
|
245
284
|
* Processes the provided logger.
|
|
246
285
|
* @param {Logger} logger a logger
|
|
@@ -267,8 +306,10 @@ const visitModules = (
|
|
|
267
306
|
/** @type {Map<RuntimeSpec, BlockModulesMap>} */
|
|
268
307
|
const blockModulesRuntimeMap = new Map();
|
|
269
308
|
|
|
270
|
-
|
|
271
|
-
|
|
309
|
+
// map containing the first extraction per root module,
|
|
310
|
+
// other runtimes derive their result from it
|
|
311
|
+
/** @type {Map<Module, BlockModulesMap>} */
|
|
312
|
+
const firstBlockModulesMapByModule = new Map();
|
|
272
313
|
|
|
273
314
|
/** @type {Map<Module, number>} */
|
|
274
315
|
const ordinalByModule = new Map();
|
|
@@ -302,7 +343,7 @@ const visitModules = (
|
|
|
302
343
|
* @returns {BlockModulesInFlattenTuples | undefined} block modules in flatten tuples
|
|
303
344
|
*/
|
|
304
345
|
const getBlockModules = (block, runtime) => {
|
|
305
|
-
blockModulesMap = blockModulesRuntimeMap.get(runtime);
|
|
346
|
+
let blockModulesMap = blockModulesRuntimeMap.get(runtime);
|
|
306
347
|
if (blockModulesMap === undefined) {
|
|
307
348
|
/** @type {BlockModulesMap} */
|
|
308
349
|
blockModulesMap = new Map();
|
|
@@ -320,18 +361,33 @@ const visitModules = (
|
|
|
320
361
|
() => {
|
|
321
362
|
logger.time("visitModules: prepare");
|
|
322
363
|
const map = new Map();
|
|
323
|
-
|
|
364
|
+
const source = firstBlockModulesMapByModule.get(module);
|
|
365
|
+
if (source !== undefined) {
|
|
366
|
+
deriveBlockModules(module, source, runtime, map);
|
|
367
|
+
} else {
|
|
368
|
+
extractBlockModules(module, moduleGraph, runtime, map);
|
|
369
|
+
}
|
|
324
370
|
logger.timeAggregate("visitModules: prepare");
|
|
325
371
|
return map;
|
|
326
372
|
}
|
|
327
373
|
);
|
|
374
|
+
// allow other runtimes to derive from a memCache hit too
|
|
375
|
+
if (!firstBlockModulesMapByModule.has(module)) {
|
|
376
|
+
firstBlockModulesMapByModule.set(module, map);
|
|
377
|
+
}
|
|
328
378
|
for (const [block, blockModules] of map) {
|
|
329
379
|
blockModulesMap.set(block, blockModules);
|
|
330
380
|
}
|
|
331
381
|
return map.get(block);
|
|
332
382
|
}
|
|
333
383
|
logger.time("visitModules: prepare");
|
|
334
|
-
|
|
384
|
+
const source = firstBlockModulesMapByModule.get(module);
|
|
385
|
+
if (source !== undefined) {
|
|
386
|
+
deriveBlockModules(module, source, runtime, blockModulesMap);
|
|
387
|
+
} else {
|
|
388
|
+
extractBlockModules(module, moduleGraph, runtime, blockModulesMap);
|
|
389
|
+
firstBlockModulesMapByModule.set(module, blockModulesMap);
|
|
390
|
+
}
|
|
335
391
|
blockModules =
|
|
336
392
|
/** @type {BlockModulesInFlattenTuples} */
|
|
337
393
|
(blockModulesMap.get(block));
|
|
@@ -581,7 +637,27 @@ const visitModules = (
|
|
|
581
637
|
}
|
|
582
638
|
} else {
|
|
583
639
|
entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);
|
|
584
|
-
//
|
|
640
|
+
// Fill in options the existing entrypoint hasn't set yet. We never
|
|
641
|
+
// overwrite: blocks that dedupe to one entrypoint (e.g. several
|
|
642
|
+
// workers pointing at the same module) legitimately carry distinct
|
|
643
|
+
// values such as `runtime`, so the first block to create the
|
|
644
|
+
// entrypoint wins and later ones only contribute missing keys.
|
|
645
|
+
// `name` is excluded: it is the entrypoint's identity, fixed at
|
|
646
|
+
// creation (and used to key namedChunkGroups), so back-filling it
|
|
647
|
+
// from a block that deduped in via its module would leave
|
|
648
|
+
// `entrypoint.name` out of sync and make module codegen
|
|
649
|
+
// order-dependent, which breaks persistent caching.
|
|
650
|
+
const existingOptions = entrypoint.options;
|
|
651
|
+
for (const key_ of Object.keys(entryOptions)) {
|
|
652
|
+
const key =
|
|
653
|
+
/** @type {keyof EntryOptions} */
|
|
654
|
+
(key_);
|
|
655
|
+
if (key === "name") continue;
|
|
656
|
+
if (entryOptions[key] === undefined) continue;
|
|
657
|
+
if (existingOptions[key] !== undefined) continue;
|
|
658
|
+
/** @type {EntryOptions[keyof EntryOptions]} */
|
|
659
|
+
(existingOptions[key]) = entryOptions[key];
|
|
660
|
+
}
|
|
585
661
|
entrypoint.addOrigin(
|
|
586
662
|
module,
|
|
587
663
|
/** @type {DependencyLocation} */ (b.loc),
|
|
@@ -733,7 +809,6 @@ const visitModules = (
|
|
|
733
809
|
continue;
|
|
734
810
|
}
|
|
735
811
|
|
|
736
|
-
const refOrdinal = /** @type {number} */ getModuleOrdinal(refModule);
|
|
737
812
|
const activeState = /** @type {ConnectionState} */ (
|
|
738
813
|
blockModules[i + 1]
|
|
739
814
|
);
|
|
@@ -744,7 +819,10 @@ const visitModules = (
|
|
|
744
819
|
skipConnectionBuffer.push([refModule, connections]);
|
|
745
820
|
// We skip inactive connections
|
|
746
821
|
if (activeState === false) continue;
|
|
747
|
-
} else if (
|
|
822
|
+
} else if (
|
|
823
|
+
// assigning ordinals lazily here keeps masks small
|
|
824
|
+
isOrdinalSetInMask(minAvailableModules, getModuleOrdinal(refModule))
|
|
825
|
+
) {
|
|
748
826
|
// already in parent chunks, skip it for now
|
|
749
827
|
skipBuffer.push(refModule);
|
|
750
828
|
continue;
|
|
@@ -1290,7 +1368,8 @@ const connectChunkGroups = (
|
|
|
1290
1368
|
// connections and modules can only create one version
|
|
1291
1369
|
// TODO maybe decide this per runtime
|
|
1292
1370
|
if (
|
|
1293
|
-
//
|
|
1371
|
+
// Blocks with nested blocks must stay connected — skipping orphans the
|
|
1372
|
+
// nested block's chunk group from this block's chunk group parent.
|
|
1294
1373
|
!blocksWithNestedBlocks.has(block) &&
|
|
1295
1374
|
connections.every(({ chunkGroup, originChunkGroupInfo }) =>
|
|
1296
1375
|
areModulesAvailable(
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author sheo13666q @sheo13666q
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
9
|
+
const NodeTargetPlugin = require("../node/NodeTargetPlugin");
|
|
10
|
+
|
|
11
|
+
/** @typedef {import("../Compiler")} Compiler */
|
|
12
|
+
|
|
13
|
+
// Bun exposes the node.js core modules; externalize them with the `node:`
|
|
14
|
+
// specifier (Bun resolves both forms) like the deno target.
|
|
15
|
+
// cspell:word pnpapi
|
|
16
|
+
const coreModules = new Set(
|
|
17
|
+
NodeTargetPlugin.builtins.filter(
|
|
18
|
+
(builtin) => typeof builtin === "string" && builtin !== "pnpapi"
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// Bun's own built-in modules (`bun`, `bun:sqlite`, ...) are provided by the
|
|
23
|
+
// runtime, never bundled.
|
|
24
|
+
const BUN_BUILTINS = /^bun(?::|$)/;
|
|
25
|
+
|
|
26
|
+
class BunTargetPlugin {
|
|
27
|
+
/**
|
|
28
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
29
|
+
* @param {Compiler} compiler the compiler instance
|
|
30
|
+
* @returns {void}
|
|
31
|
+
*/
|
|
32
|
+
apply(compiler) {
|
|
33
|
+
new ExternalsPlugin(
|
|
34
|
+
(dependency) =>
|
|
35
|
+
dependency.category === "commonjs" ? "node-commonjs" : "module-import",
|
|
36
|
+
({ request }, callback) => {
|
|
37
|
+
if (!request) return callback();
|
|
38
|
+
if (request.startsWith("node:") || BUN_BUILTINS.test(request)) {
|
|
39
|
+
return callback(null, request);
|
|
40
|
+
}
|
|
41
|
+
if (coreModules.has(request)) return callback(null, `node:${request}`);
|
|
42
|
+
callback();
|
|
43
|
+
}
|
|
44
|
+
).apply(compiler);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = BunTargetPlugin;
|
|
@@ -15,8 +15,11 @@ class AddManagedPathsPlugin {
|
|
|
15
15
|
* @param {Iterable<string | RegExp>} unmanagedPaths list of unmanaged paths
|
|
16
16
|
*/
|
|
17
17
|
constructor(managedPaths, immutablePaths, unmanagedPaths) {
|
|
18
|
+
/** @type {Set<string | RegExp>} */
|
|
18
19
|
this.managedPaths = new Set(managedPaths);
|
|
20
|
+
/** @type {Set<string | RegExp>} */
|
|
19
21
|
this.immutablePaths = new Set(immutablePaths);
|
|
22
|
+
/** @type {Set<string | RegExp>} */
|
|
20
23
|
this.unmanagedPaths = new Set(unmanagedPaths);
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -28,9 +28,13 @@ class IdleFileCachePlugin {
|
|
|
28
28
|
idleTimeoutForInitialStore,
|
|
29
29
|
idleTimeoutAfterLargeChanges
|
|
30
30
|
) {
|
|
31
|
+
/** @type {PackFileCacheStrategy} */
|
|
31
32
|
this.strategy = strategy;
|
|
33
|
+
/** @type {number} */
|
|
32
34
|
this.idleTimeout = idleTimeout;
|
|
35
|
+
/** @type {number} */
|
|
33
36
|
this.idleTimeoutForInitialStore = idleTimeoutForInitialStore;
|
|
37
|
+
/** @type {number} */
|
|
34
38
|
this.idleTimeoutAfterLargeChanges = idleTimeoutAfterLargeChanges;
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -25,7 +25,7 @@ class LazyHashedEtag {
|
|
|
25
25
|
* @param {HashFunction} hashFunction the hash function to use
|
|
26
26
|
*/
|
|
27
27
|
constructor(obj, hashFunction = DEFAULTS.HASH_FUNCTION) {
|
|
28
|
-
/** @type {HashableObject} */
|
|
28
|
+
/** @type {HashableObject | undefined} */
|
|
29
29
|
this._obj = obj;
|
|
30
30
|
/** @type {undefined | string} */
|
|
31
31
|
this._hash = undefined;
|
|
@@ -40,8 +40,15 @@ class LazyHashedEtag {
|
|
|
40
40
|
toString() {
|
|
41
41
|
if (this._hash === undefined) {
|
|
42
42
|
const hash = createHash(this._hashFunction);
|
|
43
|
-
|
|
43
|
+
/** @type {HashableObject} */
|
|
44
|
+
(this._obj).updateHash(hash);
|
|
44
45
|
this._hash = hash.digest("base64");
|
|
46
|
+
// Drop the captured object once the hash is memoized. The hash is
|
|
47
|
+
// never reset, so we never need `_obj` again — and many callers
|
|
48
|
+
// (e.g. `SourceMapDevToolPlugin`, `RealContentHashPlugin`) capture
|
|
49
|
+
// a heavy `CachedSource` here that would otherwise stay reachable
|
|
50
|
+
// through this etag for the lifetime of the compilation cache.
|
|
51
|
+
this._obj = undefined;
|
|
45
52
|
}
|
|
46
53
|
return this._hash;
|
|
47
54
|
}
|
package/lib/cache/mergeEtags.js
CHANGED
package/lib/cli.js
CHANGED
|
@@ -17,15 +17,15 @@ const webpackSchema =
|
|
|
17
17
|
/** @typedef {JSONSchema4 | JSONSchema6 | JSONSchema7} JSONSchema */
|
|
18
18
|
/** @typedef {JSONSchema & { absolutePath: boolean, instanceof: string, cli: { helper?: boolean, exclude?: boolean, description?: string, negatedDescription?: string, resetDescription?: string } }} Schema */
|
|
19
19
|
|
|
20
|
-
// TODO add originPath to PathItem for better errors
|
|
21
20
|
/**
|
|
22
21
|
* Defines the path item type used by this module.
|
|
23
22
|
* @typedef {object} PathItem
|
|
24
23
|
* @property {Schema} schema the part of the schema
|
|
25
24
|
* @property {string} path the path in the config
|
|
25
|
+
* @property {string} segment the JSON pointer segment of this schema part (absolute when starting with "#")
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
|
|
28
|
+
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "prototype-pollution-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
|
|
29
29
|
|
|
30
30
|
/** @typedef {string | number | boolean | RegExp} Value */
|
|
31
31
|
|
|
@@ -181,6 +181,12 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
181
181
|
values: schemaPart.enum
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
|
+
if (schemaPart.const !== undefined) {
|
|
185
|
+
return {
|
|
186
|
+
type: "enum",
|
|
187
|
+
values: [schemaPart.const]
|
|
188
|
+
};
|
|
189
|
+
}
|
|
184
190
|
switch (schemaPart.type) {
|
|
185
191
|
case "number":
|
|
186
192
|
return {
|
|
@@ -233,6 +239,20 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
233
239
|
};
|
|
234
240
|
};
|
|
235
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Joins the per-item segments into a JSON pointer (built only when needed).
|
|
244
|
+
* @param {PathItem[]} path full path in schema (deepest item first)
|
|
245
|
+
* @returns {string} JSON pointer to the deepest schema part
|
|
246
|
+
*/
|
|
247
|
+
const getOriginPath = (path) => {
|
|
248
|
+
let origin = "";
|
|
249
|
+
for (let i = path.length - 1; i >= 0; i--) {
|
|
250
|
+
const { segment } = path[i];
|
|
251
|
+
origin = segment[0] === "#" ? segment : origin + segment;
|
|
252
|
+
}
|
|
253
|
+
return origin;
|
|
254
|
+
};
|
|
255
|
+
|
|
236
256
|
/**
|
|
237
257
|
* Adds the provided path to this object.
|
|
238
258
|
* @param {PathItem[]} path full path in schema
|
|
@@ -283,7 +303,11 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
283
303
|
) {
|
|
284
304
|
if (multiple) {
|
|
285
305
|
throw new Error(
|
|
286
|
-
`Conflicting schema for ${path[0].path}
|
|
306
|
+
`Conflicting schema for ${path[0].path} (${getOriginPath(
|
|
307
|
+
path
|
|
308
|
+
)}) with ${
|
|
309
|
+
argConfig.type
|
|
310
|
+
} type (array type must be before single item type)`
|
|
287
311
|
);
|
|
288
312
|
}
|
|
289
313
|
return 0;
|
|
@@ -294,18 +318,25 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
294
318
|
return 1;
|
|
295
319
|
};
|
|
296
320
|
|
|
297
|
-
// TODO support `not`
|
|
298
|
-
// TODO support `const`, but we don't use it on our schema
|
|
321
|
+
// TODO support `not`
|
|
299
322
|
/**
|
|
300
323
|
* Returns added arguments.
|
|
301
324
|
* @param {Schema} schemaPart the current schema
|
|
302
|
-
* @param {string} schemaPath the current path in the
|
|
325
|
+
* @param {string} schemaPath the current path in the config
|
|
303
326
|
* @param {PathItem[]} path all previous visited schemaParts
|
|
304
327
|
* @param {string | null} inArray if inside of an array, the path to the array
|
|
328
|
+
* @param {string} segment the JSON pointer segment of the current schema
|
|
305
329
|
* @returns {number} added arguments
|
|
306
330
|
*/
|
|
307
|
-
const traverse = (
|
|
331
|
+
const traverse = (
|
|
332
|
+
schemaPart,
|
|
333
|
+
schemaPath = "",
|
|
334
|
+
path = [],
|
|
335
|
+
inArray = null,
|
|
336
|
+
segment = "#"
|
|
337
|
+
) => {
|
|
308
338
|
while (schemaPart.$ref) {
|
|
339
|
+
segment = schemaPart.$ref;
|
|
309
340
|
schemaPart = getSchemaPart(schemaPart.$ref);
|
|
310
341
|
}
|
|
311
342
|
|
|
@@ -320,12 +351,33 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
320
351
|
if (schemaPart.cli && schemaPart.cli.exclude) return 0;
|
|
321
352
|
|
|
322
353
|
/** @type {PathItem[]} */
|
|
323
|
-
const fullPath = [
|
|
354
|
+
const fullPath = [
|
|
355
|
+
{ schema: schemaPart, path: schemaPath, segment },
|
|
356
|
+
...path
|
|
357
|
+
];
|
|
324
358
|
|
|
325
359
|
let addedArguments = 0;
|
|
326
360
|
|
|
327
361
|
addedArguments += addFlag(fullPath, Boolean(inArray));
|
|
328
362
|
|
|
363
|
+
// Collect flags from both branches of a conditional schema.
|
|
364
|
+
const conditional = /** @type {JSONSchema7} */ (schemaPart);
|
|
365
|
+
if (conditional.if) {
|
|
366
|
+
for (const key of /** @type {const} */ (["if", "then", "else"])) {
|
|
367
|
+
const subSchema = conditional[key];
|
|
368
|
+
if (subSchema && typeof subSchema === "object") {
|
|
369
|
+
addedArguments += traverse(
|
|
370
|
+
/** @type {Schema} */
|
|
371
|
+
(subSchema),
|
|
372
|
+
schemaPath,
|
|
373
|
+
fullPath,
|
|
374
|
+
inArray,
|
|
375
|
+
`/${key}`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
329
381
|
if (schemaPart.type === "object") {
|
|
330
382
|
if (schemaPart.properties) {
|
|
331
383
|
for (const property of Object.keys(schemaPart.properties)) {
|
|
@@ -334,7 +386,8 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
334
386
|
(schemaPart.properties[property]),
|
|
335
387
|
schemaPath ? `${schemaPath}.${property}` : property,
|
|
336
388
|
fullPath,
|
|
337
|
-
inArray
|
|
389
|
+
inArray,
|
|
390
|
+
`/properties/${property}`
|
|
338
391
|
);
|
|
339
392
|
}
|
|
340
393
|
}
|
|
@@ -354,7 +407,8 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
354
407
|
(item),
|
|
355
408
|
`${schemaPath}.${i}`,
|
|
356
409
|
fullPath,
|
|
357
|
-
schemaPath
|
|
410
|
+
schemaPath,
|
|
411
|
+
`/items/${i}`
|
|
358
412
|
);
|
|
359
413
|
}
|
|
360
414
|
|
|
@@ -366,7 +420,8 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
366
420
|
(schemaPart.items),
|
|
367
421
|
`${schemaPath}[]`,
|
|
368
422
|
fullPath,
|
|
369
|
-
schemaPath
|
|
423
|
+
schemaPath,
|
|
424
|
+
"/items"
|
|
370
425
|
);
|
|
371
426
|
|
|
372
427
|
if (addedArguments > 0) {
|
|
@@ -377,10 +432,16 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
377
432
|
return addedArguments;
|
|
378
433
|
}
|
|
379
434
|
|
|
380
|
-
const
|
|
435
|
+
const ofKey = schemaPart.oneOf
|
|
436
|
+
? "oneOf"
|
|
437
|
+
: schemaPart.anyOf
|
|
438
|
+
? "anyOf"
|
|
439
|
+
: schemaPart.allOf
|
|
440
|
+
? "allOf"
|
|
441
|
+
: undefined;
|
|
381
442
|
|
|
382
|
-
if (
|
|
383
|
-
const items =
|
|
443
|
+
if (ofKey) {
|
|
444
|
+
const items = /** @type {Schema[]} */ (schemaPart[ofKey]);
|
|
384
445
|
|
|
385
446
|
for (let i = 0; i < items.length; i++) {
|
|
386
447
|
addedArguments += traverse(
|
|
@@ -388,7 +449,8 @@ const getArguments = (schema = webpackSchema) => {
|
|
|
388
449
|
(items[i]),
|
|
389
450
|
schemaPath,
|
|
390
451
|
fullPath,
|
|
391
|
-
inArray
|
|
452
|
+
inArray,
|
|
453
|
+
`/${ofKey}/${i}`
|
|
392
454
|
);
|
|
393
455
|
}
|
|
394
456
|
|
|
@@ -449,6 +511,14 @@ const cliAddedItems = new WeakMap();
|
|
|
449
511
|
|
|
450
512
|
/** @typedef {string | number} Property */
|
|
451
513
|
|
|
514
|
+
/**
|
|
515
|
+
* Whether a path segment would walk into the prototype chain.
|
|
516
|
+
* @param {string} name path segment
|
|
517
|
+
* @returns {boolean} true when the segment is unsafe to write through
|
|
518
|
+
*/
|
|
519
|
+
const isUnsafeKey = (name) =>
|
|
520
|
+
name === "__proto__" || name === "constructor" || name === "prototype";
|
|
521
|
+
|
|
452
522
|
/**
|
|
453
523
|
* Gets object and property.
|
|
454
524
|
* @param {ObjectConfiguration} config configuration
|
|
@@ -465,6 +535,14 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
|
465
535
|
for (const part of parts) {
|
|
466
536
|
const isArray = part.endsWith("[]");
|
|
467
537
|
const name = isArray ? part.slice(0, -2) : part;
|
|
538
|
+
if (isUnsafeKey(name)) {
|
|
539
|
+
return {
|
|
540
|
+
problem: {
|
|
541
|
+
type: "prototype-pollution-in-path",
|
|
542
|
+
path: parts.slice(0, i).join(".")
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
468
546
|
let value = current[name];
|
|
469
547
|
if (isArray) {
|
|
470
548
|
if (value === undefined) {
|
|
@@ -511,6 +589,14 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
|
511
589
|
current = value;
|
|
512
590
|
i++;
|
|
513
591
|
}
|
|
592
|
+
if (isUnsafeKey(property.endsWith("[]") ? property.slice(0, -2) : property)) {
|
|
593
|
+
return {
|
|
594
|
+
problem: {
|
|
595
|
+
type: "prototype-pollution-in-path",
|
|
596
|
+
path: parts.join(".")
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
514
600
|
const value = current[property];
|
|
515
601
|
if (property.endsWith("[]")) {
|
|
516
602
|
const name = property.slice(0, -2);
|
|
@@ -748,16 +834,20 @@ const processArguments = (args, config, values) => {
|
|
|
748
834
|
const isColorSupported = () => {
|
|
749
835
|
const { env = {}, argv = [], platform = "" } = process;
|
|
750
836
|
|
|
751
|
-
|
|
752
|
-
|
|
837
|
+
// Read values instead of using `in`: Deno's and Bun's `process.env` honor
|
|
838
|
+
// property access but not the `in`/`has` trap, so `"X" in env` is unreliable.
|
|
839
|
+
const isDisabled = env.NO_COLOR !== undefined || argv.includes("--no-color");
|
|
840
|
+
const isForced = env.FORCE_COLOR !== undefined || argv.includes("--color");
|
|
753
841
|
const isWindows = platform === "win32";
|
|
754
842
|
const isDumbTerminal = env.TERM === "dumb";
|
|
755
843
|
|
|
756
844
|
const isCompatibleTerminal = tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
757
845
|
|
|
758
846
|
const isCI =
|
|
759
|
-
|
|
760
|
-
(
|
|
847
|
+
env.CI !== undefined &&
|
|
848
|
+
(env.GITHUB_ACTIONS !== undefined ||
|
|
849
|
+
env.GITLAB_CI !== undefined ||
|
|
850
|
+
env.CIRCLECI !== undefined);
|
|
761
851
|
|
|
762
852
|
return (
|
|
763
853
|
!isDisabled &&
|
|
@@ -120,6 +120,44 @@ const resolve = (browsers) => {
|
|
|
120
120
|
kaios: [2, 5],
|
|
121
121
|
node: [6, 0]
|
|
122
122
|
}),
|
|
123
|
+
let: rawChecker({
|
|
124
|
+
chrome: 49,
|
|
125
|
+
and_chr: 49,
|
|
126
|
+
edge: 12,
|
|
127
|
+
firefox: 44,
|
|
128
|
+
and_ff: 44,
|
|
129
|
+
// ie: Not supported
|
|
130
|
+
opera: 36,
|
|
131
|
+
op_mob: 36,
|
|
132
|
+
safari: [10, 0],
|
|
133
|
+
ios_saf: [10, 0],
|
|
134
|
+
samsung: [5, 0],
|
|
135
|
+
android: 49,
|
|
136
|
+
and_qq: [10, 4],
|
|
137
|
+
baidu: [13, 18],
|
|
138
|
+
and_uc: [12, 12],
|
|
139
|
+
kaios: [2, 5],
|
|
140
|
+
node: [6, 0]
|
|
141
|
+
}),
|
|
142
|
+
logicalAssignment: rawChecker({
|
|
143
|
+
chrome: 85,
|
|
144
|
+
and_chr: 85,
|
|
145
|
+
edge: 85,
|
|
146
|
+
firefox: 79,
|
|
147
|
+
and_ff: 79,
|
|
148
|
+
// ie: Not supported,
|
|
149
|
+
opera: 71,
|
|
150
|
+
op_mob: 60,
|
|
151
|
+
safari: 14,
|
|
152
|
+
ios_saf: 14,
|
|
153
|
+
samsung: [14, 0],
|
|
154
|
+
android: 85,
|
|
155
|
+
and_qq: [14, 9],
|
|
156
|
+
baidu: [13, 52],
|
|
157
|
+
and_uc: [15, 5],
|
|
158
|
+
kaios: [3, 0],
|
|
159
|
+
node: [15, 0]
|
|
160
|
+
}),
|
|
123
161
|
methodShorthand: rawChecker({
|
|
124
162
|
chrome: 47,
|
|
125
163
|
and_chr: 47,
|
|
@@ -317,6 +355,62 @@ const resolve = (browsers) => {
|
|
|
317
355
|
kaios: [3, 0],
|
|
318
356
|
node: 14
|
|
319
357
|
}),
|
|
358
|
+
symbol: rawChecker({
|
|
359
|
+
chrome: 38,
|
|
360
|
+
and_chr: 38,
|
|
361
|
+
edge: 12,
|
|
362
|
+
firefox: 36,
|
|
363
|
+
and_ff: 36,
|
|
364
|
+
// ie: Not supported,
|
|
365
|
+
opera: 25,
|
|
366
|
+
op_mob: 25,
|
|
367
|
+
safari: 9,
|
|
368
|
+
ios_saf: 9,
|
|
369
|
+
samsung: [3, 0],
|
|
370
|
+
android: 38,
|
|
371
|
+
and_qq: [10, 4],
|
|
372
|
+
and_uc: [12, 12],
|
|
373
|
+
kaios: [2, 5],
|
|
374
|
+
node: [0, 12]
|
|
375
|
+
}),
|
|
376
|
+
hasOwn: rawChecker({
|
|
377
|
+
chrome: 93,
|
|
378
|
+
and_chr: 93,
|
|
379
|
+
edge: 93,
|
|
380
|
+
firefox: 92,
|
|
381
|
+
and_ff: 92,
|
|
382
|
+
// ie: Not supported,
|
|
383
|
+
opera: 79,
|
|
384
|
+
op_mob: 66,
|
|
385
|
+
safari: [15, 4],
|
|
386
|
+
ios_saf: [15, 4],
|
|
387
|
+
samsung: 17,
|
|
388
|
+
android: 93,
|
|
389
|
+
// and_qq: Not supported
|
|
390
|
+
// baidu: Not supported
|
|
391
|
+
// and_uc: Not supported
|
|
392
|
+
// kaios: Not supported
|
|
393
|
+
node: [16, 9]
|
|
394
|
+
}),
|
|
395
|
+
spread: rawChecker({
|
|
396
|
+
chrome: 60,
|
|
397
|
+
and_chr: 60,
|
|
398
|
+
edge: 79,
|
|
399
|
+
firefox: 55,
|
|
400
|
+
and_ff: 55,
|
|
401
|
+
// ie: Not supported,
|
|
402
|
+
opera: 47,
|
|
403
|
+
op_mob: 44,
|
|
404
|
+
safari: [11, 1],
|
|
405
|
+
ios_saf: [11, 3],
|
|
406
|
+
samsung: [8, 2],
|
|
407
|
+
android: 60,
|
|
408
|
+
and_qq: [13, 1],
|
|
409
|
+
// baidu: Not supported
|
|
410
|
+
and_uc: [15, 5],
|
|
411
|
+
kaios: [3, 0],
|
|
412
|
+
node: [8, 3]
|
|
413
|
+
}),
|
|
320
414
|
templateLiteral: rawChecker({
|
|
321
415
|
chrome: 41,
|
|
322
416
|
and_chr: 41,
|
|
@@ -380,6 +474,11 @@ const resolve = (browsers) => {
|
|
|
380
474
|
rawChecker({
|
|
381
475
|
node: [22, 16]
|
|
382
476
|
}),
|
|
477
|
+
nodeBuiltinModuleGetter:
|
|
478
|
+
nodeProperty &&
|
|
479
|
+
rawChecker({
|
|
480
|
+
node: [22, 3]
|
|
481
|
+
}),
|
|
383
482
|
require: nodeProperty
|
|
384
483
|
};
|
|
385
484
|
};
|