webpack 5.101.3 → 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 +6 -5
- 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 +4 -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/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 +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/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 +2 -1
- 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 +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 +119 -54
- 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 +12 -12
- 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 +1129 -530
- package/SECURITY.md +0 -9
|
@@ -13,29 +13,29 @@ const {
|
|
|
13
13
|
const { getTrimmedIdsAndRange } = require("../util/chainedImports");
|
|
14
14
|
const makeSerializable = require("../util/makeSerializable");
|
|
15
15
|
const propertyAccess = require("../util/propertyAccess");
|
|
16
|
+
const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties");
|
|
16
17
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
17
18
|
|
|
18
19
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
19
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
20
|
-
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
|
21
20
|
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
|
22
|
-
/** @typedef {import("../Dependency").
|
|
23
|
-
/** @typedef {import("../Dependency").
|
|
21
|
+
/** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
|
|
22
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
24
23
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
25
24
|
/** @typedef {import("../Module")} Module */
|
|
26
25
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
27
26
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
28
|
-
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
29
27
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
30
28
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
31
|
-
/** @typedef {import("../javascript/JavascriptParser").
|
|
29
|
+
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */
|
|
32
30
|
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
33
31
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
32
|
+
/** @typedef {import("../optimize/InnerGraph").UsedByExports} UsedByExports */
|
|
34
33
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
35
34
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
36
|
-
/** @typedef {import("../util/Hash")} Hash */
|
|
37
35
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
36
|
+
/** @typedef {import("../util/chainedImports").IdRanges} IdRanges */
|
|
38
37
|
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
|
|
38
|
+
/** @typedef {HarmonyImportDependency.Ids} Ids */
|
|
39
39
|
|
|
40
40
|
const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids");
|
|
41
41
|
|
|
@@ -45,12 +45,12 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
45
45
|
/**
|
|
46
46
|
* @param {string} request request
|
|
47
47
|
* @param {number} sourceOrder source order
|
|
48
|
-
* @param {
|
|
48
|
+
* @param {Ids} ids ids
|
|
49
49
|
* @param {string} name name
|
|
50
50
|
* @param {Range} range range
|
|
51
51
|
* @param {ExportPresenceMode} exportPresenceMode export presence mode
|
|
52
52
|
* @param {ImportAttributes | undefined} attributes import attributes
|
|
53
|
-
* @param {
|
|
53
|
+
* @param {IdRanges | undefined} idRanges ranges for members of ids; the two arrays are right-aligned
|
|
54
54
|
* @param {boolean=} defer is defer phase
|
|
55
55
|
*/
|
|
56
56
|
constructor(
|
|
@@ -75,9 +75,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
75
75
|
this.directImport = undefined;
|
|
76
76
|
this.shorthand = undefined;
|
|
77
77
|
this.asiSafe = undefined;
|
|
78
|
-
/** @type {
|
|
78
|
+
/** @type {UsedByExports | undefined} */
|
|
79
79
|
this.usedByExports = undefined;
|
|
80
|
-
/** @type {
|
|
80
|
+
/** @type {DestructuringAssignmentProperties | undefined} */
|
|
81
81
|
this.referencedPropertiesInDestructuring = undefined;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -102,7 +102,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
105
|
-
* @returns {
|
|
105
|
+
* @returns {Ids} the imported ids
|
|
106
106
|
*/
|
|
107
107
|
getIds(moduleGraph) {
|
|
108
108
|
const meta = moduleGraph.getMetaIfExisting(this);
|
|
@@ -113,7 +113,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
116
|
-
* @param {
|
|
116
|
+
* @param {Ids} ids the imported ids
|
|
117
117
|
* @returns {void}
|
|
118
118
|
*/
|
|
119
119
|
setIds(moduleGraph, ids) {
|
|
@@ -144,7 +144,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
144
144
|
* Returns list of exports referenced by this dependency
|
|
145
145
|
* @param {ModuleGraph} moduleGraph module graph
|
|
146
146
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
147
|
-
* @returns {
|
|
147
|
+
* @returns {ReferencedExports} referenced exports
|
|
148
148
|
*/
|
|
149
149
|
getReferencedExports(moduleGraph, runtime) {
|
|
150
150
|
let ids = this.getIds(moduleGraph);
|
|
@@ -190,15 +190,21 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
|
-
* @param {
|
|
194
|
-
* @returns {
|
|
193
|
+
* @param {Ids=} ids ids
|
|
194
|
+
* @returns {RawReferencedExports} referenced exports
|
|
195
195
|
*/
|
|
196
196
|
_getReferencedExportsInDestructuring(ids) {
|
|
197
197
|
if (this.referencedPropertiesInDestructuring) {
|
|
198
|
-
/** @type {
|
|
198
|
+
/** @type {RawReferencedExports} */
|
|
199
|
+
const refsInDestructuring = [];
|
|
200
|
+
traverseDestructuringAssignmentProperties(
|
|
201
|
+
this.referencedPropertiesInDestructuring,
|
|
202
|
+
(stack) => refsInDestructuring.push(stack.map((p) => p.id))
|
|
203
|
+
);
|
|
204
|
+
/** @type {RawReferencedExports} */
|
|
199
205
|
const refs = [];
|
|
200
|
-
for (const
|
|
201
|
-
refs.push(ids ? [...ids,
|
|
206
|
+
for (const idsInDestructuring of refsInDestructuring) {
|
|
207
|
+
refs.push(ids ? [...ids, ...idsInDestructuring] : idsInDestructuring);
|
|
202
208
|
}
|
|
203
209
|
return refs;
|
|
204
210
|
}
|
|
@@ -375,13 +381,23 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
|
375
381
|
}
|
|
376
382
|
}
|
|
377
383
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
384
|
+
/** @type {{ ids: Ids, range: Range, shorthand: boolean | string }[]} */
|
|
385
|
+
const replacementsInDestructuring = [];
|
|
386
|
+
traverseDestructuringAssignmentProperties(
|
|
387
|
+
dep.referencedPropertiesInDestructuring,
|
|
388
|
+
undefined,
|
|
389
|
+
(stack) => {
|
|
390
|
+
const property = stack[stack.length - 1];
|
|
391
|
+
replacementsInDestructuring.push({
|
|
392
|
+
ids: stack.map((p) => p.id),
|
|
393
|
+
range: property.range,
|
|
394
|
+
shorthand: property.shorthand
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
for (const { ids, shorthand, range } of replacementsInDestructuring) {
|
|
399
|
+
/** @type {Ids} */
|
|
400
|
+
const concatedIds = [...prefixedIds, ...ids];
|
|
385
401
|
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
|
|
386
402
|
const used = moduleGraph
|
|
387
403
|
.getExportsInfo(module)
|
|
@@ -394,10 +410,8 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
|
394
410
|
const comment = `${Template.toNormalComment(name)} `;
|
|
395
411
|
const key = comment + JSON.stringify(newName);
|
|
396
412
|
source.replace(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
/** @type {Range} */
|
|
400
|
-
(range)[1] - 1,
|
|
413
|
+
range[0],
|
|
414
|
+
range[1] - 1,
|
|
401
415
|
shorthand ? `${key}: ${name}` : `${key}`
|
|
402
416
|
);
|
|
403
417
|
}
|
|
@@ -408,7 +422,7 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
|
408
422
|
* @param {HarmonyImportSpecifierDependency} dep dependency
|
|
409
423
|
* @param {ReplaceSource} source source
|
|
410
424
|
* @param {DependencyTemplateContext} templateContext context
|
|
411
|
-
* @param {
|
|
425
|
+
* @param {Ids} ids ids
|
|
412
426
|
* @returns {string} generated code
|
|
413
427
|
*/
|
|
414
428
|
_getCodeForIds(dep, source, templateContext, ids) {
|
|
@@ -476,3 +490,4 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
|
476
490
|
};
|
|
477
491
|
|
|
478
492
|
module.exports = HarmonyImportSpecifierDependency;
|
|
493
|
+
module.exports.idsSymbol = idsSymbol;
|
|
@@ -28,9 +28,9 @@ const HarmonyTopLevelThisParserPlugin = require("./HarmonyTopLevelThisParserPlug
|
|
|
28
28
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
29
29
|
/** @typedef {import("../Compiler")} Compiler */
|
|
30
30
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
31
|
+
|
|
31
32
|
/**
|
|
32
|
-
* @typedef HarmonyModulesPluginOptions
|
|
33
|
-
* @property {boolean=} topLevelAwait
|
|
33
|
+
* @typedef {object} HarmonyModulesPluginOptions
|
|
34
34
|
* @property {boolean=} deferImport
|
|
35
35
|
*/
|
|
36
36
|
|
|
@@ -134,7 +134,7 @@ class HarmonyModulesPlugin {
|
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
new HarmonyDetectionParserPlugin(
|
|
137
|
+
new HarmonyDetectionParserPlugin().apply(parser);
|
|
138
138
|
new HarmonyImportDependencyParserPlugin(parserOptions).apply(parser);
|
|
139
139
|
new HarmonyExportDependencyParserPlugin(parserOptions).apply(parser);
|
|
140
140
|
new HarmonyTopLevelThisParserPlugin().apply(parser);
|
|
@@ -11,7 +11,8 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
13
13
|
/** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
14
|
-
/** @typedef {import("../Dependency").
|
|
14
|
+
/** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
|
|
15
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
15
16
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
16
17
|
/** @typedef {import("../Module")} Module */
|
|
17
18
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
@@ -26,14 +27,14 @@ class ImportDependency extends ModuleDependency {
|
|
|
26
27
|
/**
|
|
27
28
|
* @param {string} request the request
|
|
28
29
|
* @param {Range} range expression range
|
|
29
|
-
* @param {
|
|
30
|
+
* @param {RawReferencedExports | null=} referencedExports list of referenced exports
|
|
30
31
|
* @param {ImportAttributes=} attributes import attributes
|
|
31
32
|
*/
|
|
32
33
|
constructor(request, range, referencedExports, attributes) {
|
|
33
34
|
super(request);
|
|
34
35
|
this.range = range;
|
|
35
36
|
this.referencedExports = referencedExports;
|
|
36
|
-
this.
|
|
37
|
+
this.attributes = attributes;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
get type() {
|
|
@@ -44,11 +45,22 @@ class ImportDependency extends ModuleDependency {
|
|
|
44
45
|
return "esm";
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @returns {string | null} an identifier to merge equal requests
|
|
50
|
+
*/
|
|
51
|
+
getResourceIdentifier() {
|
|
52
|
+
let str = super.getResourceIdentifier();
|
|
53
|
+
if (this.attributes !== undefined) {
|
|
54
|
+
str += JSON.stringify(this.attributes);
|
|
55
|
+
}
|
|
56
|
+
return str;
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
/**
|
|
48
60
|
* Returns list of exports referenced by this dependency
|
|
49
61
|
* @param {ModuleGraph} moduleGraph module graph
|
|
50
62
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
51
|
-
* @returns {
|
|
63
|
+
* @returns {ReferencedExports} referenced exports
|
|
52
64
|
*/
|
|
53
65
|
getReferencedExports(moduleGraph, runtime) {
|
|
54
66
|
if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
@@ -87,7 +99,7 @@ class ImportDependency extends ModuleDependency {
|
|
|
87
99
|
serialize(context) {
|
|
88
100
|
context.write(this.range);
|
|
89
101
|
context.write(this.referencedExports);
|
|
90
|
-
context.write(this.
|
|
102
|
+
context.write(this.attributes);
|
|
91
103
|
super.serialize(context);
|
|
92
104
|
}
|
|
93
105
|
|
|
@@ -97,7 +109,7 @@ class ImportDependency extends ModuleDependency {
|
|
|
97
109
|
deserialize(context) {
|
|
98
110
|
this.range = context.read();
|
|
99
111
|
this.referencedExports = context.read();
|
|
100
|
-
this.
|
|
112
|
+
this.attributes = context.read();
|
|
101
113
|
super.deserialize(context);
|
|
102
114
|
}
|
|
103
115
|
}
|
|
@@ -10,19 +10,18 @@ const ImportDependency = require("./ImportDependency");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
12
12
|
/** @typedef {import("../Dependency")} Dependency */
|
|
13
|
-
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
|
14
13
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
15
14
|
/** @typedef {import("../Module")} Module */
|
|
16
15
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
17
|
-
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
18
16
|
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
19
17
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
18
|
+
/** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */
|
|
20
19
|
|
|
21
20
|
class ImportEagerDependency extends ImportDependency {
|
|
22
21
|
/**
|
|
23
22
|
* @param {string} request the request
|
|
24
23
|
* @param {Range} range expression range
|
|
25
|
-
* @param {
|
|
24
|
+
* @param {RawReferencedExports | null=} referencedExports list of referenced exports
|
|
26
25
|
* @param {ImportAttributes=} attributes import attributes
|
|
27
26
|
*/
|
|
28
27
|
constructor(request, range, referencedExports, attributes) {
|
|
@@ -15,14 +15,17 @@ const ImportMetaContextDependency = require("./ImportMetaContextDependency");
|
|
|
15
15
|
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
|
16
16
|
/** @typedef {import("estree").Property} Property */
|
|
17
17
|
/** @typedef {import("estree").Identifier} Identifier */
|
|
18
|
-
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
|
19
18
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
20
19
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
21
20
|
/** @typedef {import("../ContextModule").ContextModuleOptions} ContextModuleOptions */
|
|
21
|
+
/** @typedef {import("../ContextModule").ContextMode} ContextMode */
|
|
22
|
+
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
|
22
23
|
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
|
|
24
|
+
/** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
|
|
23
25
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
24
26
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
25
|
-
|
|
27
|
+
|
|
28
|
+
/** @typedef {Pick<ContextModuleOptions, 'mode' | 'recursive' | 'regExp' | 'include' | 'exclude' | 'chunkName'> & { groupOptions: RawChunkGroupOptions, exports?: RawReferencedExports }} ImportMetaContextOptions */
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* @param {Property} prop property
|
|
@@ -84,7 +87,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
|
84
87
|
const errors = [];
|
|
85
88
|
let regExp = /^\.\/.*$/;
|
|
86
89
|
let recursive = true;
|
|
87
|
-
/** @type {
|
|
90
|
+
/** @type {ContextMode} */
|
|
88
91
|
let mode = "sync";
|
|
89
92
|
/** @type {ContextModuleOptions["include"]} */
|
|
90
93
|
let include;
|
|
@@ -92,9 +95,9 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
|
92
95
|
let exclude;
|
|
93
96
|
/** @type {RawChunkGroupOptions} */
|
|
94
97
|
const groupOptions = {};
|
|
95
|
-
/** @type {
|
|
98
|
+
/** @type {ChunkName | undefined} */
|
|
96
99
|
let chunkName;
|
|
97
|
-
/** @type {
|
|
100
|
+
/** @type {RawReferencedExports | undefined} */
|
|
98
101
|
let exports;
|
|
99
102
|
if (optionsNode) {
|
|
100
103
|
for (const prop of /** @type {ObjectExpression} */ (optionsNode)
|
|
@@ -14,7 +14,6 @@ const ImportMetaContextDependency = require("./ImportMetaContextDependency");
|
|
|
14
14
|
const ImportMetaContextDependencyParserPlugin = require("./ImportMetaContextDependencyParserPlugin");
|
|
15
15
|
|
|
16
16
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
17
|
-
/** @typedef {import("../../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
|
18
17
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
18
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
20
19
|
|
|
@@ -30,6 +30,7 @@ const ConstDependency = require("./ConstDependency");
|
|
|
30
30
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
31
31
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
32
32
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
33
|
+
/** @typedef {import("../javascript/JavascriptParser").Members} Members */
|
|
33
34
|
|
|
34
35
|
const getCriticalDependencyWarning = memoize(() =>
|
|
35
36
|
require("./CriticalDependencyWarning")
|
|
@@ -83,7 +84,7 @@ class ImportMetaPlugin {
|
|
|
83
84
|
JSON.stringify(getUrl(parser.state.module));
|
|
84
85
|
const importMetaWebpackVersion = () => JSON.stringify(webpackVersion);
|
|
85
86
|
/**
|
|
86
|
-
* @param {
|
|
87
|
+
* @param {Members} members members
|
|
87
88
|
* @returns {string} error message
|
|
88
89
|
*/
|
|
89
90
|
const importMetaUnknownProperty = (members) =>
|