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/DefinePlugin.js
CHANGED
|
@@ -31,9 +31,11 @@ const createHash = require("./util/createHash");
|
|
|
31
31
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
32
32
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
33
33
|
/** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */
|
|
34
|
+
/** @typedef {import("./javascript/JavascriptParser").Members} Members */
|
|
34
35
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
35
36
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
|
36
37
|
/** @typedef {import("./Compilation")} Compilation */
|
|
38
|
+
/** @typedef {import("./NormalModule").NormalModuleBuildInfo} NormalModuleBuildInfo */
|
|
37
39
|
|
|
38
40
|
/** @typedef {null | undefined | RegExp | EXPECTED_FUNCTION | string | number | boolean | bigint | undefined} CodeValuePrimitive */
|
|
39
41
|
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive | RuntimeValue>} CodeValue */
|
|
@@ -140,6 +142,17 @@ function getObjKeys(properties) {
|
|
|
140
142
|
return new Set([...properties].map((p) => p.id));
|
|
141
143
|
}
|
|
142
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Whether a value is a nested definition (plain object/array) to recurse into.
|
|
147
|
+
* @param {CodeValue} code code value
|
|
148
|
+
* @returns {code is Definitions} true for a plain object or array
|
|
149
|
+
*/
|
|
150
|
+
const isObjectDefinition = (code) =>
|
|
151
|
+
Boolean(code) &&
|
|
152
|
+
typeof code === "object" &&
|
|
153
|
+
!(code instanceof RuntimeValue) &&
|
|
154
|
+
!(code instanceof RegExp);
|
|
155
|
+
|
|
143
156
|
/** @typedef {Set<string> | null} ObjKeys */
|
|
144
157
|
/** @typedef {boolean | undefined | null} AsiSafe */
|
|
145
158
|
|
|
@@ -439,7 +452,7 @@ class DefinePlugin {
|
|
|
439
452
|
/** @type {ValueCacheVersion} */
|
|
440
453
|
(compilation.valueCacheVersions.get(VALUE_DEP_MAIN));
|
|
441
454
|
parser.hooks.program.tap(PLUGIN_NAME, () => {
|
|
442
|
-
const buildInfo = /** @type {
|
|
455
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (
|
|
443
456
|
parser.state.module.buildInfo
|
|
444
457
|
);
|
|
445
458
|
if (!buildInfo.valueDependencies) {
|
|
@@ -454,9 +467,9 @@ class DefinePlugin {
|
|
|
454
467
|
*/
|
|
455
468
|
const addValueDependency = (key) => {
|
|
456
469
|
const buildInfo =
|
|
457
|
-
/** @type {
|
|
470
|
+
/** @type {NormalModuleBuildInfo} */
|
|
458
471
|
(parser.state.module.buildInfo);
|
|
459
|
-
/** @type {NonNullable<
|
|
472
|
+
/** @type {NonNullable<NormalModuleBuildInfo["valueDependencies"]>} */
|
|
460
473
|
(buildInfo.valueDependencies).set(
|
|
461
474
|
VALUE_DEP_PREFIX + key,
|
|
462
475
|
/** @type {ValueCacheVersion} */
|
|
@@ -487,12 +500,7 @@ class DefinePlugin {
|
|
|
487
500
|
const walkDefinitions = (definitions, prefix) => {
|
|
488
501
|
for (const key of Object.keys(definitions)) {
|
|
489
502
|
const code = definitions[key];
|
|
490
|
-
if (
|
|
491
|
-
code &&
|
|
492
|
-
typeof code === "object" &&
|
|
493
|
-
!(code instanceof RuntimeValue) &&
|
|
494
|
-
!(code instanceof RegExp)
|
|
495
|
-
) {
|
|
503
|
+
if (isObjectDefinition(code)) {
|
|
496
504
|
walkDefinitions(
|
|
497
505
|
/** @type {Definitions} */ (code),
|
|
498
506
|
`${prefix + key}.`
|
|
@@ -774,6 +782,77 @@ class DefinePlugin {
|
|
|
774
782
|
}
|
|
775
783
|
return toConstantDependency(parser, strCode)(expr);
|
|
776
784
|
});
|
|
785
|
+
// A property access not defined on the object resolves to `undefined`
|
|
786
|
+
// and the whole object is never inlined (issue #15559). Keyed by the
|
|
787
|
+
// chain root so dotted object keys (e.g. `a.b`) are also covered.
|
|
788
|
+
const chainParts = key.split(".");
|
|
789
|
+
// `import.meta` is one chain root (a MetaProperty), not two members.
|
|
790
|
+
const isMeta =
|
|
791
|
+
chainParts[0] === "import" && chainParts[1] === "meta";
|
|
792
|
+
const chainRoot = isMeta ? "import.meta" : chainParts[0];
|
|
793
|
+
const chainPrefix = chainParts.slice(isMeta ? 2 : 1);
|
|
794
|
+
/**
|
|
795
|
+
* Whether a member chain reads a property that is not defined.
|
|
796
|
+
* Collects every define key consulted so the caller can record a
|
|
797
|
+
* value dependency on each (a sibling key like `OBJECT.SUB2` affects
|
|
798
|
+
* the result even though `OBJECT` registered the handler).
|
|
799
|
+
* `member in value` keeps inherited members (e.g. `toString`) defined.
|
|
800
|
+
* @param {Members} members chain members (after the root)
|
|
801
|
+
* @param {string[]} deps consulted define keys (mutated)
|
|
802
|
+
* @returns {boolean} true when the access resolves to `undefined`
|
|
803
|
+
*/
|
|
804
|
+
const isUndefinedMemberAccess = (members, deps) => {
|
|
805
|
+
if (members.length <= chainPrefix.length) return false;
|
|
806
|
+
for (let i = 0; i < chainPrefix.length; i++) {
|
|
807
|
+
if (members[i] !== chainPrefix[i]) return false;
|
|
808
|
+
}
|
|
809
|
+
/** @type {CodeValue} */
|
|
810
|
+
let value = /** @type {CodeValue} */ (obj);
|
|
811
|
+
let path = key;
|
|
812
|
+
for (let i = chainPrefix.length; i < members.length; i++) {
|
|
813
|
+
// a leaf with members left is a real property access on a value
|
|
814
|
+
if (!isObjectDefinition(value)) return false;
|
|
815
|
+
const member = members[i];
|
|
816
|
+
const nextPath = `${path}.${member}`;
|
|
817
|
+
if (member in value) {
|
|
818
|
+
value = value[member];
|
|
819
|
+
} else if (
|
|
820
|
+
Object.prototype.hasOwnProperty.call(definitions, nextPath)
|
|
821
|
+
) {
|
|
822
|
+
// defined via a dotted sibling key, e.g. `OBJECT.SUB2`
|
|
823
|
+
deps.push(nextPath);
|
|
824
|
+
value = definitions[nextPath];
|
|
825
|
+
} else {
|
|
826
|
+
return true;
|
|
827
|
+
}
|
|
828
|
+
path = nextPath;
|
|
829
|
+
}
|
|
830
|
+
return false;
|
|
831
|
+
};
|
|
832
|
+
parser.hooks.expressionMemberChain
|
|
833
|
+
.for(chainRoot)
|
|
834
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
835
|
+
const deps = [key];
|
|
836
|
+
if (!isUndefinedMemberAccess(members, deps)) return;
|
|
837
|
+
for (const dep of deps) addValueDependency(dep);
|
|
838
|
+
return toConstantDependency(parser, "undefined")(expr);
|
|
839
|
+
});
|
|
840
|
+
// In a call, replace only the callee so the call itself is kept:
|
|
841
|
+
// `x.MISSING()` stays a (throwing) call and `x.MISSING?.()`
|
|
842
|
+
// short-circuits, with the object never inlined.
|
|
843
|
+
parser.hooks.callMemberChain
|
|
844
|
+
.for(chainRoot)
|
|
845
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
846
|
+
const deps = [key];
|
|
847
|
+
if (!isUndefinedMemberAccess(members, deps)) return;
|
|
848
|
+
for (const dep of deps) addValueDependency(dep);
|
|
849
|
+
toConstantDependency(
|
|
850
|
+
parser,
|
|
851
|
+
"undefined"
|
|
852
|
+
)(/** @type {Expression} */ (expr.callee));
|
|
853
|
+
parser.walkExpressions(expr.arguments);
|
|
854
|
+
return true;
|
|
855
|
+
});
|
|
777
856
|
parser.hooks.typeof
|
|
778
857
|
.for(key)
|
|
779
858
|
.tap(
|
|
@@ -821,12 +900,7 @@ class DefinePlugin {
|
|
|
821
900
|
warning.hideStack = true;
|
|
822
901
|
compilation.warnings.push(warning);
|
|
823
902
|
}
|
|
824
|
-
if (
|
|
825
|
-
code &&
|
|
826
|
-
typeof code === "object" &&
|
|
827
|
-
!(code instanceof RuntimeValue) &&
|
|
828
|
-
!(code instanceof RegExp)
|
|
829
|
-
) {
|
|
903
|
+
if (isObjectDefinition(code)) {
|
|
830
904
|
walkDefinitionsForValues(
|
|
831
905
|
/** @type {Definitions} */ (code),
|
|
832
906
|
`${prefix + key}.`
|
package/lib/Dependency.js
CHANGED
|
@@ -60,11 +60,13 @@ const memoize = require("./util/memoize");
|
|
|
60
60
|
* @property {ExportInfoName} name the name of the export
|
|
61
61
|
* @property {boolean=} canMangle can the export be renamed (defaults to true)
|
|
62
62
|
* @property {boolean=} terminalBinding is the export a terminal binding that should be checked for export star conflicts
|
|
63
|
+
* @property {boolean=} isPure calling this export has no observable side effects
|
|
63
64
|
* @property {(string | ExportSpec)[]=} exports nested exports
|
|
64
65
|
* @property {ModuleGraphConnection=} from when reexported: from which module
|
|
65
66
|
* @property {string[] | null=} export when reexported: from which export
|
|
66
67
|
* @property {number=} priority when reexported: with which priority
|
|
67
68
|
* @property {boolean=} hidden export is not visible, because another export blends over it
|
|
69
|
+
* @property {import("./optimize/InlineExports").InlinedValue=} inlined when set: the export binds to a small primitive constant eligible for inlining
|
|
68
70
|
*/
|
|
69
71
|
|
|
70
72
|
/** @typedef {Set<string>} ExportsSpecExcludeExports */
|
|
@@ -79,6 +81,7 @@ const memoize = require("./util/memoize");
|
|
|
79
81
|
* @property {number=} priority when reexported: with which priority
|
|
80
82
|
* @property {boolean=} canMangle can the export be renamed (defaults to true)
|
|
81
83
|
* @property {boolean=} terminalBinding are the exports terminal bindings that should be checked for export star conflicts
|
|
84
|
+
* @property {boolean=} isPure calling these exports has no observable side effects
|
|
82
85
|
* @property {Module[]=} dependencies module on which the result depends on
|
|
83
86
|
*/
|
|
84
87
|
|
|
@@ -87,6 +90,7 @@ const memoize = require("./util/memoize");
|
|
|
87
90
|
* @typedef {object} ReferencedExport
|
|
88
91
|
* @property {string[]} name name of the referenced export
|
|
89
92
|
* @property {boolean=} canMangle when false, referenced export can not be mangled, defaults to true
|
|
93
|
+
* @property {boolean=} canInline when false, the referenced export can not be substituted with an inlined literal at this site, defaults to true
|
|
90
94
|
*/
|
|
91
95
|
|
|
92
96
|
/** @typedef {string[][]} RawReferencedExports */
|
|
@@ -94,6 +98,20 @@ const memoize = require("./util/memoize");
|
|
|
94
98
|
|
|
95
99
|
/** @typedef {(moduleGraphConnection: ModuleGraphConnection, runtime: RuntimeSpec) => ConnectionState} GetConditionFn */
|
|
96
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Lazy barrel classification of a dependency within a side-effect-free module.
|
|
103
|
+
* `LAZY_UNTIL_LOCAL`: locally provided export name (`getLazyName`), requesting it requires no dependency.
|
|
104
|
+
* `LAZY_UNTIL_ID`: named re-export (`getLazyName`) deferred until the export name is requested.
|
|
105
|
+
* `LAZY_UNTIL_FALLBACK`: star re-export, deferred until an unknown name or all names are requested.
|
|
106
|
+
* `LAZY_UNTIL_REQUEST`: deferred together with other dependencies of the same request.
|
|
107
|
+
* @typedef {"local" | "id" | "*" | "@"} LazyUntil
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
const LAZY_UNTIL_LOCAL = /** @type {"local"} */ ("local");
|
|
111
|
+
const LAZY_UNTIL_ID = /** @type {"id"} */ ("id");
|
|
112
|
+
const LAZY_UNTIL_FALLBACK = /** @type {"*"} */ ("*");
|
|
113
|
+
const LAZY_UNTIL_REQUEST = /** @type {"@"} */ ("@");
|
|
114
|
+
|
|
97
115
|
const TRANSITIVE = /** @type {symbol} */ (Symbol("transitive"));
|
|
98
116
|
|
|
99
117
|
const getIgnoredModule = memoize(() => {
|
|
@@ -112,15 +130,16 @@ class Dependency {
|
|
|
112
130
|
this._parentDependenciesBlock = undefined;
|
|
113
131
|
/** @type {number} */
|
|
114
132
|
this._parentDependenciesBlockIndex = -1;
|
|
115
|
-
//
|
|
116
|
-
/** @type {boolean} */
|
|
117
|
-
this.weak = false;
|
|
118
|
-
// TODO check if this can be moved into ModuleDependency
|
|
133
|
+
// stays on base: also set on ContextDependency, which is not a ModuleDependency
|
|
119
134
|
/** @type {boolean | undefined} */
|
|
120
135
|
this.optional = false;
|
|
136
|
+
/** @type {number} */
|
|
121
137
|
this._locSL = 0;
|
|
138
|
+
/** @type {number} */
|
|
122
139
|
this._locSC = 0;
|
|
140
|
+
/** @type {number} */
|
|
123
141
|
this._locEL = 0;
|
|
142
|
+
/** @type {number} */
|
|
124
143
|
this._locEC = 0;
|
|
125
144
|
/** @type {undefined | number} */
|
|
126
145
|
this._locI = undefined;
|
|
@@ -189,7 +208,10 @@ class Dependency {
|
|
|
189
208
|
}
|
|
190
209
|
this._locI = "index" in loc ? loc.index : undefined;
|
|
191
210
|
this._locN = "name" in loc ? loc.name : undefined;
|
|
192
|
-
|
|
211
|
+
// Don't retain the passed object; `get loc` rebuilds it from the numbers
|
|
212
|
+
// above on demand, so dependencies whose loc is never read hold 4 numbers
|
|
213
|
+
// instead of a SourceLocation + two Position objects.
|
|
214
|
+
this._loc = undefined;
|
|
193
215
|
}
|
|
194
216
|
|
|
195
217
|
/**
|
|
@@ -209,6 +231,42 @@ class Dependency {
|
|
|
209
231
|
this._loc = undefined;
|
|
210
232
|
}
|
|
211
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Updates loc from a source location plus an explicit index, without
|
|
236
|
+
* materializing the `loc` object (keeps `get loc` lazy). Replaces the
|
|
237
|
+
* `dep.loc = Object.create(loc); dep.loc.index = i` pattern, which both
|
|
238
|
+
* allocated a copy and stored the index outside the serialized fields.
|
|
239
|
+
* @param {DependencyLocation} loc source location (start/end/name read from it)
|
|
240
|
+
* @param {number} index dependency index within the statement
|
|
241
|
+
*/
|
|
242
|
+
setLocWithIndex(loc, index) {
|
|
243
|
+
this.loc = loc;
|
|
244
|
+
this._locI = index;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Compares two dependencies by source location for sorting a module's
|
|
249
|
+
* `dependencies`, without materializing the `loc` objects (`get loc` caches
|
|
250
|
+
* its result, so comparing through it would retain a location object on every
|
|
251
|
+
* sorted dependency). These dependencies always carry a real source position,
|
|
252
|
+
* so only start (line, column) and the within-statement index are compared; a
|
|
253
|
+
* dependency without an index sorts after one that has an index at the same
|
|
254
|
+
* position.
|
|
255
|
+
* @param {Dependency} a first dependency
|
|
256
|
+
* @param {Dependency} b second dependency
|
|
257
|
+
* @returns {-1 | 0 | 1} compare result
|
|
258
|
+
*/
|
|
259
|
+
static compareLocations(a, b) {
|
|
260
|
+
if (a._locSL !== b._locSL) return a._locSL < b._locSL ? -1 : 1;
|
|
261
|
+
if (a._locSC !== b._locSC) return a._locSC < b._locSC ? -1 : 1;
|
|
262
|
+
const ai = a._locI;
|
|
263
|
+
const bi = b._locI;
|
|
264
|
+
if (ai === bi) return 0;
|
|
265
|
+
if (ai === undefined) return 1;
|
|
266
|
+
if (bi === undefined) return -1;
|
|
267
|
+
return ai < bi ? -1 : 1;
|
|
268
|
+
}
|
|
269
|
+
|
|
212
270
|
/**
|
|
213
271
|
* Returns a request context.
|
|
214
272
|
* @returns {string | undefined} a request context
|
|
@@ -233,6 +291,45 @@ class Dependency {
|
|
|
233
291
|
return TRANSITIVE;
|
|
234
292
|
}
|
|
235
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Returns the export name this dependency requests from its target module (lazy barrel optimization).
|
|
296
|
+
* @returns {string | true | null} export name, true for all exports, null for none
|
|
297
|
+
*/
|
|
298
|
+
getForwardId() {
|
|
299
|
+
// unknown dependency types conservatively request all exports
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Returns how this dependency may be deferred when its parent module is side-effect-free (lazy barrel optimization).
|
|
305
|
+
* @returns {LazyUntil | null} lazy classification, null when it must be processed eagerly
|
|
306
|
+
*/
|
|
307
|
+
getLazyUntil() {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Returns the export name for a `LAZY_UNTIL_LOCAL`/`LAZY_UNTIL_ID` classification (lazy barrel optimization).
|
|
313
|
+
* @returns {string | null} export name, null when not applicable
|
|
314
|
+
*/
|
|
315
|
+
getLazyName() {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Whether the lazy barrel currently defers creating this dependency's target module (lazy barrel optimization).
|
|
321
|
+
* @returns {boolean} true while deferred, so it must not be processed or rendered
|
|
322
|
+
*/
|
|
323
|
+
isLazy() {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Sets whether the lazy barrel defers creating this dependency's target module (lazy barrel optimization).
|
|
329
|
+
* @param {boolean} value true to defer, false to create it now
|
|
330
|
+
*/
|
|
331
|
+
setLazy(value) {}
|
|
332
|
+
|
|
236
333
|
/**
|
|
237
334
|
* Returns the referenced module and export
|
|
238
335
|
* @deprecated
|
|
@@ -338,7 +435,6 @@ class Dependency {
|
|
|
338
435
|
* @param {ObjectSerializerContext} context context
|
|
339
436
|
*/
|
|
340
437
|
serialize({ write }) {
|
|
341
|
-
write(this.weak);
|
|
342
438
|
write(this.optional);
|
|
343
439
|
write(this._locSL);
|
|
344
440
|
write(this._locSC);
|
|
@@ -353,7 +449,6 @@ class Dependency {
|
|
|
353
449
|
* @param {ObjectDeserializerContext} context context
|
|
354
450
|
*/
|
|
355
451
|
deserialize({ read }) {
|
|
356
|
-
this.weak = read();
|
|
357
452
|
this.optional = read();
|
|
358
453
|
this._locSL = read();
|
|
359
454
|
this._locSC = read();
|
|
@@ -368,6 +463,11 @@ class Dependency {
|
|
|
368
463
|
Dependency.NO_EXPORTS_REFERENCED = [];
|
|
369
464
|
/** @type {RawReferencedExports} */
|
|
370
465
|
Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
|
|
466
|
+
// Like EXPORTS_OBJECT_REFERENCED, but the reference can be rendered as a
|
|
467
|
+
// decoupled namespace object, so the module's exports stay mangleable.
|
|
468
|
+
// Same shape as EXPORTS_OBJECT_REFERENCED; only distinguished by identity.
|
|
469
|
+
/** @type {RawReferencedExports} */
|
|
470
|
+
Dependency.EXPORTS_OBJECT_REFERENCED_MANGLEABLE = [[]];
|
|
371
471
|
|
|
372
472
|
// TODO remove in webpack 6
|
|
373
473
|
Object.defineProperty(Dependency.prototype, "module", {
|
|
@@ -430,5 +530,9 @@ Object.defineProperty(Dependency.prototype, "disconnect", {
|
|
|
430
530
|
});
|
|
431
531
|
|
|
432
532
|
Dependency.TRANSITIVE = TRANSITIVE;
|
|
533
|
+
Dependency.LAZY_UNTIL_LOCAL = LAZY_UNTIL_LOCAL;
|
|
534
|
+
Dependency.LAZY_UNTIL_ID = LAZY_UNTIL_ID;
|
|
535
|
+
Dependency.LAZY_UNTIL_FALLBACK = LAZY_UNTIL_FALLBACK;
|
|
536
|
+
Dependency.LAZY_UNTIL_REQUEST = LAZY_UNTIL_REQUEST;
|
|
433
537
|
|
|
434
538
|
module.exports = Dependency;
|
package/lib/EntryOptionPlugin.js
CHANGED
|
@@ -5,14 +5,39 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const { SyncBailHook } = require("tapable");
|
|
9
|
+
|
|
8
10
|
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */
|
|
9
11
|
/** @typedef {import("../declarations/WebpackOptions").EntryNormalized} Entry */
|
|
10
12
|
/** @typedef {import("./Compiler")} Compiler */
|
|
11
13
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {object} EntryOptionPluginHooks
|
|
17
|
+
* @property {SyncBailHook<[string, string, EntryDescription], string | undefined>} entry transform an entry into a different request (e.g. wrap a non-HTML entry in a synthetic HTML module); return `undefined` to keep the default behavior
|
|
18
|
+
*/
|
|
19
|
+
|
|
13
20
|
const PLUGIN_NAME = "EntryOptionPlugin";
|
|
14
21
|
|
|
22
|
+
/** @type {WeakMap<Compiler, EntryOptionPluginHooks>} */
|
|
23
|
+
const hooksMap = new WeakMap();
|
|
24
|
+
|
|
15
25
|
class EntryOptionPlugin {
|
|
26
|
+
/**
|
|
27
|
+
* @param {Compiler} compiler the compiler
|
|
28
|
+
* @returns {EntryOptionPluginHooks} the hooks
|
|
29
|
+
*/
|
|
30
|
+
static getHooks(compiler) {
|
|
31
|
+
let hooks = hooksMap.get(compiler);
|
|
32
|
+
if (hooks === undefined) {
|
|
33
|
+
hooks = {
|
|
34
|
+
entry: new SyncBailHook(["context", "name", "entryDescription"])
|
|
35
|
+
};
|
|
36
|
+
hooksMap.set(compiler, hooks);
|
|
37
|
+
}
|
|
38
|
+
return hooks;
|
|
39
|
+
}
|
|
40
|
+
|
|
16
41
|
/**
|
|
17
42
|
* Applies the plugin by registering its hooks on the compiler.
|
|
18
43
|
* @param {Compiler} compiler the compiler instance one is tapping into
|
|
@@ -50,8 +75,19 @@ class EntryOptionPlugin {
|
|
|
50
75
|
const descImport =
|
|
51
76
|
/** @type {Exclude<EntryDescription["import"], undefined>} */
|
|
52
77
|
(desc.import);
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
// A plugin (e.g. HtmlModulesPlugin) may rewrite the entry into a
|
|
79
|
+
// single synthetic request; otherwise each import becomes an entry.
|
|
80
|
+
const request = EntryOptionPlugin.getHooks(compiler).entry.call(
|
|
81
|
+
context,
|
|
82
|
+
name,
|
|
83
|
+
desc
|
|
84
|
+
);
|
|
85
|
+
if (request !== undefined) {
|
|
86
|
+
new EntryPlugin(context, request, options).apply(compiler);
|
|
87
|
+
} else {
|
|
88
|
+
for (const entry of descImport) {
|
|
89
|
+
new EntryPlugin(context, entry, options).apply(compiler);
|
|
90
|
+
}
|
|
55
91
|
}
|
|
56
92
|
}
|
|
57
93
|
}
|
|
@@ -77,6 +113,7 @@ class EntryOptionPlugin {
|
|
|
77
113
|
chunkLoading: desc.chunkLoading,
|
|
78
114
|
asyncChunks: desc.asyncChunks,
|
|
79
115
|
wasmLoading: desc.wasmLoading,
|
|
116
|
+
worker: desc.worker,
|
|
80
117
|
library: desc.library
|
|
81
118
|
};
|
|
82
119
|
if (desc.chunkLoading) {
|
package/lib/EntryPlugin.js
CHANGED
|
@@ -20,7 +20,9 @@ class EntryPlugin {
|
|
|
20
20
|
* @param {EntryOptions | string=} options entry options (passing a string is deprecated)
|
|
21
21
|
*/
|
|
22
22
|
constructor(context, entry, options) {
|
|
23
|
+
/** @type {string} */
|
|
23
24
|
this.context = context;
|
|
25
|
+
/** @type {string} */
|
|
24
26
|
this.entry = entry;
|
|
25
27
|
this.options = options || "";
|
|
26
28
|
}
|