webpack 5.101.2 → 5.102.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/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 +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +18 -10
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +18 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- 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 +96 -78
- 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 +41 -24
- 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 +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- 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 +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- 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 +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- 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/async-modules/AwaitDependenciesInitFragment.js +4 -1
- 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/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- 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 +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- 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 +3 -4
- 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 +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +38 -24
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- 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 +8 -1
- package/lib/dependencies/ImportParserPlugin.js +294 -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 +3 -9
- 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/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 +44 -21
- package/lib/javascript/JavascriptParser.js +159 -93
- 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 +0 -1
- 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/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/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- 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 +178 -94
- 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/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 +0 -1
- 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/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 -1
- 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 -4
- 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 +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- 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/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1140 -505
- package/SECURITY.md +0 -9
|
@@ -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").BaseNode & { type: "ImportAttribute", key: Identifier | Literal, value: Literal }} ImportAttribute */
|
|
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
109
|
/** @typedef {import("estree").ImportExpression & { options?: Expression | null, phase?: "defer" }} ImportExpression */
|
|
110
|
-
/** @typedef {ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration} ModuleDeclaration */
|
|
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
|
|
@@ -522,26 +535,30 @@ class JavascriptParser extends Parser {
|
|
|
522
535
|
varDeclarationVar: new HookMap(() => new SyncBailHook(["declaration"])),
|
|
523
536
|
/** @type {HookMap<SyncBailHook<[Identifier], boolean | void>>} */
|
|
524
537
|
pattern: new HookMap(() => new SyncBailHook(["pattern"])),
|
|
538
|
+
/** @type {SyncBailHook<[Expression], boolean | void>} */
|
|
539
|
+
collectDestructuringAssignmentProperties: new SyncBailHook([
|
|
540
|
+
"expression"
|
|
541
|
+
]),
|
|
525
542
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
526
543
|
canRename: new HookMap(() => new SyncBailHook(["initExpression"])),
|
|
527
544
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
528
545
|
rename: new HookMap(() => new SyncBailHook(["initExpression"])),
|
|
529
546
|
/** @type {HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>} */
|
|
530
547
|
assign: new HookMap(() => new SyncBailHook(["expression"])),
|
|
531
|
-
/** @type {HookMap<SyncBailHook<[AssignmentExpression,
|
|
548
|
+
/** @type {HookMap<SyncBailHook<[AssignmentExpression, Members], boolean | void>>} */
|
|
532
549
|
assignMemberChain: new HookMap(
|
|
533
550
|
() => new SyncBailHook(["expression", "members"])
|
|
534
551
|
),
|
|
535
552
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
536
553
|
typeof: new HookMap(() => new SyncBailHook(["expression"])),
|
|
537
|
-
/** @type {SyncBailHook<[ImportExpression], boolean | void>} */
|
|
538
|
-
importCall: new SyncBailHook(["expression"]),
|
|
554
|
+
/** @type {SyncBailHook<[ImportExpression, CallExpression?], boolean | void>} */
|
|
555
|
+
importCall: new SyncBailHook(["expression", "importThen"]),
|
|
539
556
|
/** @type {SyncBailHook<[Expression | ForOfStatement], boolean | void>} */
|
|
540
557
|
topLevelAwait: new SyncBailHook(["expression"]),
|
|
541
558
|
/** @type {HookMap<SyncBailHook<[CallExpression], boolean | void>>} */
|
|
542
559
|
call: new HookMap(() => new SyncBailHook(["expression"])),
|
|
543
560
|
/** Something like "a.b()" */
|
|
544
|
-
/** @type {HookMap<SyncBailHook<[CallExpression,
|
|
561
|
+
/** @type {HookMap<SyncBailHook<[CallExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
|
|
545
562
|
callMemberChain: new HookMap(
|
|
546
563
|
() =>
|
|
547
564
|
new SyncBailHook([
|
|
@@ -552,7 +569,7 @@ class JavascriptParser extends Parser {
|
|
|
552
569
|
])
|
|
553
570
|
),
|
|
554
571
|
/** Something like "a.b().c.d" */
|
|
555
|
-
/** @type {HookMap<SyncBailHook<[Expression,
|
|
572
|
+
/** @type {HookMap<SyncBailHook<[Expression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
|
|
556
573
|
memberChainOfCallMemberChain: new HookMap(
|
|
557
574
|
() =>
|
|
558
575
|
new SyncBailHook([
|
|
@@ -564,7 +581,7 @@ class JavascriptParser extends Parser {
|
|
|
564
581
|
])
|
|
565
582
|
),
|
|
566
583
|
/** Something like "a.b().c.d()"" */
|
|
567
|
-
/** @type {HookMap<SyncBailHook<[CallExpression,
|
|
584
|
+
/** @type {HookMap<SyncBailHook<[CallExpression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
|
|
568
585
|
callMemberChainOfCallMemberChain: new HookMap(
|
|
569
586
|
() =>
|
|
570
587
|
new SyncBailHook([
|
|
@@ -583,7 +600,7 @@ class JavascriptParser extends Parser {
|
|
|
583
600
|
binaryExpression: new SyncBailHook(["binaryExpression"]),
|
|
584
601
|
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
|
|
585
602
|
expression: new HookMap(() => new SyncBailHook(["expression"])),
|
|
586
|
-
/** @type {HookMap<SyncBailHook<[MemberExpression,
|
|
603
|
+
/** @type {HookMap<SyncBailHook<[MemberExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
|
|
587
604
|
expressionMemberChain: new HookMap(
|
|
588
605
|
() =>
|
|
589
606
|
new SyncBailHook([
|
|
@@ -593,7 +610,7 @@ class JavascriptParser extends Parser {
|
|
|
593
610
|
"memberRanges"
|
|
594
611
|
])
|
|
595
612
|
),
|
|
596
|
-
/** @type {HookMap<SyncBailHook<[MemberExpression,
|
|
613
|
+
/** @type {HookMap<SyncBailHook<[MemberExpression, Members], boolean | void>>} */
|
|
597
614
|
unhandledExpressionMemberChain: new HookMap(
|
|
598
615
|
() => new SyncBailHook(["expression", "members"])
|
|
599
616
|
),
|
|
@@ -612,9 +629,9 @@ class JavascriptParser extends Parser {
|
|
|
612
629
|
});
|
|
613
630
|
this.sourceType = sourceType;
|
|
614
631
|
/** @type {ScopeInfo} */
|
|
615
|
-
this.scope = /** @type {
|
|
632
|
+
this.scope = /** @type {EXPECTED_ANY} */ (undefined);
|
|
616
633
|
/** @type {ParserState} */
|
|
617
|
-
this.state = /** @type {
|
|
634
|
+
this.state = /** @type {EXPECTED_ANY} */ (undefined);
|
|
618
635
|
/** @type {Comment[] | undefined} */
|
|
619
636
|
this.comments = undefined;
|
|
620
637
|
/** @type {Set<number> | undefined} */
|
|
@@ -623,7 +640,7 @@ class JavascriptParser extends Parser {
|
|
|
623
640
|
this.statementPath = undefined;
|
|
624
641
|
/** @type {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | undefined} */
|
|
625
642
|
this.prevStatement = undefined;
|
|
626
|
-
/** @type {WeakMap<Expression,
|
|
643
|
+
/** @type {WeakMap<Expression, DestructuringAssignmentProperties> | undefined} */
|
|
627
644
|
this.destructuringAssignmentProperties = undefined;
|
|
628
645
|
/** @type {TagData | undefined} */
|
|
629
646
|
this.currentTagData = undefined;
|
|
@@ -1887,7 +1904,7 @@ class JavascriptParser extends Parser {
|
|
|
1887
1904
|
|
|
1888
1905
|
/**
|
|
1889
1906
|
* @param {Expression} node node
|
|
1890
|
-
* @returns {
|
|
1907
|
+
* @returns {DestructuringAssignmentProperties | undefined} destructured identifiers
|
|
1891
1908
|
*/
|
|
1892
1909
|
destructuringAssignmentPropertiesFor(node) {
|
|
1893
1910
|
if (!this.destructuringAssignmentProperties) return;
|
|
@@ -2607,34 +2624,48 @@ class JavascriptParser extends Parser {
|
|
|
2607
2624
|
* @param {AssignmentExpression} expression assignment expression
|
|
2608
2625
|
*/
|
|
2609
2626
|
preWalkAssignmentExpression(expression) {
|
|
2627
|
+
this.enterDestructuringAssignment(expression.left, expression.right);
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
/**
|
|
2631
|
+
* @param {Pattern} pattern pattern
|
|
2632
|
+
* @param {Expression} expression assignment expression
|
|
2633
|
+
* @returns {Expression | undefined} destructuring expression
|
|
2634
|
+
*/
|
|
2635
|
+
enterDestructuringAssignment(pattern, expression) {
|
|
2610
2636
|
if (
|
|
2611
|
-
|
|
2637
|
+
pattern.type !== "ObjectPattern" ||
|
|
2612
2638
|
!this.destructuringAssignmentProperties
|
|
2613
2639
|
) {
|
|
2614
2640
|
return;
|
|
2615
2641
|
}
|
|
2616
|
-
const keys = this._preWalkObjectPattern(expression.left);
|
|
2617
|
-
if (!keys) return;
|
|
2618
|
-
|
|
2619
|
-
// check multiple assignments
|
|
2620
|
-
if (this.destructuringAssignmentProperties.has(expression)) {
|
|
2621
|
-
const set =
|
|
2622
|
-
/** @type {Set<DestructuringAssignmentProperty>} */
|
|
2623
|
-
(this.destructuringAssignmentProperties.get(expression));
|
|
2624
|
-
this.destructuringAssignmentProperties.delete(expression);
|
|
2625
|
-
for (const id of set) keys.add(id);
|
|
2626
|
-
}
|
|
2627
2642
|
|
|
2628
|
-
|
|
2629
|
-
expression.
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2643
|
+
const expr =
|
|
2644
|
+
expression.type === "AwaitExpression" ? expression.argument : expression;
|
|
2645
|
+
|
|
2646
|
+
const destructuring =
|
|
2647
|
+
expr.type === "AssignmentExpression"
|
|
2648
|
+
? this.enterDestructuringAssignment(expr.left, expr.right)
|
|
2649
|
+
: this.hooks.collectDestructuringAssignmentProperties.call(expr)
|
|
2650
|
+
? expr
|
|
2651
|
+
: undefined;
|
|
2652
|
+
|
|
2653
|
+
if (destructuring) {
|
|
2654
|
+
const keys = this._preWalkObjectPattern(pattern);
|
|
2655
|
+
if (!keys) return;
|
|
2634
2656
|
|
|
2635
|
-
|
|
2636
|
-
this.
|
|
2657
|
+
// check multiple assignments
|
|
2658
|
+
if (this.destructuringAssignmentProperties.has(destructuring)) {
|
|
2659
|
+
const set =
|
|
2660
|
+
/** @type {DestructuringAssignmentProperties} */
|
|
2661
|
+
(this.destructuringAssignmentProperties.get(destructuring));
|
|
2662
|
+
for (const id of keys) set.add(id);
|
|
2663
|
+
} else {
|
|
2664
|
+
this.destructuringAssignmentProperties.set(destructuring, keys);
|
|
2665
|
+
}
|
|
2637
2666
|
}
|
|
2667
|
+
|
|
2668
|
+
return destructuring;
|
|
2638
2669
|
}
|
|
2639
2670
|
|
|
2640
2671
|
/**
|
|
@@ -2811,11 +2842,16 @@ class JavascriptParser extends Parser {
|
|
|
2811
2842
|
* @param {ExportDefaultDeclaration} statement statement
|
|
2812
2843
|
*/
|
|
2813
2844
|
blockPreWalkExportDefaultDeclaration(statement) {
|
|
2814
|
-
|
|
2845
|
+
if (
|
|
2846
|
+
statement.declaration.type === "FunctionDeclaration" ||
|
|
2847
|
+
statement.declaration.type === "ClassDeclaration"
|
|
2848
|
+
) {
|
|
2849
|
+
const prev = this.prevStatement;
|
|
2815
2850
|
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2851
|
+
this.preWalkStatement(statement.declaration);
|
|
2852
|
+
this.prevStatement = prev;
|
|
2853
|
+
this.blockPreWalkStatement(statement.declaration);
|
|
2854
|
+
}
|
|
2819
2855
|
|
|
2820
2856
|
if (
|
|
2821
2857
|
/** @type {MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} */
|
|
@@ -2867,15 +2903,7 @@ class JavascriptParser extends Parser {
|
|
|
2867
2903
|
this.walkExpression(statement.declaration);
|
|
2868
2904
|
}
|
|
2869
2905
|
|
|
2870
|
-
|
|
2871
|
-
this.hooks.exportSpecifier.call(
|
|
2872
|
-
statement,
|
|
2873
|
-
/** @type {TODO} */
|
|
2874
|
-
(statement.declaration),
|
|
2875
|
-
"default",
|
|
2876
|
-
undefined
|
|
2877
|
-
);
|
|
2878
|
-
}
|
|
2906
|
+
this.hooks.exportExpression.call(statement, statement.declaration);
|
|
2879
2907
|
}
|
|
2880
2908
|
}
|
|
2881
2909
|
|
|
@@ -2945,10 +2973,10 @@ class JavascriptParser extends Parser {
|
|
|
2945
2973
|
|
|
2946
2974
|
/**
|
|
2947
2975
|
* @param {ObjectPattern} objectPattern object pattern
|
|
2948
|
-
* @returns {
|
|
2976
|
+
* @returns {DestructuringAssignmentProperties | undefined} set of names or undefined if not all keys are identifiers
|
|
2949
2977
|
*/
|
|
2950
2978
|
_preWalkObjectPattern(objectPattern) {
|
|
2951
|
-
/** @type {
|
|
2979
|
+
/** @type {DestructuringAssignmentProperties} */
|
|
2952
2980
|
const props = new Set();
|
|
2953
2981
|
const properties = objectPattern.properties;
|
|
2954
2982
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -2966,18 +2994,32 @@ class JavascriptParser extends Parser {
|
|
|
2966
2994
|
}
|
|
2967
2995
|
const key = property.key;
|
|
2968
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;
|
|
2969
3003
|
props.add({
|
|
2970
3004
|
id: key.name,
|
|
2971
|
-
range: key.range,
|
|
3005
|
+
range: /** @type {Range} */ (key.range),
|
|
3006
|
+
pattern,
|
|
2972
3007
|
shorthand: this.scope.inShorthand
|
|
2973
3008
|
});
|
|
2974
3009
|
} else {
|
|
2975
3010
|
const id = this.evaluateExpression(key);
|
|
2976
3011
|
const str = id.asString();
|
|
2977
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;
|
|
2978
3019
|
props.add({
|
|
2979
3020
|
id: str,
|
|
2980
|
-
range: key.range,
|
|
3021
|
+
range: /** @type {Range} */ (key.range),
|
|
3022
|
+
pattern,
|
|
2981
3023
|
shorthand: this.scope.inShorthand
|
|
2982
3024
|
});
|
|
2983
3025
|
} else {
|
|
@@ -2992,28 +3034,40 @@ class JavascriptParser extends Parser {
|
|
|
2992
3034
|
}
|
|
2993
3035
|
|
|
2994
3036
|
/**
|
|
2995
|
-
* @param {
|
|
3037
|
+
* @param {ArrayPattern} arrayPattern array pattern
|
|
3038
|
+
* @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
|
|
2996
3039
|
*/
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
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
|
+
});
|
|
3004
3060
|
}
|
|
3005
|
-
const keys = this._preWalkObjectPattern(declarator.id);
|
|
3006
|
-
|
|
3007
|
-
if (!keys) return;
|
|
3008
|
-
this.destructuringAssignmentProperties.set(
|
|
3009
|
-
declarator.init.type === "AwaitExpression"
|
|
3010
|
-
? declarator.init.argument
|
|
3011
|
-
: declarator.init,
|
|
3012
|
-
keys
|
|
3013
|
-
);
|
|
3014
3061
|
|
|
3015
|
-
|
|
3016
|
-
|
|
3062
|
+
return props;
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
/**
|
|
3066
|
+
* @param {VariableDeclarator} declarator variable declarator
|
|
3067
|
+
*/
|
|
3068
|
+
preWalkVariableDeclarator(declarator) {
|
|
3069
|
+
if (declarator.init) {
|
|
3070
|
+
this.enterDestructuringAssignment(declarator.id, declarator.init);
|
|
3017
3071
|
}
|
|
3018
3072
|
}
|
|
3019
3073
|
|
|
@@ -3832,6 +3886,18 @@ class JavascriptParser extends Parser {
|
|
|
3832
3886
|
);
|
|
3833
3887
|
if (result === true) return;
|
|
3834
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
|
+
}
|
|
3835
3901
|
}
|
|
3836
3902
|
const callee = this.evaluateExpression(expression.callee);
|
|
3837
3903
|
if (callee.isIdentifier()) {
|
|
@@ -3944,7 +4010,7 @@ class JavascriptParser extends Parser {
|
|
|
3944
4010
|
* @param {MemberExpression} expression member expression
|
|
3945
4011
|
* @param {string} name name
|
|
3946
4012
|
* @param {string | VariableInfo} rootInfo root info
|
|
3947
|
-
* @param {
|
|
4013
|
+
* @param {Members} members members
|
|
3948
4014
|
* @param {() => R | undefined} onUnhandled on unhandled callback
|
|
3949
4015
|
*/
|
|
3950
4016
|
walkMemberExpressionWithExpressionName(
|
|
@@ -4026,7 +4092,7 @@ class JavascriptParser extends Parser {
|
|
|
4026
4092
|
* @template R
|
|
4027
4093
|
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
|
|
4028
4094
|
* @param {Expression | Super} expr expression info
|
|
4029
|
-
* @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
|
|
4030
4096
|
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
|
|
4031
4097
|
* @param {AsArray<T>} args args for the hook
|
|
4032
4098
|
* @returns {R | undefined} result of hook
|
|
@@ -4097,7 +4163,7 @@ class JavascriptParser extends Parser {
|
|
|
4097
4163
|
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
|
|
4098
4164
|
* @param {ExportedVariableInfo} info variable info
|
|
4099
4165
|
* @param {((name: string) => R | undefined) | undefined} fallback callback when variable in not handled by hooks
|
|
4100
|
-
* @param {((result?: string) =>
|
|
4166
|
+
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
|
|
4101
4167
|
* @param {AsArray<T>} args args for the hook
|
|
4102
4168
|
* @returns {R | undefined} result of hook
|
|
4103
4169
|
*/
|
|
@@ -4285,7 +4351,7 @@ class JavascriptParser extends Parser {
|
|
|
4285
4351
|
}
|
|
4286
4352
|
|
|
4287
4353
|
/**
|
|
4288
|
-
* @param {
|
|
4354
|
+
* @param {(Directive | Statement | ModuleDeclaration)[]} statements statements
|
|
4289
4355
|
*/
|
|
4290
4356
|
detectMode(statements) {
|
|
4291
4357
|
const isLiteral =
|
|
@@ -4605,7 +4671,7 @@ class JavascriptParser extends Parser {
|
|
|
4605
4671
|
terminated: undefined,
|
|
4606
4672
|
definitions: new StackedMap()
|
|
4607
4673
|
};
|
|
4608
|
-
this.state =
|
|
4674
|
+
this.state = state;
|
|
4609
4675
|
this.comments = comments;
|
|
4610
4676
|
this.semicolons = semicolons;
|
|
4611
4677
|
this.statementPath = [];
|
|
@@ -4959,7 +5025,7 @@ class JavascriptParser extends Parser {
|
|
|
4959
5025
|
|
|
4960
5026
|
/**
|
|
4961
5027
|
* @param {string} name variable name
|
|
4962
|
-
* @returns {
|
|
5028
|
+
* @returns {ExportedVariableInfo} info for this variable
|
|
4963
5029
|
*/
|
|
4964
5030
|
getVariableInfo(name) {
|
|
4965
5031
|
const value = this.scope.definitions.get(name);
|
|
@@ -4971,7 +5037,7 @@ class JavascriptParser extends Parser {
|
|
|
4971
5037
|
|
|
4972
5038
|
/**
|
|
4973
5039
|
* @param {string} name variable name
|
|
4974
|
-
* @param {
|
|
5040
|
+
* @param {ExportedVariableInfo} variableInfo new info for this variable
|
|
4975
5041
|
* @returns {void}
|
|
4976
5042
|
*/
|
|
4977
5043
|
setVariable(name, variableInfo) {
|
|
@@ -5052,7 +5118,7 @@ class JavascriptParser extends Parser {
|
|
|
5052
5118
|
|
|
5053
5119
|
/**
|
|
5054
5120
|
* @param {Expression | Super} expression a member expression
|
|
5055
|
-
* @returns {{ members:
|
|
5121
|
+
* @returns {{ members: Members, object: Expression | Super, membersOptionals: MembersOptionals, memberRanges: MemberRanges }} member names (reverse order) and remaining object
|
|
5056
5122
|
*/
|
|
5057
5123
|
extractMemberExpressionChain(expression) {
|
|
5058
5124
|
/** @type {Node} */
|
|
@@ -5118,8 +5184,8 @@ class JavascriptParser extends Parser {
|
|
|
5118
5184
|
return { info, name };
|
|
5119
5185
|
}
|
|
5120
5186
|
|
|
5121
|
-
/** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () =>
|
|
5122
|
-
/** @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 */
|
|
5123
5189
|
|
|
5124
5190
|
/**
|
|
5125
5191
|
* @param {Expression | Super} expression a member expression
|
|
@@ -5179,8 +5245,8 @@ class JavascriptParser extends Parser {
|
|
|
5179
5245
|
}
|
|
5180
5246
|
|
|
5181
5247
|
/**
|
|
5182
|
-
* @param {
|
|
5183
|
-
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () =>
|
|
5248
|
+
* @param {Expression} expression an expression
|
|
5249
|
+
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => Members} | undefined} name info
|
|
5184
5250
|
*/
|
|
5185
5251
|
getNameForExpression(expression) {
|
|
5186
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
|