webpack 5.101.3 → 5.102.1
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/README.md +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +105 -90
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +42 -25
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +4 -7
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +33 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportContextDependency.js +13 -0
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +3 -2
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +4 -12
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +15 -6
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RealContentHashPlugin.js +5 -3
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +179 -95
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/Hash.js +35 -5
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +1 -2
- package/lib/util/createHash.js +85 -15
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -13
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
|
@@ -24,7 +24,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
24
24
|
/** @typedef {import("estree").BlockStatement} BlockStatement */
|
|
25
25
|
/** @typedef {import("estree").SequenceExpression} SequenceExpression */
|
|
26
26
|
/** @typedef {import("estree").CallExpression} CallExpression */
|
|
27
|
-
/** @typedef {import("estree").BaseCallExpression} BaseCallExpression */
|
|
28
27
|
/** @typedef {import("estree").StaticBlock} StaticBlock */
|
|
29
28
|
/** @typedef {import("estree").ClassDeclaration} ClassDeclaration */
|
|
30
29
|
/** @typedef {import("estree").ForStatement} ForStatement */
|
|
@@ -36,6 +35,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
36
35
|
/** @typedef {import("estree").PrivateIdentifier} PrivateIdentifier */
|
|
37
36
|
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
|
|
38
37
|
/** @typedef {import("estree").Expression} Expression */
|
|
38
|
+
/** @typedef {import("estree").ImportAttribute} ImportAttribute */
|
|
39
|
+
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
|
|
39
40
|
/** @typedef {import("estree").Identifier} Identifier */
|
|
40
41
|
/** @typedef {import("estree").VariableDeclaration} VariableDeclaration */
|
|
41
42
|
/** @typedef {import("estree").IfStatement} IfStatement */
|
|
@@ -48,7 +49,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
48
49
|
/** @typedef {import("estree").MetaProperty} MetaProperty */
|
|
49
50
|
/** @typedef {import("estree").Property} Property */
|
|
50
51
|
/** @typedef {import("estree").AssignmentPattern} AssignmentPattern */
|
|
51
|
-
/** @typedef {import("estree").ChainElement} ChainElement */
|
|
52
52
|
/** @typedef {import("estree").Pattern} Pattern */
|
|
53
53
|
/** @typedef {import("estree").UpdateExpression} UpdateExpression */
|
|
54
54
|
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
|
@@ -74,6 +74,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
74
74
|
/** @typedef {import("estree").WhileStatement} WhileStatement */
|
|
75
75
|
/** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
|
|
76
76
|
/** @typedef {import("estree").ExpressionStatement} ExpressionStatement */
|
|
77
|
+
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
|
|
78
|
+
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
|
|
77
79
|
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
|
|
78
80
|
/** @typedef {import("estree").DoWhileStatement} DoWhileStatement */
|
|
79
81
|
/** @typedef {import("estree").TryStatement} TryStatement */
|
|
@@ -83,10 +85,9 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
83
85
|
/** @typedef {import("estree").Statement} Statement */
|
|
84
86
|
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
|
|
85
87
|
/** @typedef {import("estree").Super} Super */
|
|
86
|
-
/** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
|
|
87
88
|
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
|
|
88
89
|
/** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
|
|
89
|
-
/** @typedef {import("estree").
|
|
90
|
+
/** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
|
|
90
91
|
/** @typedef {import("estree").MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration */
|
|
91
92
|
/** @typedef {import("estree").MaybeNamedClassDeclaration} MaybeNamedClassDeclaration */
|
|
92
93
|
/**
|
|
@@ -95,19 +96,17 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
|
95
96
|
*/
|
|
96
97
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
97
98
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
|
98
|
-
|
|
99
|
+
|
|
100
|
+
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges }} GetInfoResult */
|
|
99
101
|
/** @typedef {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} StatementPathItem */
|
|
100
102
|
/** @typedef {(ident: string) => void} OnIdentString */
|
|
101
103
|
/** @typedef {(ident: string, identifier: Identifier) => void} OnIdent */
|
|
102
104
|
/** @typedef {StatementPathItem[]} StatementPath */
|
|
103
105
|
|
|
106
|
+
/** @typedef {Set<DestructuringAssignmentProperty>} DestructuringAssignmentProperties */
|
|
107
|
+
|
|
104
108
|
// TODO remove cast when @types/estree has been updated to import assertions
|
|
105
|
-
/** @typedef {import("estree").
|
|
106
|
-
/** @typedef {import("estree").ImportDeclaration & { attributes?: Array<ImportAttribute>, phase?: "defer" }} ImportDeclaration */
|
|
107
|
-
/** @typedef {import("estree").ExportNamedDeclaration & { attributes?: Array<ImportAttribute> }} ExportNamedDeclaration */
|
|
108
|
-
/** @typedef {import("estree").ExportAllDeclaration & { attributes?: Array<ImportAttribute> }} ExportAllDeclaration */
|
|
109
|
-
/** @typedef {import("estree").ImportExpression & { options?: Expression | null, phase?: "defer" }} ImportExpression */
|
|
110
|
-
/** @typedef {ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration} ModuleDeclaration */
|
|
109
|
+
/** @typedef {import("estree").ImportExpression & { phase?: "defer" }} ImportExpression */
|
|
111
110
|
|
|
112
111
|
/** @type {string[]} */
|
|
113
112
|
const EMPTY_ARRAY = [];
|
|
@@ -301,7 +300,15 @@ class VariableInfo {
|
|
|
301
300
|
/** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
|
|
302
301
|
|
|
303
302
|
/** @typedef {symbol} Tag */
|
|
304
|
-
|
|
303
|
+
|
|
304
|
+
/** @typedef {import("../dependencies/HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
|
305
|
+
/** @typedef {import("../dependencies/ImportParserPlugin").ImportSettings} ImportSettings */
|
|
306
|
+
/** @typedef {import("../dependencies/CommonJsImportsParserPlugin").CommonJsImportSettings} CommonJsImportSettings */
|
|
307
|
+
/** @typedef {import("../CompatibilityPlugin").CompatibilitySettings} CompatibilitySettings */
|
|
308
|
+
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
|
|
309
|
+
|
|
310
|
+
/** @typedef {HarmonySettings | ImportSettings | CommonJsImportSettings | TopLevelSymbol | CompatibilitySettings} KnownTagData */
|
|
311
|
+
/** @typedef {KnownTagData | Record<string, EXPECTED_ANY>} TagData */
|
|
305
312
|
|
|
306
313
|
/**
|
|
307
314
|
* @typedef {object} TagInfo
|
|
@@ -310,6 +317,11 @@ class VariableInfo {
|
|
|
310
317
|
* @property {TagInfo | undefined} next
|
|
311
318
|
*/
|
|
312
319
|
|
|
320
|
+
/** @typedef {string[]} CalleeMembers */
|
|
321
|
+
/** @typedef {string[]} Members */
|
|
322
|
+
/** @typedef {boolean[]} MembersOptionals */
|
|
323
|
+
/** @typedef {Range[]} MemberRanges */
|
|
324
|
+
|
|
313
325
|
const SCOPE_INFO_TERMINATED_RETURN = 1;
|
|
314
326
|
const SCOPE_INFO_TERMINATED_THROW = 2;
|
|
315
327
|
|
|
@@ -330,7 +342,8 @@ const SCOPE_INFO_TERMINATED_THROW = 2;
|
|
|
330
342
|
/**
|
|
331
343
|
* @typedef {object} DestructuringAssignmentProperty
|
|
332
344
|
* @property {string} id
|
|
333
|
-
* @property {Range
|
|
345
|
+
* @property {Range} range
|
|
346
|
+
* @property {Set<DestructuringAssignmentProperty> | undefined=} pattern
|
|
334
347
|
* @property {boolean | string} shorthand
|
|
335
348
|
*/
|
|
336
349
|
|
|
@@ -359,7 +372,7 @@ const joinRanges = (startRange, endRange) => {
|
|
|
359
372
|
* Helper function used to generate a string representation of a
|
|
360
373
|
* [member expression](https://github.com/estree/estree/blob/master/es5.md#memberexpression).
|
|
361
374
|
* @param {string} object object to name
|
|
362
|
-
* @param {
|
|
375
|
+
* @param {Members} membersReversed reversed list of members
|
|
363
376
|
* @returns {string} member expression as a string
|
|
364
377
|
* @example
|
|
365
378
|
* ```js
|
|
@@ -532,20 +545,20 @@ class JavascriptParser extends Parser {
|
|
|
532
545
|
rename: new HookMap(() => new SyncBailHook(["initExpression"])),
|
|
533
546
|
/** @type {HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>} */
|
|
534
547
|
assign: new HookMap(() => new SyncBailHook(["expression"])),
|
|
535
|
-
/** @type {HookMap<SyncBailHook<[AssignmentExpression,
|
|
548
|
+
/** @type {HookMap<SyncBailHook<[AssignmentExpression, Members], boolean | void>>} */
|
|
536
549
|
assignMemberChain: new HookMap(
|
|
537
550
|
() => new SyncBailHook(["expression", "members"])
|
|
538
551
|
),
|
|
539
552
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
540
553
|
typeof: new HookMap(() => new SyncBailHook(["expression"])),
|
|
541
|
-
/** @type {SyncBailHook<[ImportExpression], boolean | void>} */
|
|
542
|
-
importCall: new SyncBailHook(["expression"]),
|
|
554
|
+
/** @type {SyncBailHook<[ImportExpression, CallExpression?], boolean | void>} */
|
|
555
|
+
importCall: new SyncBailHook(["expression", "importThen"]),
|
|
543
556
|
/** @type {SyncBailHook<[Expression | ForOfStatement], boolean | void>} */
|
|
544
557
|
topLevelAwait: new SyncBailHook(["expression"]),
|
|
545
558
|
/** @type {HookMap<SyncBailHook<[CallExpression], boolean | void>>} */
|
|
546
559
|
call: new HookMap(() => new SyncBailHook(["expression"])),
|
|
547
560
|
/** Something like "a.b()" */
|
|
548
|
-
/** @type {HookMap<SyncBailHook<[CallExpression,
|
|
561
|
+
/** @type {HookMap<SyncBailHook<[CallExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
|
|
549
562
|
callMemberChain: new HookMap(
|
|
550
563
|
() =>
|
|
551
564
|
new SyncBailHook([
|
|
@@ -556,7 +569,7 @@ class JavascriptParser extends Parser {
|
|
|
556
569
|
])
|
|
557
570
|
),
|
|
558
571
|
/** Something like "a.b().c.d" */
|
|
559
|
-
/** @type {HookMap<SyncBailHook<[Expression,
|
|
572
|
+
/** @type {HookMap<SyncBailHook<[Expression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
|
|
560
573
|
memberChainOfCallMemberChain: new HookMap(
|
|
561
574
|
() =>
|
|
562
575
|
new SyncBailHook([
|
|
@@ -568,7 +581,7 @@ class JavascriptParser extends Parser {
|
|
|
568
581
|
])
|
|
569
582
|
),
|
|
570
583
|
/** Something like "a.b().c.d()"" */
|
|
571
|
-
/** @type {HookMap<SyncBailHook<[CallExpression,
|
|
584
|
+
/** @type {HookMap<SyncBailHook<[CallExpression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
|
|
572
585
|
callMemberChainOfCallMemberChain: new HookMap(
|
|
573
586
|
() =>
|
|
574
587
|
new SyncBailHook([
|
|
@@ -587,7 +600,7 @@ class JavascriptParser extends Parser {
|
|
|
587
600
|
binaryExpression: new SyncBailHook(["binaryExpression"]),
|
|
588
601
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
589
602
|
expression: new HookMap(() => new SyncBailHook(["expression"])),
|
|
590
|
-
/** @type {HookMap<SyncBailHook<[MemberExpression,
|
|
603
|
+
/** @type {HookMap<SyncBailHook<[MemberExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
|
|
591
604
|
expressionMemberChain: new HookMap(
|
|
592
605
|
() =>
|
|
593
606
|
new SyncBailHook([
|
|
@@ -597,7 +610,7 @@ class JavascriptParser extends Parser {
|
|
|
597
610
|
"memberRanges"
|
|
598
611
|
])
|
|
599
612
|
),
|
|
600
|
-
/** @type {HookMap<SyncBailHook<[MemberExpression,
|
|
613
|
+
/** @type {HookMap<SyncBailHook<[MemberExpression, Members], boolean | void>>} */
|
|
601
614
|
unhandledExpressionMemberChain: new HookMap(
|
|
602
615
|
() => new SyncBailHook(["expression", "members"])
|
|
603
616
|
),
|
|
@@ -616,9 +629,9 @@ class JavascriptParser extends Parser {
|
|
|
616
629
|
});
|
|
617
630
|
this.sourceType = sourceType;
|
|
618
631
|
/** @type {ScopeInfo} */
|
|
619
|
-
this.scope = /** @type {
|
|
632
|
+
this.scope = /** @type {EXPECTED_ANY} */ (undefined);
|
|
620
633
|
/** @type {ParserState} */
|
|
621
|
-
this.state = /** @type {
|
|
634
|
+
this.state = /** @type {EXPECTED_ANY} */ (undefined);
|
|
622
635
|
/** @type {Comment[] | undefined} */
|
|
623
636
|
this.comments = undefined;
|
|
624
637
|
/** @type {Set<number> | undefined} */
|
|
@@ -627,7 +640,7 @@ class JavascriptParser extends Parser {
|
|
|
627
640
|
this.statementPath = undefined;
|
|
628
641
|
/** @type {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | undefined} */
|
|
629
642
|
this.prevStatement = undefined;
|
|
630
|
-
/** @type {WeakMap<Expression,
|
|
643
|
+
/** @type {WeakMap<Expression, DestructuringAssignmentProperties> | undefined} */
|
|
631
644
|
this.destructuringAssignmentProperties = undefined;
|
|
632
645
|
/** @type {TagData | undefined} */
|
|
633
646
|
this.currentTagData = undefined;
|
|
@@ -1891,7 +1904,7 @@ class JavascriptParser extends Parser {
|
|
|
1891
1904
|
|
|
1892
1905
|
/**
|
|
1893
1906
|
* @param {Expression} node node
|
|
1894
|
-
* @returns {
|
|
1907
|
+
* @returns {DestructuringAssignmentProperties | undefined} destructured identifiers
|
|
1895
1908
|
*/
|
|
1896
1909
|
destructuringAssignmentPropertiesFor(node) {
|
|
1897
1910
|
if (!this.destructuringAssignmentProperties) return;
|
|
@@ -2644,7 +2657,7 @@ class JavascriptParser extends Parser {
|
|
|
2644
2657
|
// check multiple assignments
|
|
2645
2658
|
if (this.destructuringAssignmentProperties.has(destructuring)) {
|
|
2646
2659
|
const set =
|
|
2647
|
-
/** @type {
|
|
2660
|
+
/** @type {DestructuringAssignmentProperties} */
|
|
2648
2661
|
(this.destructuringAssignmentProperties.get(destructuring));
|
|
2649
2662
|
for (const id of keys) set.add(id);
|
|
2650
2663
|
} else {
|
|
@@ -2829,11 +2842,16 @@ class JavascriptParser extends Parser {
|
|
|
2829
2842
|
* @param {ExportDefaultDeclaration} statement statement
|
|
2830
2843
|
*/
|
|
2831
2844
|
blockPreWalkExportDefaultDeclaration(statement) {
|
|
2832
|
-
|
|
2845
|
+
if (
|
|
2846
|
+
statement.declaration.type === "FunctionDeclaration" ||
|
|
2847
|
+
statement.declaration.type === "ClassDeclaration"
|
|
2848
|
+
) {
|
|
2849
|
+
const prev = this.prevStatement;
|
|
2833
2850
|
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2851
|
+
this.preWalkStatement(statement.declaration);
|
|
2852
|
+
this.prevStatement = prev;
|
|
2853
|
+
this.blockPreWalkStatement(statement.declaration);
|
|
2854
|
+
}
|
|
2837
2855
|
|
|
2838
2856
|
if (
|
|
2839
2857
|
/** @type {MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} */
|
|
@@ -2885,15 +2903,7 @@ class JavascriptParser extends Parser {
|
|
|
2885
2903
|
this.walkExpression(statement.declaration);
|
|
2886
2904
|
}
|
|
2887
2905
|
|
|
2888
|
-
|
|
2889
|
-
this.hooks.exportSpecifier.call(
|
|
2890
|
-
statement,
|
|
2891
|
-
/** @type {TODO} */
|
|
2892
|
-
(statement.declaration),
|
|
2893
|
-
"default",
|
|
2894
|
-
undefined
|
|
2895
|
-
);
|
|
2896
|
-
}
|
|
2906
|
+
this.hooks.exportExpression.call(statement, statement.declaration);
|
|
2897
2907
|
}
|
|
2898
2908
|
}
|
|
2899
2909
|
|
|
@@ -2963,10 +2973,10 @@ class JavascriptParser extends Parser {
|
|
|
2963
2973
|
|
|
2964
2974
|
/**
|
|
2965
2975
|
* @param {ObjectPattern} objectPattern object pattern
|
|
2966
|
-
* @returns {
|
|
2976
|
+
* @returns {DestructuringAssignmentProperties | undefined} set of names or undefined if not all keys are identifiers
|
|
2967
2977
|
*/
|
|
2968
2978
|
_preWalkObjectPattern(objectPattern) {
|
|
2969
|
-
/** @type {
|
|
2979
|
+
/** @type {DestructuringAssignmentProperties} */
|
|
2970
2980
|
const props = new Set();
|
|
2971
2981
|
const properties = objectPattern.properties;
|
|
2972
2982
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -2984,18 +2994,32 @@ class JavascriptParser extends Parser {
|
|
|
2984
2994
|
}
|
|
2985
2995
|
const key = property.key;
|
|
2986
2996
|
if (key.type === "Identifier" && !property.computed) {
|
|
2997
|
+
const pattern =
|
|
2998
|
+
property.value.type === "ObjectPattern"
|
|
2999
|
+
? this._preWalkObjectPattern(property.value)
|
|
3000
|
+
: property.value.type === "ArrayPattern"
|
|
3001
|
+
? this._preWalkArrayPattern(property.value)
|
|
3002
|
+
: undefined;
|
|
2987
3003
|
props.add({
|
|
2988
3004
|
id: key.name,
|
|
2989
|
-
range: key.range,
|
|
3005
|
+
range: /** @type {Range} */ (key.range),
|
|
3006
|
+
pattern,
|
|
2990
3007
|
shorthand: this.scope.inShorthand
|
|
2991
3008
|
});
|
|
2992
3009
|
} else {
|
|
2993
3010
|
const id = this.evaluateExpression(key);
|
|
2994
3011
|
const str = id.asString();
|
|
2995
3012
|
if (str) {
|
|
3013
|
+
const pattern =
|
|
3014
|
+
property.value.type === "ObjectPattern"
|
|
3015
|
+
? this._preWalkObjectPattern(property.value)
|
|
3016
|
+
: property.value.type === "ArrayPattern"
|
|
3017
|
+
? this._preWalkArrayPattern(property.value)
|
|
3018
|
+
: undefined;
|
|
2996
3019
|
props.add({
|
|
2997
3020
|
id: str,
|
|
2998
|
-
range: key.range,
|
|
3021
|
+
range: /** @type {Range} */ (key.range),
|
|
3022
|
+
pattern,
|
|
2999
3023
|
shorthand: this.scope.inShorthand
|
|
3000
3024
|
});
|
|
3001
3025
|
} else {
|
|
@@ -3009,6 +3033,35 @@ class JavascriptParser extends Parser {
|
|
|
3009
3033
|
return props;
|
|
3010
3034
|
}
|
|
3011
3035
|
|
|
3036
|
+
/**
|
|
3037
|
+
* @param {ArrayPattern} arrayPattern array pattern
|
|
3038
|
+
* @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
|
|
3039
|
+
*/
|
|
3040
|
+
_preWalkArrayPattern(arrayPattern) {
|
|
3041
|
+
/** @type {Set<DestructuringAssignmentProperty>} */
|
|
3042
|
+
const props = new Set();
|
|
3043
|
+
const elements = arrayPattern.elements;
|
|
3044
|
+
for (let i = 0; i < elements.length; i++) {
|
|
3045
|
+
const element = elements[i];
|
|
3046
|
+
if (!element) continue;
|
|
3047
|
+
if (element.type === "RestElement") return;
|
|
3048
|
+
const pattern =
|
|
3049
|
+
element.type === "ObjectPattern"
|
|
3050
|
+
? this._preWalkObjectPattern(element)
|
|
3051
|
+
: element.type === "ArrayPattern"
|
|
3052
|
+
? this._preWalkArrayPattern(element)
|
|
3053
|
+
: undefined;
|
|
3054
|
+
props.add({
|
|
3055
|
+
id: `${i}`,
|
|
3056
|
+
range: /** @type {Range} */ (element.range),
|
|
3057
|
+
pattern,
|
|
3058
|
+
shorthand: false
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
return props;
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3012
3065
|
/**
|
|
3013
3066
|
* @param {VariableDeclarator} declarator variable declarator
|
|
3014
3067
|
*/
|
|
@@ -3833,6 +3886,18 @@ class JavascriptParser extends Parser {
|
|
|
3833
3886
|
);
|
|
3834
3887
|
if (result === true) return;
|
|
3835
3888
|
}
|
|
3889
|
+
// import("./m").then(m => { ... })
|
|
3890
|
+
if (
|
|
3891
|
+
expression.callee.object.type === "ImportExpression" &&
|
|
3892
|
+
expression.callee.property.type === "Identifier" &&
|
|
3893
|
+
expression.callee.property.name === "then"
|
|
3894
|
+
) {
|
|
3895
|
+
const result = this.hooks.importCall.call(
|
|
3896
|
+
expression.callee.object,
|
|
3897
|
+
expression
|
|
3898
|
+
);
|
|
3899
|
+
if (result === true) return;
|
|
3900
|
+
}
|
|
3836
3901
|
}
|
|
3837
3902
|
const callee = this.evaluateExpression(expression.callee);
|
|
3838
3903
|
if (callee.isIdentifier()) {
|
|
@@ -3945,7 +4010,7 @@ class JavascriptParser extends Parser {
|
|
|
3945
4010
|
* @param {MemberExpression} expression member expression
|
|
3946
4011
|
* @param {string} name name
|
|
3947
4012
|
* @param {string | VariableInfo} rootInfo root info
|
|
3948
|
-
* @param {
|
|
4013
|
+
* @param {Members} members members
|
|
3949
4014
|
* @param {() => R | undefined} onUnhandled on unhandled callback
|
|
3950
4015
|
*/
|
|
3951
4016
|
walkMemberExpressionWithExpressionName(
|
|
@@ -4027,7 +4092,7 @@ class JavascriptParser extends Parser {
|
|
|
4027
4092
|
* @template R
|
|
4028
4093
|
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
|
|
4029
4094
|
* @param {Expression | Super} expr expression info
|
|
4030
|
-
* @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () =>
|
|
4095
|
+
* @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () => Members) => R) | undefined} fallback callback when variable in not handled by hooks
|
|
4031
4096
|
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
|
|
4032
4097
|
* @param {AsArray<T>} args args for the hook
|
|
4033
4098
|
* @returns {R | undefined} result of hook
|
|
@@ -4098,7 +4163,7 @@ class JavascriptParser extends Parser {
|
|
|
4098
4163
|
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
|
|
4099
4164
|
* @param {ExportedVariableInfo} info variable info
|
|
4100
4165
|
* @param {((name: string) => R | undefined) | undefined} fallback callback when variable in not handled by hooks
|
|
4101
|
-
* @param {((result?: string) =>
|
|
4166
|
+
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
|
|
4102
4167
|
* @param {AsArray<T>} args args for the hook
|
|
4103
4168
|
* @returns {R | undefined} result of hook
|
|
4104
4169
|
*/
|
|
@@ -4286,7 +4351,7 @@ class JavascriptParser extends Parser {
|
|
|
4286
4351
|
}
|
|
4287
4352
|
|
|
4288
4353
|
/**
|
|
4289
|
-
* @param {
|
|
4354
|
+
* @param {(Directive | Statement | ModuleDeclaration)[]} statements statements
|
|
4290
4355
|
*/
|
|
4291
4356
|
detectMode(statements) {
|
|
4292
4357
|
const isLiteral =
|
|
@@ -4606,7 +4671,7 @@ class JavascriptParser extends Parser {
|
|
|
4606
4671
|
terminated: undefined,
|
|
4607
4672
|
definitions: new StackedMap()
|
|
4608
4673
|
};
|
|
4609
|
-
this.state =
|
|
4674
|
+
this.state = state;
|
|
4610
4675
|
this.comments = comments;
|
|
4611
4676
|
this.semicolons = semicolons;
|
|
4612
4677
|
this.statementPath = [];
|
|
@@ -4960,7 +5025,7 @@ class JavascriptParser extends Parser {
|
|
|
4960
5025
|
|
|
4961
5026
|
/**
|
|
4962
5027
|
* @param {string} name variable name
|
|
4963
|
-
* @returns {
|
|
5028
|
+
* @returns {ExportedVariableInfo} info for this variable
|
|
4964
5029
|
*/
|
|
4965
5030
|
getVariableInfo(name) {
|
|
4966
5031
|
const value = this.scope.definitions.get(name);
|
|
@@ -4972,7 +5037,7 @@ class JavascriptParser extends Parser {
|
|
|
4972
5037
|
|
|
4973
5038
|
/**
|
|
4974
5039
|
* @param {string} name variable name
|
|
4975
|
-
* @param {
|
|
5040
|
+
* @param {ExportedVariableInfo} variableInfo new info for this variable
|
|
4976
5041
|
* @returns {void}
|
|
4977
5042
|
*/
|
|
4978
5043
|
setVariable(name, variableInfo) {
|
|
@@ -5053,7 +5118,7 @@ class JavascriptParser extends Parser {
|
|
|
5053
5118
|
|
|
5054
5119
|
/**
|
|
5055
5120
|
* @param {Expression | Super} expression a member expression
|
|
5056
|
-
* @returns {{ members:
|
|
5121
|
+
* @returns {{ members: Members, object: Expression | Super, membersOptionals: MembersOptionals, memberRanges: MemberRanges }} member names (reverse order) and remaining object
|
|
5057
5122
|
*/
|
|
5058
5123
|
extractMemberExpressionChain(expression) {
|
|
5059
5124
|
/** @type {Node} */
|
|
@@ -5119,8 +5184,8 @@ class JavascriptParser extends Parser {
|
|
|
5119
5184
|
return { info, name };
|
|
5120
5185
|
}
|
|
5121
5186
|
|
|
5122
|
-
/** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () =>
|
|
5123
|
-
/** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () =>
|
|
5187
|
+
/** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => CalleeMembers, name: string, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges}} CallExpressionInfo */
|
|
5188
|
+
/** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges}} ExpressionExpressionInfo */
|
|
5124
5189
|
|
|
5125
5190
|
/**
|
|
5126
5191
|
* @param {Expression | Super} expression a member expression
|
|
@@ -5181,7 +5246,7 @@ class JavascriptParser extends Parser {
|
|
|
5181
5246
|
|
|
5182
5247
|
/**
|
|
5183
5248
|
* @param {Expression} expression an expression
|
|
5184
|
-
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () =>
|
|
5249
|
+
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => Members} | undefined} name info
|
|
5185
5250
|
*/
|
|
5186
5251
|
getNameForExpression(expression) {
|
|
5187
5252
|
return this.getMemberExpressionInfo(
|
|
@@ -10,10 +10,10 @@ const ConstDependency = require("../dependencies/ConstDependency");
|
|
|
10
10
|
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("estree").Expression} Expression */
|
|
13
|
-
/** @typedef {import("estree").Node} Node */
|
|
14
13
|
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
|
15
14
|
/** @typedef {import("./JavascriptParser")} JavascriptParser */
|
|
16
15
|
/** @typedef {import("./JavascriptParser").Range} Range */
|
|
16
|
+
/** @typedef {import("./BasicEvaluatedExpression").GetMembers} GetMembers */
|
|
17
17
|
|
|
18
18
|
module.exports.approve = () => true;
|
|
19
19
|
|
|
@@ -31,7 +31,7 @@ module.exports.evaluateToBoolean = (value) =>
|
|
|
31
31
|
/**
|
|
32
32
|
* @param {string} identifier identifier
|
|
33
33
|
* @param {string} rootInfo rootInfo
|
|
34
|
-
* @param {
|
|
34
|
+
* @param {GetMembers} getMembers getMembers
|
|
35
35
|
* @param {boolean | null=} truthy is truthy, null if nullish
|
|
36
36
|
* @returns {(expression: Expression) => BasicEvaluatedExpression} callback
|
|
37
37
|
*/
|
|
@@ -13,14 +13,11 @@ const { getAllChunks } = require("./ChunkHelpers");
|
|
|
13
13
|
/** @typedef {import("../util/Hash")} Hash */
|
|
14
14
|
/** @typedef {import("../Chunk")} Chunk */
|
|
15
15
|
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
|
16
|
-
/** @typedef {import("../Compilation")} Compilation */
|
|
17
16
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
18
17
|
/** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
|
|
19
18
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
20
19
|
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
|
21
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
22
20
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
23
|
-
/** @typedef {(string|number)[]} EntryItem */
|
|
24
21
|
|
|
25
22
|
const EXPORT_PREFIX = `var ${RuntimeGlobals.exports} = `;
|
|
26
23
|
|
|
@@ -137,9 +134,10 @@ module.exports.generateEntryStartup = (
|
|
|
137
134
|
* @param {Chunk} chunk the chunk
|
|
138
135
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
139
136
|
* @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function
|
|
140
|
-
* @returns {Set<
|
|
137
|
+
* @returns {Set<ChunkId>} initially fulfilled chunk ids
|
|
141
138
|
*/
|
|
142
139
|
module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
|
|
140
|
+
/** @type {Set<ChunkId>} */
|
|
143
141
|
const initialChunkIds = new Set(chunk.ids);
|
|
144
142
|
for (const c of chunk.getAllInitialChunks()) {
|
|
145
143
|
if (c === chunk || filterFn(c, chunkGraph)) continue;
|
package/lib/json/JsonData.js
CHANGED
|
@@ -10,7 +10,7 @@ const { register } = require("../util/serialization");
|
|
|
10
10
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
11
11
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
12
12
|
/** @typedef {import("../util/Hash")} Hash */
|
|
13
|
-
/** @typedef {import("
|
|
13
|
+
/** @typedef {import("../util/fs").JsonValue} JsonValue */
|
|
14
14
|
|
|
15
15
|
class JsonData {
|
|
16
16
|
/**
|
|
@@ -20,10 +20,9 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
20
20
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
21
21
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
22
22
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
23
|
-
/** @typedef {import("
|
|
24
|
-
/** @typedef {import("
|
|
25
|
-
/** @typedef {import("
|
|
26
|
-
/** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */
|
|
23
|
+
/** @typedef {import("../util/fs").JsonArray} JsonArray */
|
|
24
|
+
/** @typedef {import("../util/fs").JsonObject} JsonObject */
|
|
25
|
+
/** @typedef {import("../util/fs").JsonValue} JsonValue */
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
28
|
* @param {JsonValue} data Raw JSON data
|
|
@@ -206,7 +205,7 @@ class JsonGenerator extends Generator {
|
|
|
206
205
|
/** @type {string} */
|
|
207
206
|
let content;
|
|
208
207
|
if (concatenationScope) {
|
|
209
|
-
content = `${runtimeTemplate.
|
|
208
|
+
content = `${runtimeTemplate.renderConst()} ${
|
|
210
209
|
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
|
211
210
|
} = ${jsonExpr};`;
|
|
212
211
|
concatenationScope.registerNamespaceExport(
|
|
@@ -11,9 +11,6 @@ const JsonGenerator = require("./JsonGenerator");
|
|
|
11
11
|
const JsonParser = require("./JsonParser");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
|
14
|
-
/** @typedef {import("../util/fs").JsonArray} JsonArray */
|
|
15
|
-
/** @typedef {import("../util/fs").JsonObject} JsonObject */
|
|
16
|
-
/** @typedef {import("../util/fs").JsonValue} JsonValue */
|
|
17
14
|
|
|
18
15
|
const validate = createSchemaValidation(
|
|
19
16
|
require("../../schemas/plugins/json/JsonModulesPluginParser.check"),
|
package/lib/json/JsonParser.js
CHANGED
|
@@ -15,7 +15,9 @@ const JsonData = require("./JsonData");
|
|
|
15
15
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
16
16
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
17
17
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
|
18
|
-
/** @typedef {import("
|
|
18
|
+
/** @typedef {import("../util/fs").JsonValue} JsonValue */
|
|
19
|
+
|
|
20
|
+
/** @typedef {(input: string) => Buffer | JsonValue} ParseFn */
|
|
19
21
|
|
|
20
22
|
const getParseJson = memoize(() => require("json-parse-even-better-errors"));
|
|
21
23
|
|
|
@@ -38,7 +40,7 @@ class JsonParser extends Parser {
|
|
|
38
40
|
source = source.toString("utf8");
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
/** @type {
|
|
43
|
+
/** @type {ParseFn} */
|
|
42
44
|
const parseFn =
|
|
43
45
|
typeof this.options.parse === "function"
|
|
44
46
|
? this.options.parse
|
|
@@ -17,9 +17,9 @@ const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin")
|
|
|
17
17
|
/** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
|
|
18
18
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
19
|
/** @typedef {import("../Module")} Module */
|
|
20
|
+
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
20
21
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
|
|
21
22
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
|
|
22
|
-
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
23
23
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */
|
|
24
24
|
/** @typedef {import("../util/Hash")} Hash */
|
|
25
25
|
|
|
@@ -273,7 +273,7 @@ class AbstractLibraryPlugin {
|
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
275
|
* @param {Chunk} chunk the chunk
|
|
276
|
-
* @param {
|
|
276
|
+
* @param {RuntimeRequirements} set runtime requirements
|
|
277
277
|
* @param {LibraryContext<T>} libraryContext context
|
|
278
278
|
* @returns {void}
|
|
279
279
|
*/
|
|
@@ -15,7 +15,6 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
|
15
15
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
|
|
16
16
|
/** @typedef {import("../Chunk")} Chunk */
|
|
17
17
|
/** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
|
|
18
|
-
/** @typedef {import("../Compiler")} Compiler */
|
|
19
18
|
/** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
|
|
20
19
|
/** @typedef {import("../util/Hash")} Hash */
|
|
21
20
|
/** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
|