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/config/defaults.js
CHANGED
|
@@ -103,6 +103,7 @@ const {
|
|
|
103
103
|
* devtoolNamespace: NonNullable<Output["devtoolNamespace"]>,
|
|
104
104
|
* publicPath: NonNullable<Output["publicPath"]>,
|
|
105
105
|
* workerPublicPath: NonNullable<Output["workerPublicPath"]>,
|
|
106
|
+
* workerChunkFilename: NonNullable<Output["workerChunkFilename"]>,
|
|
106
107
|
* workerWasmLoading: NonNullable<Output["workerWasmLoading"]>,
|
|
107
108
|
* workerChunkLoading: NonNullable<Output["workerChunkLoading"]>,
|
|
108
109
|
* chunkFormat: NonNullable<Output["chunkFormat"]>,
|
|
@@ -123,6 +124,7 @@ const {
|
|
|
123
124
|
* compareBeforeEmit: NonNullable<Output["compareBeforeEmit"]>,
|
|
124
125
|
* strictModuleErrorHandling: NonNullable<Output["strictModuleErrorHandling"]>,
|
|
125
126
|
* strictModuleExceptionHandling: NonNullable<Output["strictModuleExceptionHandling"]>,
|
|
127
|
+
* strictModuleResolution: NonNullable<Output["strictModuleResolution"]>,
|
|
126
128
|
* importFunctionName: NonNullable<Output["importFunctionName"]>,
|
|
127
129
|
* importMetaName: NonNullable<Output["importMetaName"]>,
|
|
128
130
|
* environment: RecursiveNonNullable<Output["environment"]>,
|
|
@@ -160,6 +162,7 @@ const {
|
|
|
160
162
|
* usedExports: NonNullable<Optimization["usedExports"]>,
|
|
161
163
|
* mangleExports: NonNullable<Optimization["mangleExports"]>,
|
|
162
164
|
* innerGraph: NonNullable<Optimization["innerGraph"]>,
|
|
165
|
+
* inlineExports: NonNullable<Optimization["inlineExports"]>,
|
|
163
166
|
* concatenateModules: NonNullable<Optimization["concatenateModules"]>,
|
|
164
167
|
* avoidEntryIife: NonNullable<Optimization["avoidEntryIife"]>,
|
|
165
168
|
* emitOnErrors: NonNullable<Optimization["emitOnErrors"]>,
|
|
@@ -525,6 +528,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
525
528
|
css:
|
|
526
529
|
/** @type {NonNullable<ExperimentsNormalized["css"]>} */
|
|
527
530
|
(options.experiments.css),
|
|
531
|
+
html:
|
|
532
|
+
/** @type {NonNullable<ExperimentsNormalized["html"]>} */
|
|
533
|
+
(options.experiments.html),
|
|
528
534
|
typescript:
|
|
529
535
|
/** @type {NonNullable<ExperimentsNormalized["typescript"]>} */
|
|
530
536
|
(options.experiments.typescript)
|
|
@@ -546,8 +552,13 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
|
546
552
|
browser: targetProperties.browser,
|
|
547
553
|
webworker: targetProperties.webworker,
|
|
548
554
|
node: targetProperties.node,
|
|
555
|
+
deno: targetProperties.deno,
|
|
556
|
+
bun: targetProperties.bun,
|
|
549
557
|
nwjs: targetProperties.nwjs,
|
|
550
|
-
electron: targetProperties.electron
|
|
558
|
+
electron: targetProperties.electron,
|
|
559
|
+
// spans both web and node (target "universal" or ["web", "node"])
|
|
560
|
+
universal:
|
|
561
|
+
targetProperties.node === null && targetProperties.web === null
|
|
551
562
|
}
|
|
552
563
|
};
|
|
553
564
|
};
|
|
@@ -570,7 +581,19 @@ const applyExperimentsDefaults = (
|
|
|
570
581
|
// TODO do we need sync web assembly in webpack@6?
|
|
571
582
|
D(experiments, "syncWebAssembly", false);
|
|
572
583
|
D(experiments, "asyncWebAssembly", experiments.futureDefaults);
|
|
573
|
-
|
|
584
|
+
// the universal target (web + node, neither specific) only works as ESM
|
|
585
|
+
const universal =
|
|
586
|
+
Boolean(targetProperties) &&
|
|
587
|
+
/** @type {TargetProperties} */ (targetProperties).node === null &&
|
|
588
|
+
/** @type {TargetProperties} */ (targetProperties).web === null;
|
|
589
|
+
// the deno and bun targets only emit ECMAScript modules
|
|
590
|
+
const deno =
|
|
591
|
+
Boolean(targetProperties) &&
|
|
592
|
+
/** @type {TargetProperties} */ (targetProperties).deno === true;
|
|
593
|
+
const bun =
|
|
594
|
+
Boolean(targetProperties) &&
|
|
595
|
+
/** @type {TargetProperties} */ (targetProperties).bun === true;
|
|
596
|
+
D(experiments, "outputModule", universal || deno || bun);
|
|
574
597
|
D(experiments, "lazyCompilation", undefined);
|
|
575
598
|
D(experiments, "buildHttp", undefined);
|
|
576
599
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
|
@@ -1090,6 +1113,18 @@ const applyModuleDefaults = (
|
|
|
1090
1113
|
// modules (including imported ones); `extract: false` disables it
|
|
1091
1114
|
// everywhere.
|
|
1092
1115
|
F(module.generator, HTML_MODULE_TYPE, () => ({}));
|
|
1116
|
+
// `module.parser.html.sources` defaults to `true` — HtmlParser uses
|
|
1117
|
+
// the built-in source list to extract URL-like attributes (`<img
|
|
1118
|
+
// src>`, `<link href>`, `<script src>`, …) as webpack dependencies.
|
|
1119
|
+
// Users may pass `false` to disable extraction entirely or an array
|
|
1120
|
+
// (with `"..."` to include the defaults) to customize it.
|
|
1121
|
+
F(module.parser, HTML_MODULE_TYPE, () => ({}));
|
|
1122
|
+
D(
|
|
1123
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[HTML_MODULE_TYPE]>} */
|
|
1124
|
+
(module.parser[HTML_MODULE_TYPE]),
|
|
1125
|
+
"sources",
|
|
1126
|
+
true
|
|
1127
|
+
);
|
|
1093
1128
|
}
|
|
1094
1129
|
|
|
1095
1130
|
A(module, "defaultRules", () => {
|
|
@@ -1268,6 +1303,18 @@ const applyModuleDefaults = (
|
|
|
1268
1303
|
type: HTML_MODULE_TYPE,
|
|
1269
1304
|
resolve
|
|
1270
1305
|
});
|
|
1306
|
+
// `<iframe srcdoc>` content is fed back through the HTML pipeline as a
|
|
1307
|
+
// `data:text/html` module. `extract: "inline"` exposes the processed
|
|
1308
|
+
// HTML on the `html` codegen channel that `HtmlInlineHtmlDependency.
|
|
1309
|
+
// Template` reads back into the attribute, without emitting a standalone
|
|
1310
|
+
// `.html` file (the module is never a page on its own).
|
|
1311
|
+
rules.push({
|
|
1312
|
+
dependency: "html-srcdoc",
|
|
1313
|
+
generator: {
|
|
1314
|
+
extract: "inline"
|
|
1315
|
+
},
|
|
1316
|
+
resolve
|
|
1317
|
+
});
|
|
1271
1318
|
if (css) {
|
|
1272
1319
|
// Inline `<style>` content in an HTML module is fed into the
|
|
1273
1320
|
// CSS pipeline as a `data:text/css` virtual module. We force
|
|
@@ -1282,6 +1329,16 @@ const applyModuleDefaults = (
|
|
|
1282
1329
|
},
|
|
1283
1330
|
resolve
|
|
1284
1331
|
});
|
|
1332
|
+
// A `style="..."` attribute is a CSS block's contents, not a
|
|
1333
|
+
// stylesheet, so parse it as one (`as: "block-contents"`).
|
|
1334
|
+
rules.push({
|
|
1335
|
+
dependency: "html-style-attribute",
|
|
1336
|
+
parser: {
|
|
1337
|
+
exportType: "text",
|
|
1338
|
+
as: "block-contents"
|
|
1339
|
+
},
|
|
1340
|
+
resolve
|
|
1341
|
+
});
|
|
1285
1342
|
}
|
|
1286
1343
|
}
|
|
1287
1344
|
|
|
@@ -1452,6 +1509,17 @@ const applyOutputDefaults = (
|
|
|
1452
1509
|
"globalThis",
|
|
1453
1510
|
() => /** @type {boolean | undefined} */ (tp && tp.globalThis)
|
|
1454
1511
|
);
|
|
1512
|
+
F(
|
|
1513
|
+
environment,
|
|
1514
|
+
"symbol",
|
|
1515
|
+
() => tp && optimistic(/** @type {boolean | undefined} */ (tp.symbol))
|
|
1516
|
+
);
|
|
1517
|
+
F(
|
|
1518
|
+
environment,
|
|
1519
|
+
"hasOwn",
|
|
1520
|
+
// No optimistic, because it is new
|
|
1521
|
+
() => tp && /** @type {boolean | undefined} */ (tp.hasOwn)
|
|
1522
|
+
);
|
|
1455
1523
|
F(
|
|
1456
1524
|
environment,
|
|
1457
1525
|
"bigIntLiteral",
|
|
@@ -1463,6 +1531,22 @@ const applyOutputDefaults = (
|
|
|
1463
1531
|
"const",
|
|
1464
1532
|
() => tp && optimistic(/** @type {boolean | undefined} */ (tp.const))
|
|
1465
1533
|
);
|
|
1534
|
+
// `let` was added after `const`; targets predating it report only `const`,
|
|
1535
|
+
// so fall back to `const` when `let` is unreported (undefined). Targets that
|
|
1536
|
+
// do report `let` (browserslist, built-ins) keep their own accurate value.
|
|
1537
|
+
F(environment, "let", () =>
|
|
1538
|
+
conditionallyOptimistic(
|
|
1539
|
+
/** @type {boolean | undefined} */ (tp && tp.let),
|
|
1540
|
+
environment.const
|
|
1541
|
+
)
|
|
1542
|
+
);
|
|
1543
|
+
F(
|
|
1544
|
+
environment,
|
|
1545
|
+
"logicalAssignment",
|
|
1546
|
+
() =>
|
|
1547
|
+
// No optimistic, because it is new
|
|
1548
|
+
tp && /** @type {boolean | undefined} */ (tp.logicalAssignment)
|
|
1549
|
+
);
|
|
1466
1550
|
F(
|
|
1467
1551
|
environment,
|
|
1468
1552
|
"methodShorthand",
|
|
@@ -1498,6 +1582,11 @@ const applyOutputDefaults = (
|
|
|
1498
1582
|
() =>
|
|
1499
1583
|
tp && optimistic(/** @type {boolean | undefined} */ (tp.optionalChaining))
|
|
1500
1584
|
);
|
|
1585
|
+
F(
|
|
1586
|
+
environment,
|
|
1587
|
+
"spread",
|
|
1588
|
+
() => tp && optimistic(/** @type {boolean | undefined} */ (tp.spread))
|
|
1589
|
+
);
|
|
1501
1590
|
F(
|
|
1502
1591
|
environment,
|
|
1503
1592
|
"nodePrefixForCoreModules",
|
|
@@ -1514,6 +1603,13 @@ const applyOutputDefaults = (
|
|
|
1514
1603
|
// No optimistic, because it is new
|
|
1515
1604
|
tp && /** @type {boolean | undefined} */ (tp.importMetaDirnameAndFilename)
|
|
1516
1605
|
);
|
|
1606
|
+
F(
|
|
1607
|
+
environment,
|
|
1608
|
+
"nodeBuiltinModuleGetter",
|
|
1609
|
+
() =>
|
|
1610
|
+
// No optimistic, because it is new
|
|
1611
|
+
tp && /** @type {boolean | undefined} */ (tp.nodeBuiltinModuleGetter)
|
|
1612
|
+
);
|
|
1517
1613
|
F(
|
|
1518
1614
|
environment,
|
|
1519
1615
|
"templateLiteral",
|
|
@@ -1619,6 +1715,7 @@ const applyOutputDefaults = (
|
|
|
1619
1715
|
}
|
|
1620
1716
|
return "[name].html";
|
|
1621
1717
|
});
|
|
1718
|
+
D(output, "html", false);
|
|
1622
1719
|
D(output, "assetModuleFilename", "[hash][ext][query][fragment]");
|
|
1623
1720
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
|
1624
1721
|
D(output, "compareBeforeEmit", true);
|
|
@@ -1633,7 +1730,10 @@ const applyOutputDefaults = (
|
|
|
1633
1730
|
if (tp.global) return "global";
|
|
1634
1731
|
if (tp.globalThis) return "globalThis";
|
|
1635
1732
|
// For universal target (i.e. code can be run in browser/node/worker etc.)
|
|
1636
|
-
|
|
1733
|
+
// `tp.module` is unset for a version-less universal target, so key off ESM output
|
|
1734
|
+
if (tp.web === null && tp.node === null && output.module) {
|
|
1735
|
+
return "globalThis";
|
|
1736
|
+
}
|
|
1637
1737
|
}
|
|
1638
1738
|
return "self";
|
|
1639
1739
|
});
|
|
@@ -1700,6 +1800,13 @@ const applyOutputDefaults = (
|
|
|
1700
1800
|
}
|
|
1701
1801
|
return false;
|
|
1702
1802
|
});
|
|
1803
|
+
F(
|
|
1804
|
+
output,
|
|
1805
|
+
"workerChunkFilename",
|
|
1806
|
+
() =>
|
|
1807
|
+
/** @type {NonNullable<Output["workerChunkFilename"]>} */
|
|
1808
|
+
(output.chunkFilename)
|
|
1809
|
+
);
|
|
1703
1810
|
F(output, "workerChunkLoading", () => {
|
|
1704
1811
|
if (tp) {
|
|
1705
1812
|
switch (output.chunkFormat) {
|
|
@@ -1781,6 +1888,7 @@ const applyOutputDefaults = (
|
|
|
1781
1888
|
D(output, "hashDigestLength", futureDefaults ? 16 : 20);
|
|
1782
1889
|
D(output, "strictModuleErrorHandling", false);
|
|
1783
1890
|
D(output, "strictModuleExceptionHandling", false);
|
|
1891
|
+
F(output, "strictModuleResolution", () => development);
|
|
1784
1892
|
|
|
1785
1893
|
const { trustedTypes } = output;
|
|
1786
1894
|
if (trustedTypes) {
|
|
@@ -1888,7 +1996,25 @@ const applyExternalsPresetsDefaults = (
|
|
|
1888
1996
|
externalsPresets,
|
|
1889
1997
|
"node",
|
|
1890
1998
|
/** @type {boolean | undefined} */
|
|
1891
|
-
(
|
|
1999
|
+
(
|
|
2000
|
+
targetProperties &&
|
|
2001
|
+
((targetProperties.node &&
|
|
2002
|
+
!targetProperties.deno &&
|
|
2003
|
+
!targetProperties.bun) ||
|
|
2004
|
+
isUniversal("node"))
|
|
2005
|
+
)
|
|
2006
|
+
);
|
|
2007
|
+
D(
|
|
2008
|
+
externalsPresets,
|
|
2009
|
+
"deno",
|
|
2010
|
+
/** @type {boolean | undefined} */
|
|
2011
|
+
(Boolean(targetProperties && targetProperties.deno))
|
|
2012
|
+
);
|
|
2013
|
+
D(
|
|
2014
|
+
externalsPresets,
|
|
2015
|
+
"bun",
|
|
2016
|
+
/** @type {boolean | undefined} */
|
|
2017
|
+
(Boolean(targetProperties && targetProperties.bun))
|
|
1892
2018
|
);
|
|
1893
2019
|
D(
|
|
1894
2020
|
externalsPresets,
|
|
@@ -1952,6 +2078,8 @@ const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
|
|
|
1952
2078
|
return "electron";
|
|
1953
2079
|
}
|
|
1954
2080
|
if (targetProperties.nwjs) return "nwjs";
|
|
2081
|
+
if (targetProperties.deno) return "deno";
|
|
2082
|
+
if (targetProperties.bun) return "bun";
|
|
1955
2083
|
if (targetProperties.node) return "node";
|
|
1956
2084
|
if (targetProperties.web) return "web";
|
|
1957
2085
|
}
|
|
@@ -2051,6 +2179,7 @@ const applyOptimizationDefaults = (
|
|
|
2051
2179
|
D(optimization, "providedExports", true);
|
|
2052
2180
|
D(optimization, "usedExports", production);
|
|
2053
2181
|
D(optimization, "innerGraph", production);
|
|
2182
|
+
D(optimization, "inlineExports", production);
|
|
2054
2183
|
D(optimization, "mangleExports", production);
|
|
2055
2184
|
D(optimization, "concatenateModules", production);
|
|
2056
2185
|
D(optimization, "avoidEntryIife", production);
|
|
@@ -2064,8 +2193,8 @@ const applyOptimizationDefaults = (
|
|
|
2064
2193
|
A(optimization, "minimizer", () => [
|
|
2065
2194
|
{
|
|
2066
2195
|
apply: (compiler) => {
|
|
2067
|
-
// Lazy load the
|
|
2068
|
-
const TerserPlugin = require("
|
|
2196
|
+
// Lazy load the minimizer plugin
|
|
2197
|
+
const TerserPlugin = require("minimizer-webpack-plugin");
|
|
2069
2198
|
|
|
2070
2199
|
new TerserPlugin({
|
|
2071
2200
|
terserOptions: {
|
|
@@ -2125,6 +2254,7 @@ const applyOptimizationDefaults = (
|
|
|
2125
2254
|
* @param {TargetProperties | false} options.targetProperties target properties
|
|
2126
2255
|
* @param {Mode} options.mode mode
|
|
2127
2256
|
* @param {boolean} options.css is css enabled
|
|
2257
|
+
* @param {boolean} options.html is html enabled
|
|
2128
2258
|
* @param {boolean} options.typescript is typescript enabled
|
|
2129
2259
|
* @returns {ResolveOptions} resolve options
|
|
2130
2260
|
*/
|
|
@@ -2134,6 +2264,7 @@ const getResolveDefaults = ({
|
|
|
2134
2264
|
targetProperties,
|
|
2135
2265
|
mode,
|
|
2136
2266
|
css,
|
|
2267
|
+
html,
|
|
2137
2268
|
typescript
|
|
2138
2269
|
}) => {
|
|
2139
2270
|
/** @type {string[]} */
|
|
@@ -2142,6 +2273,8 @@ const getResolveDefaults = ({
|
|
|
2142
2273
|
conditions.push(mode === "development" ? "development" : "production");
|
|
2143
2274
|
|
|
2144
2275
|
if (targetProperties) {
|
|
2276
|
+
if (targetProperties.deno) conditions.push("deno");
|
|
2277
|
+
if (targetProperties.bun) conditions.push("bun");
|
|
2145
2278
|
if (targetProperties.webworker) conditions.push("worker");
|
|
2146
2279
|
if (targetProperties.node) conditions.push("node");
|
|
2147
2280
|
if (targetProperties.web) conditions.push("browser");
|
|
@@ -2153,6 +2286,13 @@ const getResolveDefaults = ({
|
|
|
2153
2286
|
? [".ts", ".js", ".json", ".wasm"]
|
|
2154
2287
|
: [".js", ".json", ".wasm"];
|
|
2155
2288
|
|
|
2289
|
+
// HTML-first when enabled: `.html` outranks `.js`, `.css` is the last fallback.
|
|
2290
|
+
const esmResolveExtensions = [
|
|
2291
|
+
...(html ? [".html"] : []),
|
|
2292
|
+
...jsExtensions,
|
|
2293
|
+
...(css ? [".css"] : [])
|
|
2294
|
+
];
|
|
2295
|
+
|
|
2156
2296
|
const tp = targetProperties;
|
|
2157
2297
|
const browserField =
|
|
2158
2298
|
tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer));
|
|
@@ -2186,7 +2326,7 @@ const getResolveDefaults = ({
|
|
|
2186
2326
|
"module",
|
|
2187
2327
|
"..."
|
|
2188
2328
|
],
|
|
2189
|
-
extensions: [...
|
|
2329
|
+
extensions: [...esmResolveExtensions]
|
|
2190
2330
|
});
|
|
2191
2331
|
|
|
2192
2332
|
/** @type {() => ResolveOptions} */
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Alexander Akait @alexander-akait
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} Configuration */
|
|
9
|
+
/** @typedef {import("../MultiCompiler").MultiWebpackOptions} MultiConfiguration */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @template T
|
|
13
|
+
* @typedef {T | Promise<T>} MaybePromise
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Function style configuration, called with the `--env` values and CLI arguments.
|
|
18
|
+
* @typedef {(env: Record<string, EXPECTED_ANY>, argv: Record<string, EXPECTED_ANY>) => MaybePromise<Configuration | MultiConfiguration>} ConfigurationFactory
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @typedef {MaybePromise<Configuration | MultiConfiguration | ConfigurationFactory | ConfigurationFactory[]>} DefineConfigInput */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A type helper for authoring configuration files, no-op at runtime.
|
|
25
|
+
* @template {DefineConfigInput} T
|
|
26
|
+
* @param {T} config webpack configuration
|
|
27
|
+
* @returns {T} the same configuration
|
|
28
|
+
*/
|
|
29
|
+
const defineConfig = (config) => config;
|
|
30
|
+
|
|
31
|
+
module.exports = defineConfig;
|
|
@@ -368,6 +368,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
368
368
|
hotUpdateChunkFilename: output.hotUpdateChunkFilename,
|
|
369
369
|
hotUpdateGlobal: output.hotUpdateGlobal,
|
|
370
370
|
hotUpdateMainFilename: output.hotUpdateMainFilename,
|
|
371
|
+
html: output.html,
|
|
371
372
|
htmlChunkFilename: output.htmlChunkFilename,
|
|
372
373
|
htmlFilename: output.htmlFilename,
|
|
373
374
|
ignoreBrowserWarnings: output.ignoreBrowserWarnings,
|
|
@@ -407,6 +408,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
407
408
|
sourcePrefix: output.sourcePrefix,
|
|
408
409
|
strictModuleErrorHandling: output.strictModuleErrorHandling,
|
|
409
410
|
strictModuleExceptionHandling: output.strictModuleExceptionHandling,
|
|
411
|
+
strictModuleResolution: output.strictModuleResolution,
|
|
410
412
|
trustedTypes: optionalNestedConfig(
|
|
411
413
|
output.trustedTypes,
|
|
412
414
|
(trustedTypes) => {
|
|
@@ -421,6 +423,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
421
423
|
wasmLoading: output.wasmLoading,
|
|
422
424
|
webassemblyModuleFilename: output.webassemblyModuleFilename,
|
|
423
425
|
workerPublicPath: output.workerPublicPath,
|
|
426
|
+
workerChunkFilename: output.workerChunkFilename,
|
|
424
427
|
workerChunkLoading: output.workerChunkLoading,
|
|
425
428
|
workerWasmLoading: output.workerWasmLoading
|
|
426
429
|
};
|
|
@@ -551,6 +554,7 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
551
554
|
(Array.isArray(value.import) ? value.import : [value.import])
|
|
552
555
|
),
|
|
553
556
|
filename: value.filename,
|
|
557
|
+
html: value.html,
|
|
554
558
|
layer: value.layer,
|
|
555
559
|
runtime: value.runtime,
|
|
556
560
|
baseUri: value.baseUri,
|
|
@@ -558,6 +562,7 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
558
562
|
chunkLoading: value.chunkLoading,
|
|
559
563
|
asyncChunks: value.asyncChunks,
|
|
560
564
|
wasmLoading: value.wasmLoading,
|
|
565
|
+
worker: value.worker,
|
|
561
566
|
dependOn:
|
|
562
567
|
/** @type {EntryDescriptionNormalized["dependOn"]} */
|
|
563
568
|
(
|