webpack 5.107.1 → 5.108.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +52 -14
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +16 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +557 -77
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +9 -1
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +105 -30
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +88 -9
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +22 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +267 -154
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +20 -27
- package/lib/dependencies/HtmlInlineStyleDependency.js +62 -11
- package/lib/dependencies/HtmlSourceDependency.js +18 -0
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +40 -10
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +134 -6
- package/lib/html/HtmlGenerator.js +292 -50
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +287 -60
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +286 -159
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +54 -29
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +38 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +397 -78
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +16 -6
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +36 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1592 -314
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
package/lib/config/target.js
CHANGED
|
@@ -28,8 +28,11 @@ const getDefaultTarget = (context) => {
|
|
|
28
28
|
* @property {boolean | null=} browser browser platform, running in a normal web browser
|
|
29
29
|
* @property {boolean | null=} webworker (Web)Worker platform, running in a web/shared/service worker
|
|
30
30
|
* @property {boolean | null=} node node platform, require of node built-in modules is available
|
|
31
|
+
* @property {boolean | null=} deno deno platform, node built-in modules (via the `node:` specifier) and web APIs are available
|
|
32
|
+
* @property {boolean | null=} bun bun platform, bun and node built-in modules are available
|
|
31
33
|
* @property {boolean | null=} nwjs nwjs platform, require of legacy nw.gui is available
|
|
32
34
|
* @property {boolean | null=} electron electron platform, require of some electron built-in modules is available
|
|
35
|
+
* @property {boolean | null=} universal universal ESM target spanning both web and node (target `"universal"` or `["web", "node"]`)
|
|
33
36
|
*/
|
|
34
37
|
|
|
35
38
|
/**
|
|
@@ -46,6 +49,7 @@ const getDefaultTarget = (context) => {
|
|
|
46
49
|
* @property {boolean | null} require has require function available
|
|
47
50
|
* @property {boolean | null} nodeBuiltins has node.js built-in modules available
|
|
48
51
|
* @property {boolean | null} nodePrefixForCoreModules node.js allows to use `node:` prefix for core modules
|
|
52
|
+
* @property {boolean | null} nodeBuiltinModuleGetter node.js exposes `process.getBuiltinModule()` to synchronously load core modules
|
|
49
53
|
* @property {boolean | null} importMetaDirnameAndFilename node.js allows to use `import.meta.dirname` and `import.meta.filename`
|
|
50
54
|
* @property {boolean | null} document has document available (allows script tags)
|
|
51
55
|
* @property {boolean | null} importScripts has importScripts available
|
|
@@ -58,8 +62,12 @@ const getDefaultTarget = (context) => {
|
|
|
58
62
|
* Defines the ecma target properties type used by this module.
|
|
59
63
|
* @typedef {object} EcmaTargetProperties
|
|
60
64
|
* @property {boolean | null} globalThis has globalThis variable available
|
|
65
|
+
* @property {boolean | null} symbol `Symbol` is available
|
|
66
|
+
* @property {boolean | null} hasOwn `Object.hasOwn` is available
|
|
61
67
|
* @property {boolean | null} bigIntLiteral big int literal syntax is available
|
|
62
|
-
* @property {boolean | null} const const
|
|
68
|
+
* @property {boolean | null} const const variable declarations are available
|
|
69
|
+
* @property {boolean | null} let let variable declarations are available
|
|
70
|
+
* @property {boolean | null} logicalAssignment logical assignment operators (`||=`, `&&=`, `??=`) are available
|
|
63
71
|
* @property {boolean | null} methodShorthand object method shorthand is available
|
|
64
72
|
* @property {boolean | null} arrowFunction arrow functions are available
|
|
65
73
|
* @property {boolean | null} forOf for of iteration is available
|
|
@@ -68,6 +76,7 @@ const getDefaultTarget = (context) => {
|
|
|
68
76
|
* @property {boolean | null} dynamicImportInWorker async import() is available when creating a worker
|
|
69
77
|
* @property {boolean | null} module ESM syntax is available (when in module)
|
|
70
78
|
* @property {boolean | null} optionalChaining optional chaining is available
|
|
79
|
+
* @property {boolean | null} spread spread and rest in array/object literals and calls is available
|
|
71
80
|
* @property {boolean | null} templateLiteral template literal is available
|
|
72
81
|
* @property {boolean | null} asyncFunction async functions and await are available
|
|
73
82
|
*/
|
|
@@ -133,6 +142,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
133
142
|
/^web$/,
|
|
134
143
|
() => ({
|
|
135
144
|
node: false,
|
|
145
|
+
deno: false,
|
|
146
|
+
bun: false,
|
|
136
147
|
web: true,
|
|
137
148
|
webworker: null,
|
|
138
149
|
browser: true,
|
|
@@ -154,6 +165,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
154
165
|
/^webworker$/,
|
|
155
166
|
() => ({
|
|
156
167
|
node: false,
|
|
168
|
+
deno: false,
|
|
169
|
+
bun: false,
|
|
157
170
|
web: true,
|
|
158
171
|
webworker: true,
|
|
159
172
|
browser: true,
|
|
@@ -169,6 +182,39 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
169
182
|
global: false
|
|
170
183
|
})
|
|
171
184
|
],
|
|
185
|
+
[
|
|
186
|
+
"universal",
|
|
187
|
+
"Universal target running in browser, web worker, Node.js, Electron and NW.js. Output is always ECMAScript modules.",
|
|
188
|
+
/^universal$/,
|
|
189
|
+
// merged web + webworker + node + electron + nwjs properties; output is
|
|
190
|
+
// always ESM, so `require` (sync CommonJS) is never available
|
|
191
|
+
() => ({
|
|
192
|
+
node: null,
|
|
193
|
+
deno: null,
|
|
194
|
+
bun: null,
|
|
195
|
+
web: null,
|
|
196
|
+
webworker: null,
|
|
197
|
+
browser: null,
|
|
198
|
+
electron: null,
|
|
199
|
+
nwjs: null,
|
|
200
|
+
|
|
201
|
+
electronMain: null,
|
|
202
|
+
electronPreload: null,
|
|
203
|
+
electronRenderer: null,
|
|
204
|
+
|
|
205
|
+
document: null,
|
|
206
|
+
importScriptsInWorker: null,
|
|
207
|
+
fetchWasm: null,
|
|
208
|
+
nodeBuiltins: null,
|
|
209
|
+
importScripts: null,
|
|
210
|
+
require: false,
|
|
211
|
+
global: null,
|
|
212
|
+
|
|
213
|
+
module: true,
|
|
214
|
+
dynamicImport: true,
|
|
215
|
+
dynamicImportInWorker: true
|
|
216
|
+
})
|
|
217
|
+
],
|
|
172
218
|
[
|
|
173
219
|
"[async-]node[X[.Y]]",
|
|
174
220
|
"Node.js in version X.Y. The 'async-' prefix will load chunks asynchronously via 'fs' and 'vm' instead of 'require()'. Examples: node14.5, async-node10.",
|
|
@@ -178,6 +224,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
178
224
|
// see https://node.green/
|
|
179
225
|
return {
|
|
180
226
|
node: true,
|
|
227
|
+
deno: false,
|
|
228
|
+
bun: false,
|
|
181
229
|
web: false,
|
|
182
230
|
webworker: false,
|
|
183
231
|
browser: false,
|
|
@@ -188,6 +236,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
188
236
|
nodeBuiltins: true,
|
|
189
237
|
// v16.0.0, v14.18.0
|
|
190
238
|
nodePrefixForCoreModules: Number(major) < 15 ? v(14, 18) : v(16),
|
|
239
|
+
// v22.3.0, backported to v20.16.0; use the conservative single threshold
|
|
240
|
+
nodeBuiltinModuleGetter: v(22, 3),
|
|
191
241
|
// Added in: v21.2.0, v20.11.0, but Node.js will output experimental warning, we don't want it
|
|
192
242
|
// v24.0.0, v22.16.0 - This property is no longer experimental.
|
|
193
243
|
importMetaDirnameAndFilename: v(22, 16),
|
|
@@ -198,9 +248,14 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
198
248
|
importScriptsInWorker: false,
|
|
199
249
|
|
|
200
250
|
globalThis: v(12),
|
|
251
|
+
symbol: v(0, 12),
|
|
252
|
+
hasOwn: v(16, 9),
|
|
201
253
|
const: v(6),
|
|
254
|
+
let: v(6),
|
|
255
|
+
logicalAssignment: v(15),
|
|
202
256
|
templateLiteral: v(4),
|
|
203
257
|
optionalChaining: v(14),
|
|
258
|
+
spread: v(8, 3),
|
|
204
259
|
methodShorthand: v(4),
|
|
205
260
|
arrowFunction: v(6),
|
|
206
261
|
asyncFunction: v(7, 6),
|
|
@@ -213,6 +268,108 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
213
268
|
};
|
|
214
269
|
}
|
|
215
270
|
],
|
|
271
|
+
[
|
|
272
|
+
"deno[X[.Y]]",
|
|
273
|
+
"Deno in version X.Y. Emits ESM output; node.js built-ins are available via the required 'node:' specifier and web APIs (fetch, WebAssembly, ...) are available too. Examples: deno2, deno1.40.",
|
|
274
|
+
/^deno((\d+)(?:\.(\d+))?)?$/,
|
|
275
|
+
(_, major, minor) => {
|
|
276
|
+
const v = versionDependent(major, minor);
|
|
277
|
+
// Deno ships a modern V8, so syntax features are available since 1.0.
|
|
278
|
+
return {
|
|
279
|
+
node: true,
|
|
280
|
+
deno: true,
|
|
281
|
+
web: true,
|
|
282
|
+
webworker: false,
|
|
283
|
+
browser: false,
|
|
284
|
+
electron: false,
|
|
285
|
+
nwjs: false,
|
|
286
|
+
|
|
287
|
+
require: false,
|
|
288
|
+
nodeBuiltins: true,
|
|
289
|
+
// Deno only resolves node.js core modules through the `node:` specifier
|
|
290
|
+
nodePrefixForCoreModules: true,
|
|
291
|
+
// process.getBuiltinModule() - v2.1.0
|
|
292
|
+
nodeBuiltinModuleGetter: v(2, 1),
|
|
293
|
+
// import.meta.dirname / import.meta.filename - v1.40.0
|
|
294
|
+
importMetaDirnameAndFilename: v(1, 40),
|
|
295
|
+
global: false,
|
|
296
|
+
document: false,
|
|
297
|
+
fetchWasm: true,
|
|
298
|
+
importScripts: false,
|
|
299
|
+
importScriptsInWorker: false,
|
|
300
|
+
|
|
301
|
+
globalThis: true,
|
|
302
|
+
symbol: true,
|
|
303
|
+
hasOwn: true,
|
|
304
|
+
bigIntLiteral: true,
|
|
305
|
+
const: true,
|
|
306
|
+
let: true,
|
|
307
|
+
logicalAssignment: true,
|
|
308
|
+
methodShorthand: true,
|
|
309
|
+
arrowFunction: true,
|
|
310
|
+
forOf: true,
|
|
311
|
+
destructuring: true,
|
|
312
|
+
dynamicImport: true,
|
|
313
|
+
dynamicImportInWorker: true,
|
|
314
|
+
module: true,
|
|
315
|
+
optionalChaining: true,
|
|
316
|
+
spread: true,
|
|
317
|
+
templateLiteral: true,
|
|
318
|
+
asyncFunction: true
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
[
|
|
323
|
+
"bun[X[.Y]]",
|
|
324
|
+
"Bun in version X.Y. Output is always ECMAScript modules. Examples: bun, bun1.1.",
|
|
325
|
+
/^bun((\d+)(?:\.(\d+))?)?$/,
|
|
326
|
+
() => ({
|
|
327
|
+
// Bun is a modern, Node.js-compatible runtime; every released version
|
|
328
|
+
// supports the full modern ECMAScript feature set, so the version is
|
|
329
|
+
// accepted but does not gate any feature. Output is always ESM, so sync
|
|
330
|
+
// CommonJS `require` is never available.
|
|
331
|
+
node: true,
|
|
332
|
+
bun: true,
|
|
333
|
+
web: false,
|
|
334
|
+
webworker: false,
|
|
335
|
+
browser: false,
|
|
336
|
+
electron: false,
|
|
337
|
+
nwjs: false,
|
|
338
|
+
|
|
339
|
+
require: false,
|
|
340
|
+
nodeBuiltins: true,
|
|
341
|
+
nodePrefixForCoreModules: true,
|
|
342
|
+
nodeBuiltinModuleGetter: true,
|
|
343
|
+
importMetaDirnameAndFilename: true,
|
|
344
|
+
// Bun implements web-standard globals; use `globalThis` and load wasm
|
|
345
|
+
// via `fetch()` (Bun's fetch resolves `file:` URLs) like the deno target,
|
|
346
|
+
// instead of proprietary `Bun.*` runtime APIs.
|
|
347
|
+
global: false,
|
|
348
|
+
document: false,
|
|
349
|
+
fetchWasm: true,
|
|
350
|
+
importScripts: false,
|
|
351
|
+
importScriptsInWorker: false,
|
|
352
|
+
|
|
353
|
+
globalThis: true,
|
|
354
|
+
symbol: true,
|
|
355
|
+
hasOwn: true,
|
|
356
|
+
const: true,
|
|
357
|
+
let: true,
|
|
358
|
+
logicalAssignment: true,
|
|
359
|
+
templateLiteral: true,
|
|
360
|
+
optionalChaining: true,
|
|
361
|
+
spread: true,
|
|
362
|
+
methodShorthand: true,
|
|
363
|
+
arrowFunction: true,
|
|
364
|
+
asyncFunction: true,
|
|
365
|
+
forOf: true,
|
|
366
|
+
destructuring: true,
|
|
367
|
+
bigIntLiteral: true,
|
|
368
|
+
dynamicImport: true,
|
|
369
|
+
dynamicImportInWorker: true,
|
|
370
|
+
module: true
|
|
371
|
+
})
|
|
372
|
+
],
|
|
216
373
|
[
|
|
217
374
|
"electron[X[.Y]]-main/preload/renderer",
|
|
218
375
|
"Electron in version X.Y. Script is running in main, preload resp. renderer context.",
|
|
@@ -222,6 +379,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
222
379
|
// see https://node.green/ + https://github.com/electron/releases
|
|
223
380
|
return {
|
|
224
381
|
node: true,
|
|
382
|
+
deno: false,
|
|
383
|
+
bun: false,
|
|
225
384
|
web: context !== "main",
|
|
226
385
|
webworker: false,
|
|
227
386
|
browser: false,
|
|
@@ -247,9 +406,15 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
247
406
|
importScriptsInWorker: true,
|
|
248
407
|
|
|
249
408
|
globalThis: v(5),
|
|
409
|
+
symbol: v(0, 24),
|
|
410
|
+
hasOwn: v(16),
|
|
250
411
|
const: v(1, 1),
|
|
412
|
+
let: v(1, 1),
|
|
413
|
+
// 10.0.0 - Chromium 85
|
|
414
|
+
logicalAssignment: v(10),
|
|
251
415
|
templateLiteral: v(1, 1),
|
|
252
416
|
optionalChaining: v(8),
|
|
417
|
+
spread: v(2),
|
|
253
418
|
methodShorthand: v(1, 1),
|
|
254
419
|
arrowFunction: v(1, 1),
|
|
255
420
|
asyncFunction: v(1, 7),
|
|
@@ -258,7 +423,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
258
423
|
bigIntLiteral: v(4),
|
|
259
424
|
dynamicImport: v(11),
|
|
260
425
|
dynamicImportInWorker: v(11),
|
|
261
|
-
|
|
426
|
+
// 28.0.0 - ESM support was added
|
|
427
|
+
module: v(28)
|
|
262
428
|
};
|
|
263
429
|
}
|
|
264
430
|
],
|
|
@@ -271,6 +437,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
271
437
|
// see https://node.green/ + https://github.com/nwjs/nw.js/blob/nw48/CHANGELOG.md
|
|
272
438
|
return {
|
|
273
439
|
node: true,
|
|
440
|
+
deno: false,
|
|
441
|
+
bun: false,
|
|
274
442
|
web: true,
|
|
275
443
|
webworker: null,
|
|
276
444
|
browser: false,
|
|
@@ -286,9 +454,15 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
286
454
|
require: false,
|
|
287
455
|
|
|
288
456
|
globalThis: v(0, 43),
|
|
457
|
+
symbol: v(0, 12),
|
|
458
|
+
hasOwn: v(0, 58),
|
|
289
459
|
const: v(0, 15),
|
|
460
|
+
let: v(0, 15),
|
|
461
|
+
// 0.48.0 - Chromium 85
|
|
462
|
+
logicalAssignment: v(0, 48),
|
|
290
463
|
templateLiteral: v(0, 13),
|
|
291
464
|
optionalChaining: v(0, 44),
|
|
465
|
+
spread: v(0, 23),
|
|
292
466
|
methodShorthand: v(0, 15),
|
|
293
467
|
arrowFunction: v(0, 15),
|
|
294
468
|
asyncFunction: v(0, 21),
|
|
@@ -310,8 +484,11 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
310
484
|
if (v < 1000) v += 2009;
|
|
311
485
|
return {
|
|
312
486
|
const: v >= 2015,
|
|
487
|
+
let: v >= 2015,
|
|
488
|
+
logicalAssignment: v >= 2021,
|
|
313
489
|
templateLiteral: v >= 2015,
|
|
314
490
|
optionalChaining: v >= 2020,
|
|
491
|
+
spread: v >= 2018,
|
|
315
492
|
methodShorthand: v >= 2015,
|
|
316
493
|
arrowFunction: v >= 2015,
|
|
317
494
|
forOf: v >= 2015,
|
|
@@ -319,6 +496,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
319
496
|
module: v >= 2015,
|
|
320
497
|
asyncFunction: v >= 2017,
|
|
321
498
|
globalThis: v >= 2020,
|
|
499
|
+
symbol: v >= 2015,
|
|
500
|
+
hasOwn: v >= 2022,
|
|
322
501
|
bigIntLiteral: v >= 2020,
|
|
323
502
|
dynamicImport: v >= 2020,
|
|
324
503
|
dynamicImportInWorker: v >= 2020
|
|
@@ -32,8 +32,8 @@ const ContainerExposedDependency = require("./ContainerExposedDependency");
|
|
|
32
32
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
33
33
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
34
34
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
35
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
36
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
35
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, ExposesList, string]>} ObjectDeserializerContext */
|
|
36
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, ExposesList, string]>} ObjectSerializerContext */
|
|
37
37
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -220,11 +220,12 @@ class ContainerEntryModule extends Module {
|
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
const cst = runtimeTemplate.renderConst();
|
|
223
224
|
const source = Template.asString([
|
|
224
|
-
|
|
225
|
+
`${cst} moduleMap = {`,
|
|
225
226
|
Template.indent(getters.join(",\n")),
|
|
226
227
|
"};",
|
|
227
|
-
|
|
228
|
+
`${cst} get = ${runtimeTemplate.basicFunction("module, getScope", [
|
|
228
229
|
`${RuntimeGlobals.currentRemoteGetScope} = getScope;`,
|
|
229
230
|
// reusing the getScope variable to avoid creating a new var (and module is also used later)
|
|
230
231
|
"getScope = (",
|
|
@@ -242,10 +243,10 @@ class ContainerEntryModule extends Module {
|
|
|
242
243
|
`${RuntimeGlobals.currentRemoteGetScope} = undefined;`,
|
|
243
244
|
"return getScope;"
|
|
244
245
|
])};`,
|
|
245
|
-
|
|
246
|
+
`${cst} init = ${runtimeTemplate.basicFunction("shareScope, initScope", [
|
|
246
247
|
`if (!${RuntimeGlobals.shareScopeMap}) return;`,
|
|
247
|
-
|
|
248
|
-
|
|
248
|
+
`${cst} name = ${JSON.stringify(this._shareScope)}`,
|
|
249
|
+
`${cst} oldScope = ${RuntimeGlobals.shareScopeMap}[name];`,
|
|
249
250
|
'if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope");',
|
|
250
251
|
`${RuntimeGlobals.shareScopeMap}[name] = shareScope;`,
|
|
251
252
|
`return ${RuntimeGlobals.initializeSharing}(name, initScope);`
|
|
@@ -287,10 +288,7 @@ class ContainerEntryModule extends Module {
|
|
|
287
288
|
* @param {ObjectSerializerContext} context context
|
|
288
289
|
*/
|
|
289
290
|
serialize(context) {
|
|
290
|
-
|
|
291
|
-
write(this._name);
|
|
292
|
-
write(this._exposes);
|
|
293
|
-
write(this._shareScope);
|
|
291
|
+
context.write(this._name).write(this._exposes).write(this._shareScope);
|
|
294
292
|
super.serialize(context);
|
|
295
293
|
}
|
|
296
294
|
|
|
@@ -300,9 +298,12 @@ class ContainerEntryModule extends Module {
|
|
|
300
298
|
* @returns {ContainerEntryModule} deserialized container entry module
|
|
301
299
|
*/
|
|
302
300
|
static deserialize(context) {
|
|
303
|
-
const
|
|
304
|
-
const
|
|
305
|
-
|
|
301
|
+
const name = context.read();
|
|
302
|
+
const c1 = context.rest;
|
|
303
|
+
const exposes = c1.read();
|
|
304
|
+
const c2 = c1.rest;
|
|
305
|
+
const obj = new ContainerEntryModule(name, exposes, c2.read());
|
|
306
|
+
obj.deserialize(c2.rest);
|
|
306
307
|
return obj;
|
|
307
308
|
}
|
|
308
309
|
}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
const ModuleDependency = require("../dependencies/ModuleDependency");
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
12
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
11
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string]>} ObjectDeserializerContext */
|
|
12
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string]>} ObjectSerializerContext */
|
|
13
13
|
|
|
14
14
|
class ContainerExposedDependency extends ModuleDependency {
|
|
15
15
|
/**
|
|
@@ -28,7 +28,7 @@ class ContainerReferencePlugin {
|
|
|
28
28
|
* @param {ContainerReferencePluginOptions} options options
|
|
29
29
|
*/
|
|
30
30
|
constructor(options) {
|
|
31
|
-
/** @
|
|
31
|
+
/** @type {ContainerReferencePluginOptions} */
|
|
32
32
|
this.options = options;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -9,8 +9,8 @@ const Dependency = require("../Dependency");
|
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */
|
|
12
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
13
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
12
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[ExternalRequests]>} ObjectDeserializerContext */
|
|
13
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[ExternalRequests]>} ObjectSerializerContext */
|
|
14
14
|
|
|
15
15
|
class FallbackDependency extends Dependency {
|
|
16
16
|
/**
|
|
@@ -44,8 +44,7 @@ class FallbackDependency extends Dependency {
|
|
|
44
44
|
* @param {ObjectSerializerContext} context context
|
|
45
45
|
*/
|
|
46
46
|
serialize(context) {
|
|
47
|
-
|
|
48
|
-
write(this.requests);
|
|
47
|
+
context.write(this.requests);
|
|
49
48
|
super.serialize(context);
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -55,9 +54,8 @@ class FallbackDependency extends Dependency {
|
|
|
55
54
|
* @returns {FallbackDependency} deserialize fallback dependency
|
|
56
55
|
*/
|
|
57
56
|
static deserialize(context) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
obj.deserialize(context);
|
|
57
|
+
const obj = new FallbackDependency(context.read());
|
|
58
|
+
obj.deserialize(context.rest);
|
|
61
59
|
return obj;
|
|
62
60
|
}
|
|
63
61
|
}
|
|
@@ -32,8 +32,8 @@ const FallbackItemDependency = require("./FallbackItemDependency");
|
|
|
32
32
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
33
33
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
34
34
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
35
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
36
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
35
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[ExternalRequests]>} ObjectDeserializerContext */
|
|
36
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[ExternalRequests]>} ObjectSerializerContext */
|
|
37
37
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
38
38
|
/** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */
|
|
39
39
|
|
|
@@ -149,10 +149,12 @@ class FallbackModule extends Module {
|
|
|
149
149
|
const ids = this.dependencies.map((dep) =>
|
|
150
150
|
chunkGraph.getModuleId(/** @type {Module} */ (moduleGraph.getModule(dep)))
|
|
151
151
|
);
|
|
152
|
+
const cst = runtimeTemplate.renderConst();
|
|
153
|
+
const lt = runtimeTemplate.renderLet();
|
|
152
154
|
const code = Template.asString([
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
`${cst} ids = ${JSON.stringify(ids)};`,
|
|
156
|
+
`${lt} error, result, i = 0;`,
|
|
157
|
+
`${cst} loop = ${runtimeTemplate.basicFunction("next", [
|
|
156
158
|
"while(i < ids.length) {",
|
|
157
159
|
Template.indent([
|
|
158
160
|
`try { next = ${RuntimeGlobals.require}(ids[i++]); } catch(e) { return handleError(e); }`,
|
|
@@ -161,11 +163,11 @@ class FallbackModule extends Module {
|
|
|
161
163
|
"}",
|
|
162
164
|
"if(error) throw error;"
|
|
163
165
|
])}`,
|
|
164
|
-
|
|
166
|
+
`${cst} handleResult = ${runtimeTemplate.basicFunction("result", [
|
|
165
167
|
"if(result) return result;",
|
|
166
168
|
"return loop();"
|
|
167
169
|
])};`,
|
|
168
|
-
|
|
170
|
+
`${cst} handleError = ${runtimeTemplate.basicFunction("e", [
|
|
169
171
|
"error = e;",
|
|
170
172
|
"return loop();"
|
|
171
173
|
])};`,
|
|
@@ -182,8 +184,7 @@ class FallbackModule extends Module {
|
|
|
182
184
|
* @param {ObjectSerializerContext} context context
|
|
183
185
|
*/
|
|
184
186
|
serialize(context) {
|
|
185
|
-
|
|
186
|
-
write(this.requests);
|
|
187
|
+
context.write(this.requests);
|
|
187
188
|
super.serialize(context);
|
|
188
189
|
}
|
|
189
190
|
|
|
@@ -34,8 +34,8 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
|
|
|
34
34
|
/** @typedef {import("../Module").ExportsType} ExportsType */
|
|
35
35
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
36
36
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
37
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
38
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
37
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, ExternalRequests, string, string]>} ObjectDeserializerContext */
|
|
38
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, ExternalRequests, string, string]>} ObjectSerializerContext */
|
|
39
39
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
40
40
|
/** @typedef {import("../Module").BasicSourceTypes} BasicSourceTypes */
|
|
41
41
|
|
|
@@ -212,11 +212,11 @@ class RemoteModule extends Module {
|
|
|
212
212
|
* @param {ObjectSerializerContext} context context
|
|
213
213
|
*/
|
|
214
214
|
serialize(context) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
context
|
|
216
|
+
.write(this.request)
|
|
217
|
+
.write(this.externalRequests)
|
|
218
|
+
.write(this.internalRequest)
|
|
219
|
+
.write(this.shareScope);
|
|
220
220
|
super.serialize(context);
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -226,9 +226,19 @@ class RemoteModule extends Module {
|
|
|
226
226
|
* @returns {RemoteModule} deserialized module
|
|
227
227
|
*/
|
|
228
228
|
static deserialize(context) {
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
|
|
229
|
+
const request = context.read();
|
|
230
|
+
const c1 = context.rest;
|
|
231
|
+
const externalRequests = c1.read();
|
|
232
|
+
const c2 = c1.rest;
|
|
233
|
+
const internalRequest = c2.read();
|
|
234
|
+
const c3 = c2.rest;
|
|
235
|
+
const obj = new RemoteModule(
|
|
236
|
+
request,
|
|
237
|
+
externalRequests,
|
|
238
|
+
internalRequest,
|
|
239
|
+
c3.read()
|
|
240
|
+
);
|
|
241
|
+
obj.deserialize(c3.rest);
|
|
232
242
|
return obj;
|
|
233
243
|
}
|
|
234
244
|
}
|
|
@@ -60,13 +60,15 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
|
60
60
|
idToExternalAndNameMapping[id] = [shareScope, name, externalModuleId];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
const cst = runtimeTemplate.renderConst();
|
|
64
|
+
const lt = runtimeTemplate.renderLet();
|
|
63
65
|
return Template.asString([
|
|
64
|
-
|
|
66
|
+
`${cst} chunkMapping = ${JSON.stringify(
|
|
65
67
|
chunkToRemotesMapping,
|
|
66
68
|
null,
|
|
67
69
|
"\t"
|
|
68
70
|
)};`,
|
|
69
|
-
|
|
71
|
+
`${cst} idToExternalAndNameMapping = ${JSON.stringify(
|
|
70
72
|
idToExternalAndNameMapping,
|
|
71
73
|
null,
|
|
72
74
|
"\t"
|
|
@@ -77,13 +79,13 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
|
77
79
|
`if(${RuntimeGlobals.hasOwnProperty}(chunkMapping, chunkId)) {`,
|
|
78
80
|
Template.indent([
|
|
79
81
|
`chunkMapping[chunkId].forEach(${runtimeTemplate.basicFunction("id", [
|
|
80
|
-
|
|
82
|
+
`${lt} getScope = ${RuntimeGlobals.currentRemoteGetScope};`,
|
|
81
83
|
"if(!getScope) getScope = [];",
|
|
82
|
-
|
|
84
|
+
`${cst} data = idToExternalAndNameMapping[id];`,
|
|
83
85
|
"if(getScope.indexOf(data) >= 0) return;",
|
|
84
86
|
"getScope.push(data);",
|
|
85
87
|
"if(data.p) return promises.push(data.p);",
|
|
86
|
-
|
|
88
|
+
`${cst} onError = ${runtimeTemplate.basicFunction("error", [
|
|
87
89
|
'if(!error) error = new Error("Container missing");',
|
|
88
90
|
'if(typeof error.message === "string")',
|
|
89
91
|
Template.indent(
|
|
@@ -94,15 +96,15 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
|
94
96
|
}[id] = ${runtimeTemplate.basicFunction("", ["throw error;"])}`,
|
|
95
97
|
"data.p = 0;"
|
|
96
98
|
])};`,
|
|
97
|
-
|
|
99
|
+
`${cst} handleFunction = ${runtimeTemplate.basicFunction(
|
|
98
100
|
"fn, arg1, arg2, d, next, first",
|
|
99
101
|
[
|
|
100
102
|
"try {",
|
|
101
103
|
Template.indent([
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
`${cst} promise = fn(arg1, arg2);`,
|
|
105
|
+
`if(${runtimeTemplate.optionalChaining("promise", "then")}) {`,
|
|
104
106
|
Template.indent([
|
|
105
|
-
|
|
107
|
+
`${cst} p = promise.then(${runtimeTemplate.returningFunction(
|
|
106
108
|
"next(result, d)",
|
|
107
109
|
"result"
|
|
108
110
|
)}, onError);`,
|
|
@@ -117,15 +119,15 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
|
117
119
|
"}"
|
|
118
120
|
]
|
|
119
121
|
)}`,
|
|
120
|
-
|
|
122
|
+
`${cst} onExternal = ${runtimeTemplate.returningFunction(
|
|
121
123
|
`external ? handleFunction(${RuntimeGlobals.initializeSharing}, data[0], 0, external, onInitialized, first) : onError()`,
|
|
122
124
|
"external, _, first"
|
|
123
125
|
)};`,
|
|
124
|
-
|
|
126
|
+
`${cst} onInitialized = ${runtimeTemplate.returningFunction(
|
|
125
127
|
"handleFunction(external.get, data[1], getScope, 0, onFactory, first)",
|
|
126
128
|
"_, external, first"
|
|
127
129
|
)};`,
|
|
128
|
-
|
|
130
|
+
`${cst} onFactory = ${runtimeTemplate.basicFunction("factory", [
|
|
129
131
|
"data.p = 1;",
|
|
130
132
|
`${
|
|
131
133
|
RuntimeGlobals.moduleFactories
|