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
|
@@ -26,6 +26,13 @@ const { propertyAccess } = require("../util/property");
|
|
|
26
26
|
const ConstDependency = require("./ConstDependency");
|
|
27
27
|
const ModuleInitFragmentDependency = require("./ModuleInitFragmentDependency");
|
|
28
28
|
|
|
29
|
+
// Loaded at module scope, not inside the parser handler: the async resolver
|
|
30
|
+
// cache tail can run that handler after a test tears down the module registry.
|
|
31
|
+
const WEBPACK_VERSION = Number.parseInt(
|
|
32
|
+
require("../../package.json").version,
|
|
33
|
+
10
|
|
34
|
+
);
|
|
35
|
+
|
|
29
36
|
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
|
30
37
|
/** @typedef {import("estree").Identifier} Identifier */
|
|
31
38
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
@@ -40,6 +47,29 @@ const ModuleInitFragmentDependency = require("./ModuleInitFragmentDependency");
|
|
|
40
47
|
|
|
41
48
|
const PLUGIN_NAME = "ImportMetaPlugin";
|
|
42
49
|
|
|
50
|
+
const IMPORT_META = "import.meta";
|
|
51
|
+
const IMPORT_META_URL = "import.meta.url";
|
|
52
|
+
const IMPORT_META_WEBPACK = "import.meta.webpack";
|
|
53
|
+
const IMPORT_META_MAIN = "import.meta.main";
|
|
54
|
+
const IMPORT_META_ENV = "import.meta.env";
|
|
55
|
+
const IMPORT_META_DIRNAME = "import.meta.dirname";
|
|
56
|
+
const IMPORT_META_FILENAME = "import.meta.filename";
|
|
57
|
+
|
|
58
|
+
// Single source of truth for `import.meta` accesses that only exist in ES modules
|
|
59
|
+
// and therefore mark a module as ESM (consumed by HarmonyDetectionParserPlugin).
|
|
60
|
+
// `dirname`/`filename` are resolved by NodeStuffPlugin, the rest here. The webpack
|
|
61
|
+
// pragmas `import.meta.webpackHot`/`webpackContext` are intentionally excluded:
|
|
62
|
+
// they are usable in CommonJS modules and must not force ESM.
|
|
63
|
+
const IMPORT_META_NAMES = [
|
|
64
|
+
IMPORT_META,
|
|
65
|
+
IMPORT_META_URL,
|
|
66
|
+
IMPORT_META_WEBPACK,
|
|
67
|
+
IMPORT_META_MAIN,
|
|
68
|
+
IMPORT_META_ENV,
|
|
69
|
+
IMPORT_META_DIRNAME,
|
|
70
|
+
IMPORT_META_FILENAME
|
|
71
|
+
];
|
|
72
|
+
|
|
43
73
|
/** @type {WeakMap<Compilation, { stringify: string, env: Record<string, string> }>} */
|
|
44
74
|
const compilationMetaEnvMap = new WeakMap();
|
|
45
75
|
|
|
@@ -137,7 +167,7 @@ class ImportMetaPlugin {
|
|
|
137
167
|
if (importMetaName === "import.meta") return;
|
|
138
168
|
|
|
139
169
|
parser.hooks.expression
|
|
140
|
-
.for(
|
|
170
|
+
.for(IMPORT_META)
|
|
141
171
|
.tap(PLUGIN_NAME, (metaProperty) => {
|
|
142
172
|
const dep = new ConstDependency(
|
|
143
173
|
/** @type {string} */ (importMetaName),
|
|
@@ -151,13 +181,10 @@ class ImportMetaPlugin {
|
|
|
151
181
|
}
|
|
152
182
|
|
|
153
183
|
// import.meta direct
|
|
154
|
-
const webpackVersion = Number.parseInt(
|
|
155
|
-
require("../../package.json").version,
|
|
156
|
-
10
|
|
157
|
-
);
|
|
158
184
|
const importMetaUrl = () =>
|
|
159
185
|
JSON.stringify(getUrl(parser.state.module));
|
|
160
|
-
const importMetaWebpackVersion = () =>
|
|
186
|
+
const importMetaWebpackVersion = () =>
|
|
187
|
+
JSON.stringify(WEBPACK_VERSION);
|
|
161
188
|
/**
|
|
162
189
|
* Import meta unknown property.
|
|
163
190
|
* @param {Members} members members
|
|
@@ -173,7 +200,7 @@ class ImportMetaPlugin {
|
|
|
173
200
|
};
|
|
174
201
|
|
|
175
202
|
parser.hooks.typeof
|
|
176
|
-
.for(
|
|
203
|
+
.for(IMPORT_META)
|
|
177
204
|
.tap(
|
|
178
205
|
PLUGIN_NAME,
|
|
179
206
|
toConstantDependency(parser, JSON.stringify("object"))
|
|
@@ -185,7 +212,7 @@ class ImportMetaPlugin {
|
|
|
185
212
|
}
|
|
186
213
|
);
|
|
187
214
|
parser.hooks.expression
|
|
188
|
-
.for(
|
|
215
|
+
.for(IMPORT_META)
|
|
189
216
|
.tap(PLUGIN_NAME, (metaProperty) => {
|
|
190
217
|
/** @type {RawRuntimeRequirements} */
|
|
191
218
|
const runtimeRequirements = [];
|
|
@@ -254,7 +281,9 @@ class ImportMetaPlugin {
|
|
|
254
281
|
);
|
|
255
282
|
break;
|
|
256
283
|
case "env":
|
|
257
|
-
str += `env: ${
|
|
284
|
+
str += `env: ${
|
|
285
|
+
collectImportMetaEnvDefinitions(compilation).stringify
|
|
286
|
+
},`;
|
|
258
287
|
break;
|
|
259
288
|
default:
|
|
260
289
|
str += `[${JSON.stringify(
|
|
@@ -273,22 +302,22 @@ class ImportMetaPlugin {
|
|
|
273
302
|
return true;
|
|
274
303
|
});
|
|
275
304
|
parser.hooks.evaluateTypeof
|
|
276
|
-
.for(
|
|
305
|
+
.for(IMPORT_META)
|
|
277
306
|
.tap(PLUGIN_NAME, evaluateToString("object"));
|
|
278
|
-
parser.hooks.evaluateIdentifier.for(
|
|
307
|
+
parser.hooks.evaluateIdentifier.for(IMPORT_META).tap(
|
|
279
308
|
PLUGIN_NAME,
|
|
280
|
-
evaluateToIdentifier(
|
|
309
|
+
evaluateToIdentifier(IMPORT_META, IMPORT_META, () => [], true)
|
|
281
310
|
);
|
|
282
311
|
|
|
283
312
|
// import.meta.url
|
|
284
313
|
parser.hooks.typeof
|
|
285
|
-
.for(
|
|
314
|
+
.for(IMPORT_META_URL)
|
|
286
315
|
.tap(
|
|
287
316
|
PLUGIN_NAME,
|
|
288
317
|
toConstantDependency(parser, JSON.stringify("string"))
|
|
289
318
|
);
|
|
290
319
|
parser.hooks.expression
|
|
291
|
-
.for(
|
|
320
|
+
.for(IMPORT_META_URL)
|
|
292
321
|
.tap(PLUGIN_NAME, (expr) => {
|
|
293
322
|
const dep = new ConstDependency(
|
|
294
323
|
importMetaUrl(),
|
|
@@ -299,10 +328,10 @@ class ImportMetaPlugin {
|
|
|
299
328
|
return true;
|
|
300
329
|
});
|
|
301
330
|
parser.hooks.evaluateTypeof
|
|
302
|
-
.for(
|
|
331
|
+
.for(IMPORT_META_URL)
|
|
303
332
|
.tap(PLUGIN_NAME, evaluateToString("string"));
|
|
304
333
|
parser.hooks.evaluateIdentifier
|
|
305
|
-
.for(
|
|
334
|
+
.for(IMPORT_META_URL)
|
|
306
335
|
.tap(PLUGIN_NAME, (expr) =>
|
|
307
336
|
new BasicEvaluatedExpression()
|
|
308
337
|
.setString(getUrl(parser.state.module))
|
|
@@ -311,26 +340,26 @@ class ImportMetaPlugin {
|
|
|
311
340
|
|
|
312
341
|
// import.meta.webpack
|
|
313
342
|
parser.hooks.expression
|
|
314
|
-
.for(
|
|
343
|
+
.for(IMPORT_META_WEBPACK)
|
|
315
344
|
.tap(
|
|
316
345
|
PLUGIN_NAME,
|
|
317
346
|
toConstantDependency(parser, importMetaWebpackVersion())
|
|
318
347
|
);
|
|
319
348
|
parser.hooks.typeof
|
|
320
|
-
.for(
|
|
349
|
+
.for(IMPORT_META_WEBPACK)
|
|
321
350
|
.tap(
|
|
322
351
|
PLUGIN_NAME,
|
|
323
352
|
toConstantDependency(parser, JSON.stringify("number"))
|
|
324
353
|
);
|
|
325
354
|
parser.hooks.evaluateTypeof
|
|
326
|
-
.for(
|
|
355
|
+
.for(IMPORT_META_WEBPACK)
|
|
327
356
|
.tap(PLUGIN_NAME, evaluateToString("number"));
|
|
328
357
|
parser.hooks.evaluateIdentifier
|
|
329
|
-
.for(
|
|
330
|
-
.tap(PLUGIN_NAME, evaluateToNumber(
|
|
358
|
+
.for(IMPORT_META_WEBPACK)
|
|
359
|
+
.tap(PLUGIN_NAME, evaluateToNumber(WEBPACK_VERSION));
|
|
331
360
|
|
|
332
361
|
parser.hooks.expression
|
|
333
|
-
.for(
|
|
362
|
+
.for(IMPORT_META_MAIN)
|
|
334
363
|
.tap(
|
|
335
364
|
PLUGIN_NAME,
|
|
336
365
|
toConstantDependency(
|
|
@@ -344,24 +373,24 @@ class ImportMetaPlugin {
|
|
|
344
373
|
)
|
|
345
374
|
);
|
|
346
375
|
parser.hooks.typeof
|
|
347
|
-
.for(
|
|
376
|
+
.for(IMPORT_META_MAIN)
|
|
348
377
|
.tap(
|
|
349
378
|
PLUGIN_NAME,
|
|
350
379
|
toConstantDependency(parser, JSON.stringify("boolean"))
|
|
351
380
|
);
|
|
352
381
|
parser.hooks.evaluateTypeof
|
|
353
|
-
.for(
|
|
382
|
+
.for(IMPORT_META_MAIN)
|
|
354
383
|
.tap(PLUGIN_NAME, evaluateToString("boolean"));
|
|
355
384
|
|
|
356
385
|
// import.meta.env
|
|
357
386
|
parser.hooks.typeof
|
|
358
|
-
.for(
|
|
387
|
+
.for(IMPORT_META_ENV)
|
|
359
388
|
.tap(
|
|
360
389
|
PLUGIN_NAME,
|
|
361
390
|
toConstantDependency(parser, JSON.stringify("object"))
|
|
362
391
|
);
|
|
363
392
|
parser.hooks.expressionMemberChain
|
|
364
|
-
.for(
|
|
393
|
+
.for(IMPORT_META)
|
|
365
394
|
.tap(PLUGIN_NAME, (expr, members) => {
|
|
366
395
|
if (members[0] === "env" && members[1]) {
|
|
367
396
|
const name = members[1];
|
|
@@ -378,7 +407,7 @@ class ImportMetaPlugin {
|
|
|
378
407
|
}
|
|
379
408
|
});
|
|
380
409
|
parser.hooks.expression
|
|
381
|
-
.for(
|
|
410
|
+
.for(IMPORT_META_ENV)
|
|
382
411
|
.tap(PLUGIN_NAME, (expr) => {
|
|
383
412
|
const { stringify } =
|
|
384
413
|
collectImportMetaEnvDefinitions(compilation);
|
|
@@ -392,10 +421,10 @@ class ImportMetaPlugin {
|
|
|
392
421
|
return true;
|
|
393
422
|
});
|
|
394
423
|
parser.hooks.evaluateTypeof
|
|
395
|
-
.for(
|
|
424
|
+
.for(IMPORT_META_ENV)
|
|
396
425
|
.tap(PLUGIN_NAME, evaluateToString("object"));
|
|
397
426
|
parser.hooks.evaluateIdentifier
|
|
398
|
-
.for(
|
|
427
|
+
.for(IMPORT_META_ENV)
|
|
399
428
|
.tap(PLUGIN_NAME, (expr) =>
|
|
400
429
|
new BasicEvaluatedExpression()
|
|
401
430
|
.setTruthy()
|
|
@@ -405,7 +434,7 @@ class ImportMetaPlugin {
|
|
|
405
434
|
|
|
406
435
|
// Unknown properties
|
|
407
436
|
parser.hooks.unhandledExpressionMemberChain
|
|
408
|
-
.for(
|
|
437
|
+
.for(IMPORT_META)
|
|
409
438
|
.tap(PLUGIN_NAME, (expr, members) => {
|
|
410
439
|
// unknown import.meta properties should be determined at runtime
|
|
411
440
|
if (importMeta === "preserve-unknown") {
|
|
@@ -442,6 +471,18 @@ class ImportMetaPlugin {
|
|
|
442
471
|
expr.property.type ===
|
|
443
472
|
(expr.computed ? "Literal" : "Identifier")
|
|
444
473
|
) {
|
|
474
|
+
const prop = expr.computed
|
|
475
|
+
? /** @type {import("estree").Literal} */ (expr.property)
|
|
476
|
+
.value
|
|
477
|
+
: /** @type {Identifier} */ (expr.property).name;
|
|
478
|
+
// dirname/filename are resolved by NodeStuffPlugin; main is a runtime value
|
|
479
|
+
if (
|
|
480
|
+
prop === "dirname" ||
|
|
481
|
+
prop === "filename" ||
|
|
482
|
+
prop === "main"
|
|
483
|
+
) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
445
486
|
return new BasicEvaluatedExpression()
|
|
446
487
|
.setUndefined()
|
|
447
488
|
.setRange(/** @type {Range} */ (expr.range));
|
|
@@ -461,3 +502,6 @@ class ImportMetaPlugin {
|
|
|
461
502
|
}
|
|
462
503
|
|
|
463
504
|
module.exports = ImportMetaPlugin;
|
|
505
|
+
module.exports.IMPORT_META_DIRNAME = IMPORT_META_DIRNAME;
|
|
506
|
+
module.exports.IMPORT_META_FILENAME = IMPORT_META_FILENAME;
|
|
507
|
+
module.exports.IMPORT_META_NAMES = IMPORT_META_NAMES;
|
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
VariableInfo,
|
|
13
13
|
getImportAttributes
|
|
14
14
|
} = require("../javascript/JavascriptParser");
|
|
15
|
+
const memoize = require("../util/memoize");
|
|
15
16
|
const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties");
|
|
16
17
|
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
|
|
17
18
|
const { getNonOptionalPart } = require("./HarmonyImportDependency");
|
|
@@ -42,6 +43,8 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
|
|
42
43
|
/** @typedef {{ references: RawReferencedExports, expression: ImportExpression }} ImportSettings */
|
|
43
44
|
/** @typedef {WeakMap<ImportExpression, RawReferencedExports>} State */
|
|
44
45
|
|
|
46
|
+
const getHarmonyImportGuard = memoize(() => require("./HarmonyImportGuard"));
|
|
47
|
+
|
|
45
48
|
/** @type {WeakMap<JavascriptParserState, State>} */
|
|
46
49
|
const parserStateMap = new WeakMap();
|
|
47
50
|
const dynamicImportTag = Symbol("import()");
|
|
@@ -177,6 +180,7 @@ class ImportParserPlugin {
|
|
|
177
180
|
* @param {JavascriptParserOptions} options options
|
|
178
181
|
*/
|
|
179
182
|
constructor(options) {
|
|
183
|
+
/** @type {JavascriptParserOptions} */
|
|
180
184
|
this.options = options;
|
|
181
185
|
}
|
|
182
186
|
|
|
@@ -452,6 +456,20 @@ class ImportParserPlugin {
|
|
|
452
456
|
exports = exportsFromEnumerable(importOptions.webpackExports);
|
|
453
457
|
}
|
|
454
458
|
}
|
|
459
|
+
// `worker` is an internal entry option set only for workers
|
|
460
|
+
if (
|
|
461
|
+
importOptions.webpackEntryOptions !== undefined &&
|
|
462
|
+
typeof importOptions.webpackEntryOptions === "object" &&
|
|
463
|
+
importOptions.webpackEntryOptions !== null &&
|
|
464
|
+
importOptions.webpackEntryOptions.worker !== undefined
|
|
465
|
+
) {
|
|
466
|
+
parser.state.module.addWarning(
|
|
467
|
+
new UnsupportedFeatureWarning(
|
|
468
|
+
"`worker` entry option is not supported in `import()`, it only applies to workers (e.g. `new Worker(new URL(...))`).",
|
|
469
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
|
470
|
+
)
|
|
471
|
+
);
|
|
472
|
+
}
|
|
455
473
|
}
|
|
456
474
|
|
|
457
475
|
if (
|
|
@@ -550,6 +568,7 @@ class ImportParserPlugin {
|
|
|
550
568
|
dep.optional = Boolean(parser.scope.inTry);
|
|
551
569
|
depBlock.addDependency(dep);
|
|
552
570
|
parser.state.current.addBlock(depBlock);
|
|
571
|
+
getHarmonyImportGuard().attachDependencyGuards(parser, dep);
|
|
553
572
|
}
|
|
554
573
|
} else {
|
|
555
574
|
if (mode === "weak") {
|
|
@@ -14,8 +14,8 @@ const NullDependency = require("./NullDependency");
|
|
|
14
14
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
15
15
|
/** @typedef {import("../json/JsonData")} JsonData */
|
|
16
16
|
/** @typedef {import("../json/JsonData").JsonValue} JsonValue */
|
|
17
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
18
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
17
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[JsonData, number]>} ObjectDeserializerContext */
|
|
18
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[JsonData, number]>} ObjectSerializerContext */
|
|
19
19
|
/** @typedef {import("../util/Hash")} Hash */
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -79,7 +79,9 @@ class JsonExportsDependency extends NullDependency {
|
|
|
79
79
|
*/
|
|
80
80
|
constructor(data, exportsDepth) {
|
|
81
81
|
super();
|
|
82
|
+
/** @type {JsonData} */
|
|
82
83
|
this.data = data;
|
|
84
|
+
/** @type {number} */
|
|
83
85
|
this.exportsDepth = exportsDepth;
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -116,9 +118,7 @@ class JsonExportsDependency extends NullDependency {
|
|
|
116
118
|
* @param {ObjectSerializerContext} context context
|
|
117
119
|
*/
|
|
118
120
|
serialize(context) {
|
|
119
|
-
|
|
120
|
-
write(this.data);
|
|
121
|
-
write(this.exportsDepth);
|
|
121
|
+
context.write(this.data).write(this.exportsDepth);
|
|
122
122
|
super.serialize(context);
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -127,10 +127,10 @@ class JsonExportsDependency extends NullDependency {
|
|
|
127
127
|
* @param {ObjectDeserializerContext} context context
|
|
128
128
|
*/
|
|
129
129
|
deserialize(context) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.exportsDepth = read();
|
|
133
|
-
super.deserialize(
|
|
130
|
+
this.data = context.read();
|
|
131
|
+
const c1 = context.rest;
|
|
132
|
+
this.exportsDepth = c1.read();
|
|
133
|
+
super.deserialize(c1.rest);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
|
|
10
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
11
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
10
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, number, boolean]>} ObjectDeserializerContext */
|
|
11
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, number, boolean]>} ObjectSerializerContext */
|
|
12
12
|
|
|
13
13
|
class LocalModule {
|
|
14
14
|
/**
|
|
@@ -17,8 +17,11 @@ class LocalModule {
|
|
|
17
17
|
* @param {number} idx index
|
|
18
18
|
*/
|
|
19
19
|
constructor(name, idx) {
|
|
20
|
+
/** @type {string} */
|
|
20
21
|
this.name = name;
|
|
22
|
+
/** @type {number} */
|
|
21
23
|
this.idx = idx;
|
|
24
|
+
/** @type {boolean} */
|
|
22
25
|
this.used = false;
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -39,11 +42,7 @@ class LocalModule {
|
|
|
39
42
|
* @param {ObjectSerializerContext} context context
|
|
40
43
|
*/
|
|
41
44
|
serialize(context) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
write(this.name);
|
|
45
|
-
write(this.idx);
|
|
46
|
-
write(this.used);
|
|
45
|
+
context.write(this.name).write(this.idx).write(this.used);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
/**
|
|
@@ -51,11 +50,11 @@ class LocalModule {
|
|
|
51
50
|
* @param {ObjectDeserializerContext} context context
|
|
52
51
|
*/
|
|
53
52
|
deserialize(context) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
this.used = read();
|
|
53
|
+
this.name = context.read();
|
|
54
|
+
const c1 = context.rest;
|
|
55
|
+
this.idx = c1.read();
|
|
56
|
+
const c2 = c1.rest;
|
|
57
|
+
this.used = c2.read();
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -12,8 +12,8 @@ const NullDependency = require("./NullDependency");
|
|
|
12
12
|
/** @typedef {import("../Dependency")} Dependency */
|
|
13
13
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
14
14
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
15
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
16
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[LocalModule, Range | undefined, boolean]>} ObjectDeserializerContext */
|
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[LocalModule, Range | undefined, boolean]>} ObjectSerializerContext */
|
|
17
17
|
/** @typedef {import("./LocalModule")} LocalModule */
|
|
18
18
|
|
|
19
19
|
class LocalModuleDependency extends NullDependency {
|
|
@@ -26,8 +26,10 @@ class LocalModuleDependency extends NullDependency {
|
|
|
26
26
|
constructor(localModule, range, callNew) {
|
|
27
27
|
super();
|
|
28
28
|
|
|
29
|
+
/** @type {LocalModule} */
|
|
29
30
|
this.localModule = localModule;
|
|
30
31
|
this.range = range;
|
|
32
|
+
/** @type {boolean} */
|
|
31
33
|
this.callNew = callNew;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -36,11 +38,7 @@ class LocalModuleDependency extends NullDependency {
|
|
|
36
38
|
* @param {ObjectSerializerContext} context context
|
|
37
39
|
*/
|
|
38
40
|
serialize(context) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
write(this.localModule);
|
|
42
|
-
write(this.range);
|
|
43
|
-
write(this.callNew);
|
|
41
|
+
context.write(this.localModule).write(this.range).write(this.callNew);
|
|
44
42
|
|
|
45
43
|
super.serialize(context);
|
|
46
44
|
}
|
|
@@ -50,13 +48,13 @@ class LocalModuleDependency extends NullDependency {
|
|
|
50
48
|
* @param {ObjectDeserializerContext} context context
|
|
51
49
|
*/
|
|
52
50
|
deserialize(context) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
this.callNew = read();
|
|
51
|
+
this.localModule = context.read();
|
|
52
|
+
const c1 = context.rest;
|
|
53
|
+
this.range = c1.read();
|
|
54
|
+
const c2 = c1.rest;
|
|
55
|
+
this.callNew = c2.read();
|
|
58
56
|
|
|
59
|
-
super.deserialize(
|
|
57
|
+
super.deserialize(c2.rest);
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
|
|
@@ -16,8 +16,8 @@ const NullDependency = require("./NullDependency");
|
|
|
16
16
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
17
17
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
18
18
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
19
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
20
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
19
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, boolean]>} ObjectDeserializerContext */
|
|
20
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, boolean]>} ObjectSerializerContext */
|
|
21
21
|
/** @typedef {import("../util/Hash")} Hash */
|
|
22
22
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
23
23
|
|
|
@@ -29,7 +29,9 @@ class ModuleDecoratorDependency extends NullDependency {
|
|
|
29
29
|
*/
|
|
30
30
|
constructor(decorator, allowExportsAccess) {
|
|
31
31
|
super();
|
|
32
|
+
/** @type {string} */
|
|
32
33
|
this.decorator = decorator;
|
|
34
|
+
/** @type {boolean} */
|
|
33
35
|
this.allowExportsAccess = allowExportsAccess;
|
|
34
36
|
/** @type {undefined | string} */
|
|
35
37
|
this._hashUpdate = undefined;
|
|
@@ -85,9 +87,7 @@ class ModuleDecoratorDependency extends NullDependency {
|
|
|
85
87
|
* @param {ObjectSerializerContext} context context
|
|
86
88
|
*/
|
|
87
89
|
serialize(context) {
|
|
88
|
-
|
|
89
|
-
write(this.decorator);
|
|
90
|
-
write(this.allowExportsAccess);
|
|
90
|
+
context.write(this.decorator).write(this.allowExportsAccess);
|
|
91
91
|
super.serialize(context);
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -96,10 +96,10 @@ class ModuleDecoratorDependency extends NullDependency {
|
|
|
96
96
|
* @param {ObjectDeserializerContext} context context
|
|
97
97
|
*/
|
|
98
98
|
deserialize(context) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.allowExportsAccess = read();
|
|
102
|
-
super.deserialize(
|
|
99
|
+
this.decorator = context.read();
|
|
100
|
+
const c1 = context.rest;
|
|
101
|
+
this.allowExportsAccess = c1.read();
|
|
102
|
+
super.deserialize(c1.rest);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -23,13 +23,18 @@ class ModuleDependency extends Dependency {
|
|
|
23
23
|
*/
|
|
24
24
|
constructor(request, sourceOrder) {
|
|
25
25
|
super();
|
|
26
|
+
/** @type {string} */
|
|
26
27
|
this.request = request;
|
|
28
|
+
/** @type {string} */
|
|
27
29
|
this.userRequest = request;
|
|
30
|
+
/** @type {number | undefined} */
|
|
28
31
|
this.sourceOrder = sourceOrder;
|
|
29
32
|
/** @type {Range | undefined} */
|
|
30
33
|
this.range = undefined;
|
|
31
34
|
/** @type {undefined | string} */
|
|
32
35
|
this._context = undefined;
|
|
36
|
+
/** @type {boolean} */
|
|
37
|
+
this.weak = false;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
/**
|
|
@@ -84,6 +89,7 @@ class ModuleDependency extends Dependency {
|
|
|
84
89
|
write(this._context);
|
|
85
90
|
write(this.range);
|
|
86
91
|
write(this.sourceOrder);
|
|
92
|
+
write(this.weak);
|
|
87
93
|
super.serialize(context);
|
|
88
94
|
}
|
|
89
95
|
|
|
@@ -98,6 +104,7 @@ class ModuleDependency extends Dependency {
|
|
|
98
104
|
this._context = read();
|
|
99
105
|
this.range = read();
|
|
100
106
|
this.sourceOrder = read();
|
|
107
|
+
this.weak = read();
|
|
101
108
|
super.deserialize(context);
|
|
102
109
|
}
|
|
103
110
|
}
|
|
@@ -12,8 +12,8 @@ const NullDependency = require("./NullDependency");
|
|
|
12
12
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
13
13
|
/** @typedef {import("../Dependency")} Dependency */
|
|
14
14
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
15
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, string[], string | undefined]>} ObjectSerializerContext */
|
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, string[], string | undefined]>} ObjectDeserializerContext */
|
|
17
17
|
/**
|
|
18
18
|
* A dependency that adds an init fragment to the module
|
|
19
19
|
*/
|
|
@@ -26,8 +26,11 @@ class ModuleInitFragmentDependency extends NullDependency {
|
|
|
26
26
|
*/
|
|
27
27
|
constructor(initCode, runtimeRequirements, key) {
|
|
28
28
|
super();
|
|
29
|
+
/** @type {string} */
|
|
29
30
|
this.initCode = initCode;
|
|
31
|
+
/** @type {string[]} */
|
|
30
32
|
this.runtimeRequirements = runtimeRequirements;
|
|
33
|
+
/** @type {string | undefined} */
|
|
31
34
|
this.key = key;
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -36,10 +39,10 @@ class ModuleInitFragmentDependency extends NullDependency {
|
|
|
36
39
|
* @param {ObjectSerializerContext} context context
|
|
37
40
|
*/
|
|
38
41
|
serialize(context) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
context
|
|
43
|
+
.write(this.initCode)
|
|
44
|
+
.write(this.runtimeRequirements)
|
|
45
|
+
.write(this.key);
|
|
43
46
|
super.serialize(context);
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -48,11 +51,12 @@ class ModuleInitFragmentDependency extends NullDependency {
|
|
|
48
51
|
* @param {ObjectDeserializerContext} context context
|
|
49
52
|
*/
|
|
50
53
|
deserialize(context) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.runtimeRequirements = read();
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
this.initCode = context.read();
|
|
55
|
+
const c1 = context.rest;
|
|
56
|
+
this.runtimeRequirements = c1.read();
|
|
57
|
+
const c2 = c1.rest;
|
|
58
|
+
this.key = c2.read();
|
|
59
|
+
super.deserialize(c2.rest);
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
|