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
|
@@ -13,8 +13,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
13
13
|
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
14
14
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
15
15
|
/** @typedef {import("../errors/WebpackError")} WebpackError */
|
|
16
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
17
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, ModuleImportDescription, false | string]>} ObjectDeserializerContext */
|
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, ModuleImportDescription, false | string]>} ObjectSerializerContext */
|
|
18
18
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
19
19
|
|
|
20
20
|
class WebAssemblyImportDependency extends ModuleDependency {
|
|
@@ -50,7 +50,8 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
|
|
50
50
|
* @returns {ReferencedExports} referenced exports
|
|
51
51
|
*/
|
|
52
52
|
getReferencedExports(moduleGraph, runtime) {
|
|
53
|
-
|
|
53
|
+
// wasm import glue needs the real binding, never an inlined literal
|
|
54
|
+
return [{ name: [this.name], canInline: false }];
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -79,12 +80,10 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
|
|
79
80
|
* @param {ObjectSerializerContext} context context
|
|
80
81
|
*/
|
|
81
82
|
serialize(context) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
write(this.onlyDirectImport);
|
|
87
|
-
|
|
83
|
+
context
|
|
84
|
+
.write(this.name)
|
|
85
|
+
.write(this.description)
|
|
86
|
+
.write(this.onlyDirectImport);
|
|
88
87
|
super.serialize(context);
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -93,13 +92,12 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
|
|
93
92
|
* @param {ObjectDeserializerContext} context context
|
|
94
93
|
*/
|
|
95
94
|
deserialize(context) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
this.onlyDirectImport = read();
|
|
101
|
-
|
|
102
|
-
super.deserialize(context);
|
|
95
|
+
this.name = context.read();
|
|
96
|
+
const c1 = context.rest;
|
|
97
|
+
this.description = c1.read();
|
|
98
|
+
const c2 = c1.rest;
|
|
99
|
+
this.onlyDirectImport = c2.read();
|
|
100
|
+
super.deserialize(c2.rest);
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
|
|
@@ -18,8 +18,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
18
18
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
19
19
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
20
20
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
21
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
22
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
21
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[WorkerDependencyOptions]>} ObjectDeserializerContext */
|
|
22
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[WorkerDependencyOptions]>} ObjectSerializerContext */
|
|
23
23
|
/** @typedef {import("../util/Hash")} Hash */
|
|
24
24
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
25
25
|
|
|
@@ -28,6 +28,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
28
28
|
* @typedef {object} WorkerDependencyOptions
|
|
29
29
|
* @property {string=} publicPath public path for the worker
|
|
30
30
|
* @property {boolean=} needNewUrl true when need generate `new URL(...)`, otherwise false
|
|
31
|
+
* @property {Range=} workerConstructorRange range of the global `Worker` constructor, set only for the `new Worker()` global syntax that needs a node-target rewrite
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
class WorkerDependency extends ModuleDependency {
|
|
@@ -84,8 +85,7 @@ class WorkerDependency extends ModuleDependency {
|
|
|
84
85
|
* @param {ObjectSerializerContext} context context
|
|
85
86
|
*/
|
|
86
87
|
serialize(context) {
|
|
87
|
-
|
|
88
|
-
write(this.options);
|
|
88
|
+
context.write(this.options);
|
|
89
89
|
super.serialize(context);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -94,9 +94,8 @@ class WorkerDependency extends ModuleDependency {
|
|
|
94
94
|
* @param {ObjectDeserializerContext} context context
|
|
95
95
|
*/
|
|
96
96
|
deserialize(context) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
super.deserialize(context);
|
|
97
|
+
this.options = context.read();
|
|
98
|
+
super.deserialize(context.rest);
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
@@ -111,7 +110,8 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
|
|
|
111
110
|
* @returns {void}
|
|
112
111
|
*/
|
|
113
112
|
apply(dependency, source, templateContext) {
|
|
114
|
-
const { chunkGraph, moduleGraph, runtimeRequirements } =
|
|
113
|
+
const { chunkGraph, moduleGraph, runtimeRequirements, runtimeTemplate } =
|
|
114
|
+
templateContext;
|
|
115
115
|
const dep = /** @type {WorkerDependency} */ (dependency);
|
|
116
116
|
const block = /** @type {AsyncDependenciesBlock} */ (
|
|
117
117
|
moduleGraph.getParentBlock(dependency)
|
|
@@ -138,6 +138,17 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
|
|
|
138
138
|
dep.range[1] - 1,
|
|
139
139
|
dep.options.needNewUrl ? `new URL(${workerImportStr})` : workerImportStr
|
|
140
140
|
);
|
|
141
|
+
|
|
142
|
+
// `Worker` is global only on the web, so route node (universal or node-only) through `worker_threads`
|
|
143
|
+
const { platform } = runtimeTemplate.compilation.compiler;
|
|
144
|
+
const ctorRange = dep.options.workerConstructorRange;
|
|
145
|
+
if (
|
|
146
|
+
ctorRange &&
|
|
147
|
+
(runtimeTemplate.isUniversalTarget() || (platform.node && !platform.web))
|
|
148
|
+
) {
|
|
149
|
+
runtimeRequirements.add(RuntimeGlobals.worker);
|
|
150
|
+
source.replace(ctorRange[0], ctorRange[1] - 1, RuntimeGlobals.worker);
|
|
151
|
+
}
|
|
141
152
|
}
|
|
142
153
|
};
|
|
143
154
|
|
|
@@ -77,9 +77,13 @@ class WorkerPlugin {
|
|
|
77
77
|
* @param {WorkerPublicPath=} workerPublicPath worker public path
|
|
78
78
|
*/
|
|
79
79
|
constructor(chunkLoading, wasmLoading, module, workerPublicPath) {
|
|
80
|
+
/** @type {ChunkLoading | undefined} */
|
|
80
81
|
this._chunkLoading = chunkLoading;
|
|
82
|
+
/** @type {WasmLoading | undefined} */
|
|
81
83
|
this._wasmLoading = wasmLoading;
|
|
84
|
+
/** @type {boolean | undefined} */
|
|
82
85
|
this._module = module;
|
|
86
|
+
/** @type {string | undefined} */
|
|
83
87
|
this._workerPublicPath = workerPublicPath;
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -255,9 +259,10 @@ class WorkerPlugin {
|
|
|
255
259
|
/**
|
|
256
260
|
* Returns true when handled.
|
|
257
261
|
* @param {CallExpression} expr expression
|
|
262
|
+
* @param {boolean=} isGlobalWorker matched the global `new Worker()` syntax (eligible for universal rewrite)
|
|
258
263
|
* @returns {boolean | void} true when handled
|
|
259
264
|
*/
|
|
260
|
-
const handleNewWorker = (expr) => {
|
|
265
|
+
const handleNewWorker = (expr, isGlobalWorker = false) => {
|
|
261
266
|
if (expr.arguments.length === 0 || expr.arguments.length > 2) {
|
|
262
267
|
return;
|
|
263
268
|
}
|
|
@@ -349,10 +354,24 @@ class WorkerPlugin {
|
|
|
349
354
|
)
|
|
350
355
|
);
|
|
351
356
|
} else {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
357
|
+
// `webpackEntryOptions` is user input from a magic
|
|
358
|
+
// comment, so copy only safe own keys to avoid
|
|
359
|
+
// prototype pollution via `__proto__`/`constructor`/
|
|
360
|
+
// `prototype`.
|
|
361
|
+
const userEntryOptions = importOptions.webpackEntryOptions;
|
|
362
|
+
for (const key of Object.keys(userEntryOptions)) {
|
|
363
|
+
if (
|
|
364
|
+
key === "__proto__" ||
|
|
365
|
+
key === "constructor" ||
|
|
366
|
+
key === "prototype"
|
|
367
|
+
) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
/** @type {EXPECTED_ANY} */
|
|
371
|
+
(entryOptions)[key] = /** @type {EXPECTED_ANY} */ (
|
|
372
|
+
userEntryOptions
|
|
373
|
+
)[key];
|
|
374
|
+
}
|
|
356
375
|
}
|
|
357
376
|
}
|
|
358
377
|
if (importOptions.webpackChunkName !== undefined) {
|
|
@@ -398,13 +417,17 @@ class WorkerPlugin {
|
|
|
398
417
|
entryOptions: {
|
|
399
418
|
chunkLoading: this._chunkLoading,
|
|
400
419
|
wasmLoading: this._wasmLoading,
|
|
401
|
-
...entryOptions
|
|
420
|
+
...entryOptions,
|
|
421
|
+
worker: true
|
|
402
422
|
}
|
|
403
423
|
});
|
|
404
424
|
block.loc = expr.loc;
|
|
405
425
|
const dep = new WorkerDependency(url, range, {
|
|
406
426
|
publicPath: this._workerPublicPath,
|
|
407
|
-
needNewUrl
|
|
427
|
+
needNewUrl,
|
|
428
|
+
workerConstructorRange: isGlobalWorker
|
|
429
|
+
? /** @type {Range} */ (expr.callee.range)
|
|
430
|
+
: undefined
|
|
408
431
|
});
|
|
409
432
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
410
433
|
block.addDependency(dep);
|
|
@@ -440,12 +463,15 @@ class WorkerPlugin {
|
|
|
440
463
|
parser.state.module.addPresentationalDependency(dep);
|
|
441
464
|
}
|
|
442
465
|
} else if (insertType === "spread") {
|
|
466
|
+
const type = this._module ? '"module"' : "undefined";
|
|
467
|
+
// `{ ...(opts), type }` is equivalent to `Object.assign({}, opts, { type })`
|
|
468
|
+
const useSpread = compilation.outputOptions.environment.spread;
|
|
443
469
|
const dep1 = new ConstDependency(
|
|
444
|
-
"Object.assign({}, ",
|
|
470
|
+
useSpread ? "{ ...(" : "Object.assign({}, ",
|
|
445
471
|
/** @type {Range} */ (insertLocation)[0]
|
|
446
472
|
);
|
|
447
473
|
const dep2 = new ConstDependency(
|
|
448
|
-
|
|
474
|
+
useSpread ? `), type: ${type} }` : `, { type: ${type} })`,
|
|
449
475
|
/** @type {Range} */ (insertLocation)[1]
|
|
450
476
|
);
|
|
451
477
|
dep1.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
@@ -545,7 +571,11 @@ class WorkerPlugin {
|
|
|
545
571
|
return handleNewWorker(expr);
|
|
546
572
|
});
|
|
547
573
|
} else {
|
|
548
|
-
parser.hooks.new
|
|
574
|
+
parser.hooks.new
|
|
575
|
+
.for(item)
|
|
576
|
+
.tap(PLUGIN_NAME, (expr) =>
|
|
577
|
+
handleNewWorker(expr, item === "Worker")
|
|
578
|
+
);
|
|
549
579
|
}
|
|
550
580
|
}
|
|
551
581
|
};
|
|
@@ -18,7 +18,7 @@ const { UsageState } = require("../ExportsInfo");
|
|
|
18
18
|
* @param {string[]} prefix export prefix
|
|
19
19
|
* @param {ExportInfo=} exportInfo the export info
|
|
20
20
|
* @param {boolean} defaultPointsToSelf when true, using default will reference itself
|
|
21
|
-
* @param {Set<ExportInfo
|
|
21
|
+
* @param {Set<ExportInfo>=} alreadyVisited already visited export info (to handle circular reexports)
|
|
22
22
|
*/
|
|
23
23
|
const processExportInfo = (
|
|
24
24
|
runtime,
|
|
@@ -26,7 +26,7 @@ const processExportInfo = (
|
|
|
26
26
|
prefix,
|
|
27
27
|
exportInfo,
|
|
28
28
|
defaultPointsToSelf = false,
|
|
29
|
-
alreadyVisited =
|
|
29
|
+
alreadyVisited = undefined
|
|
30
30
|
) => {
|
|
31
31
|
if (!exportInfo) {
|
|
32
32
|
referencedExports.push(prefix);
|
|
@@ -34,35 +34,37 @@ const processExportInfo = (
|
|
|
34
34
|
}
|
|
35
35
|
const used = exportInfo.getUsed(runtime);
|
|
36
36
|
if (used === UsageState.Unused) return;
|
|
37
|
-
if (alreadyVisited.has(exportInfo)) {
|
|
37
|
+
if (alreadyVisited !== undefined && alreadyVisited.has(exportInfo)) {
|
|
38
38
|
referencedExports.push(prefix);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
// Terminal case: not recursing, so no need to track visited here
|
|
42
42
|
if (
|
|
43
43
|
used !== UsageState.OnlyPropertiesUsed ||
|
|
44
44
|
!exportInfo.exportsInfo ||
|
|
45
45
|
exportInfo.exportsInfo.otherExportsInfo.getUsed(runtime) !==
|
|
46
46
|
UsageState.Unused
|
|
47
47
|
) {
|
|
48
|
-
alreadyVisited.delete(exportInfo);
|
|
49
48
|
referencedExports.push(prefix);
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
51
|
+
// Only the recursive path needs the visited set; allocate it lazily
|
|
52
|
+
const visited = alreadyVisited !== undefined ? alreadyVisited : new Set();
|
|
53
|
+
visited.add(exportInfo);
|
|
52
54
|
const exportsInfo = exportInfo.exportsInfo;
|
|
53
|
-
for (const
|
|
55
|
+
for (const childExportInfo of exportsInfo.orderedExports) {
|
|
54
56
|
processExportInfo(
|
|
55
57
|
runtime,
|
|
56
58
|
referencedExports,
|
|
57
|
-
defaultPointsToSelf &&
|
|
59
|
+
defaultPointsToSelf && childExportInfo.name === "default"
|
|
58
60
|
? prefix
|
|
59
|
-
: [...prefix,
|
|
60
|
-
|
|
61
|
+
: [...prefix, childExportInfo.name],
|
|
62
|
+
childExportInfo,
|
|
61
63
|
false,
|
|
62
|
-
|
|
64
|
+
visited
|
|
63
65
|
);
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
visited.delete(exportInfo);
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
module.exports = processExportInfo;
|
|
@@ -36,8 +36,8 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
36
36
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
37
37
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
38
38
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
39
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
40
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
39
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[DelegatedModuleSourceRequest, DelegatedModuleData, DelegatedModuleType, string, string | Module]>} ObjectDeserializerContext */
|
|
40
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[DelegatedModuleSourceRequest, DelegatedModuleData, DelegatedModuleType, string, string | Module]>} ObjectSerializerContext */
|
|
41
41
|
/** @typedef {import("../dependencies/StaticExportsDependency").Exports} Exports */
|
|
42
42
|
/** @typedef {import("../util/Hash")} Hash */
|
|
43
43
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
@@ -72,11 +72,17 @@ class DelegatedModule extends Module {
|
|
|
72
72
|
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
|
73
73
|
|
|
74
74
|
// Info from Factory
|
|
75
|
+
/** @type {string} */
|
|
75
76
|
this.sourceRequest = sourceRequest;
|
|
77
|
+
/** @type {ModuleId} */
|
|
76
78
|
this.request = data.id;
|
|
79
|
+
/** @type {DelegatedModuleType} */
|
|
77
80
|
this.delegationType = type;
|
|
81
|
+
/** @type {string} */
|
|
78
82
|
this.userRequest = userRequest;
|
|
83
|
+
/** @type {string | Module} */
|
|
79
84
|
this.originalRequest = originalRequest;
|
|
85
|
+
/** @type {DelegatedModuleData} */
|
|
80
86
|
this.delegateData = data;
|
|
81
87
|
|
|
82
88
|
// Build info
|
|
@@ -232,13 +238,13 @@ class DelegatedModule extends Module {
|
|
|
232
238
|
* @param {ObjectSerializerContext} context context
|
|
233
239
|
*/
|
|
234
240
|
serialize(context) {
|
|
235
|
-
const { write } = context;
|
|
236
241
|
// constructor
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
context
|
|
243
|
+
.write(this.sourceRequest)
|
|
244
|
+
.write(this.delegateData)
|
|
245
|
+
.write(this.delegationType)
|
|
246
|
+
.write(this.userRequest)
|
|
247
|
+
.write(this.originalRequest);
|
|
242
248
|
super.serialize(context);
|
|
243
249
|
}
|
|
244
250
|
|
|
@@ -248,15 +254,23 @@ class DelegatedModule extends Module {
|
|
|
248
254
|
* @returns {DelegatedModule} DelegatedModule
|
|
249
255
|
*/
|
|
250
256
|
static deserialize(context) {
|
|
251
|
-
const
|
|
257
|
+
const sourceRequest = context.read();
|
|
258
|
+
const c1 = context.rest;
|
|
259
|
+
const delegateData = c1.read();
|
|
260
|
+
const c2 = c1.rest;
|
|
261
|
+
const delegationType = c2.read();
|
|
262
|
+
const c3 = c2.rest;
|
|
263
|
+
const userRequest = c3.read();
|
|
264
|
+
const c4 = c3.rest;
|
|
265
|
+
const originalRequest = c4.read();
|
|
252
266
|
const obj = new DelegatedModule(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
sourceRequest,
|
|
268
|
+
delegateData,
|
|
269
|
+
delegationType,
|
|
270
|
+
userRequest,
|
|
271
|
+
originalRequest
|
|
258
272
|
);
|
|
259
|
-
obj.deserialize(
|
|
273
|
+
obj.deserialize(c4.rest);
|
|
260
274
|
return obj;
|
|
261
275
|
}
|
|
262
276
|
|
|
@@ -35,6 +35,7 @@ class DelegatedModuleFactoryPlugin {
|
|
|
35
35
|
* @param {Options} options options
|
|
36
36
|
*/
|
|
37
37
|
constructor(options) {
|
|
38
|
+
/** @type {Options} */
|
|
38
39
|
this.options = options;
|
|
39
40
|
options.type = options.type || "require";
|
|
40
41
|
options.extensions = options.extensions || ["", ".js", ".json", ".wasm"];
|
|
@@ -25,8 +25,11 @@ class DllEntryPlugin {
|
|
|
25
25
|
* @param {Options} options options
|
|
26
26
|
*/
|
|
27
27
|
constructor(context, entries, options) {
|
|
28
|
+
/** @type {string} */
|
|
28
29
|
this.context = context;
|
|
30
|
+
/** @type {Entries} */
|
|
29
31
|
this.entries = entries;
|
|
32
|
+
/** @type {Options} */
|
|
30
33
|
this.options = options;
|
|
31
34
|
}
|
|
32
35
|
|
package/lib/dll/DllModule.js
CHANGED
|
@@ -28,8 +28,8 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
28
28
|
/** @typedef {import("../Module").Sources} Sources */
|
|
29
29
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
30
30
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
31
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
32
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
31
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string]>} ObjectDeserializerContext */
|
|
32
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string]>} ObjectSerializerContext */
|
|
33
33
|
/** @typedef {import("../util/Hash")} Hash */
|
|
34
34
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
35
35
|
|
|
@@ -51,6 +51,7 @@ class DllModule extends Module {
|
|
|
51
51
|
// Info from Factory
|
|
52
52
|
/** @type {Dependency[]} */
|
|
53
53
|
this.dependencies = dependencies;
|
|
54
|
+
/** @type {string} */
|
|
54
55
|
this.name = name;
|
|
55
56
|
}
|
|
56
57
|
|
package/lib/dll/DllPlugin.js
CHANGED
|
@@ -11,6 +11,7 @@ const LibManifestPlugin = require("./LibManifestPlugin");
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../../declarations/plugins/dll/DllPlugin").DllPluginOptions} DllPluginOptions */
|
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
|
14
|
+
/** @typedef {import("../Module").FactoryMeta} FactoryMeta */
|
|
14
15
|
/** @typedef {import("./DllEntryPlugin").Entries} Entries */
|
|
15
16
|
/** @typedef {import("./DllEntryPlugin").Options} Options */
|
|
16
17
|
|
|
@@ -68,6 +69,21 @@ class DllPlugin {
|
|
|
68
69
|
new LibManifestPlugin({ ...this.options, entryOnly }).apply(compiler);
|
|
69
70
|
if (!entryOnly) {
|
|
70
71
|
new FlagAllModulesAsUsedPlugin(PLUGIN_NAME).apply(compiler);
|
|
72
|
+
compiler.hooks.compilation.tap(
|
|
73
|
+
PLUGIN_NAME,
|
|
74
|
+
(_compilation, { normalModuleFactory }) => {
|
|
75
|
+
normalModuleFactory.hooks.module.tap(
|
|
76
|
+
{ name: PLUGIN_NAME, stage: 10 },
|
|
77
|
+
(module) => {
|
|
78
|
+
if (module.factoryMeta === undefined) {
|
|
79
|
+
module.factoryMeta = {};
|
|
80
|
+
}
|
|
81
|
+
module.factoryMeta.sideEffectFree = false;
|
|
82
|
+
return module;
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
}
|
|
@@ -30,6 +30,7 @@ class DllReferencePlugin {
|
|
|
30
30
|
* @param {DllReferencePluginOptions} options options object
|
|
31
31
|
*/
|
|
32
32
|
constructor(options) {
|
|
33
|
+
/** @type {DllReferencePluginOptions} */
|
|
33
34
|
this.options = options;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -188,7 +189,9 @@ class DllManifestError extends WebpackError {
|
|
|
188
189
|
constructor(filename, message) {
|
|
189
190
|
super();
|
|
190
191
|
|
|
192
|
+
/** @type {string} */
|
|
191
193
|
this.name = "DllManifestError";
|
|
194
|
+
/** @type {string} */
|
|
192
195
|
this.message = `Dll manifest ${filename}\n${message}`;
|
|
193
196
|
}
|
|
194
197
|
}
|
|
@@ -7,17 +7,22 @@
|
|
|
7
7
|
|
|
8
8
|
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
9
9
|
|
|
10
|
+
/** @typedef {import("../../declarations/WebpackOptions").ExternalsType} ExternalsType */
|
|
10
11
|
/** @typedef {import("../Compiler")} Compiler */
|
|
12
|
+
/** @typedef {import("../Dependency")} Dependency */
|
|
11
13
|
/** @typedef {"main" | "preload" | "renderer"} ElectronContext */
|
|
12
14
|
|
|
13
15
|
class ElectronTargetPlugin {
|
|
14
16
|
/**
|
|
15
17
|
* Creates an instance of ElectronTargetPlugin.
|
|
16
18
|
* @param {ElectronContext=} context in main, preload or renderer context?
|
|
19
|
+
* @param {ExternalsType=} type default external type
|
|
17
20
|
*/
|
|
18
|
-
constructor(context) {
|
|
21
|
+
constructor(context, type = "node-commonjs") {
|
|
19
22
|
/** @type {ElectronContext | undefined} */
|
|
20
23
|
this._context = context;
|
|
24
|
+
/** @type {ExternalsType} */
|
|
25
|
+
this.type = type;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
/**
|
|
@@ -26,7 +31,20 @@ class ElectronTargetPlugin {
|
|
|
26
31
|
* @returns {void}
|
|
27
32
|
*/
|
|
28
33
|
apply(compiler) {
|
|
29
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @param {Dependency} dependency the dependency
|
|
36
|
+
* @returns {ExternalsType} the external type
|
|
37
|
+
*/
|
|
38
|
+
const externalType = (dependency) => {
|
|
39
|
+
// When `require` electron built-in modules with module output
|
|
40
|
+
// we should still emit `node-commonjs` for compatibility
|
|
41
|
+
if (dependency.category === "commonjs") {
|
|
42
|
+
return "node-commonjs";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this.type;
|
|
46
|
+
};
|
|
47
|
+
new ExternalsPlugin(externalType, [
|
|
30
48
|
"clipboard",
|
|
31
49
|
"crash-reporter",
|
|
32
50
|
"electron",
|
|
@@ -38,7 +56,7 @@ class ElectronTargetPlugin {
|
|
|
38
56
|
]).apply(compiler);
|
|
39
57
|
switch (this._context) {
|
|
40
58
|
case "main":
|
|
41
|
-
new ExternalsPlugin(
|
|
59
|
+
new ExternalsPlugin(externalType, [
|
|
42
60
|
"app",
|
|
43
61
|
"auto-updater",
|
|
44
62
|
"browser-window",
|
|
@@ -58,7 +76,7 @@ class ElectronTargetPlugin {
|
|
|
58
76
|
break;
|
|
59
77
|
case "preload":
|
|
60
78
|
case "renderer":
|
|
61
|
-
new ExternalsPlugin(
|
|
79
|
+
new ExternalsPlugin(externalType, [
|
|
62
80
|
"desktop-capturer",
|
|
63
81
|
"ipc-renderer",
|
|
64
82
|
"remote",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const WebpackError = require("./WebpackError");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
12
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
11
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[Error, string]>} ObjectDeserializerContext */
|
|
12
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[Error, string]>} ObjectSerializerContext */
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Defines the callback callback.
|
|
@@ -29,12 +29,16 @@ class HookWebpackError extends WebpackError {
|
|
|
29
29
|
constructor(error, hook) {
|
|
30
30
|
super(error ? error.message : undefined, error ? { cause: error } : {});
|
|
31
31
|
|
|
32
|
+
/** @type {string} */
|
|
32
33
|
this.hook = hook;
|
|
34
|
+
/** @type {Error} */
|
|
33
35
|
this.error = error;
|
|
34
36
|
/** @type {string} */
|
|
35
37
|
this.name = "HookWebpackError";
|
|
38
|
+
/** @type {boolean} */
|
|
36
39
|
this.hideStack = true;
|
|
37
40
|
this.stack += `\n-- inner error --\n${error ? error.stack : ""}`;
|
|
41
|
+
/** @type {string} */
|
|
38
42
|
this.details = `caused by plugins in ${hook}\n${error ? error.stack : ""}`;
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -43,11 +47,7 @@ class HookWebpackError extends WebpackError {
|
|
|
43
47
|
* @param {ObjectSerializerContext} context context
|
|
44
48
|
*/
|
|
45
49
|
serialize(context) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
write(this.error);
|
|
49
|
-
write(this.hook);
|
|
50
|
-
|
|
50
|
+
context.write(this.error).write(this.hook);
|
|
51
51
|
super.serialize(context);
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -56,12 +56,10 @@ class HookWebpackError extends WebpackError {
|
|
|
56
56
|
* @param {ObjectDeserializerContext} context context
|
|
57
57
|
*/
|
|
58
58
|
deserialize(context) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
super.deserialize(context);
|
|
59
|
+
this.error = context.read();
|
|
60
|
+
const c1 = context.rest;
|
|
61
|
+
this.hook = c1.read();
|
|
62
|
+
super.deserialize(c1.rest);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
|