webpack 5.104.1 → 5.105.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/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +13 -1
- package/lib/AsyncDependencyToInitialChunkError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +2 -0
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +8 -4
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +2 -0
- package/lib/CleanPlugin.js +4 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +280 -236
- package/lib/Compiler.js +3 -2
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +3 -3
- package/lib/ContextModule.js +248 -111
- package/lib/ContextModuleFactory.js +14 -2
- package/lib/DefinePlugin.js +3 -1
- package/lib/DelegatedModule.js +6 -0
- package/lib/DelegatedModuleFactoryPlugin.js +2 -0
- package/lib/Dependency.js +6 -1
- package/lib/DependencyTemplates.js +3 -2
- package/lib/DllModule.js +2 -0
- package/lib/DllReferencePlugin.js +1 -0
- package/lib/DotenvPlugin.js +11 -5
- package/lib/DynamicEntryPlugin.js +1 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +17 -13
- package/lib/ExportsInfo.js +8 -4
- package/lib/ExternalModule.js +16 -0
- package/lib/FalseIIFEUmdWarning.js +1 -0
- package/lib/FileSystemInfo.js +49 -25
- package/lib/FlagDependencyExportsPlugin.js +8 -1
- package/lib/FlagDependencyUsagePlugin.js +9 -7
- package/lib/HarmonyLinkingError.js +1 -0
- package/lib/HookWebpackError.js +2 -0
- package/lib/HotModuleReplacementPlugin.js +16 -2
- package/lib/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +4 -1
- package/lib/Module.js +7 -4
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +2 -1
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -1
- package/lib/ModuleHashingError.js +2 -0
- package/lib/ModuleInfoHeaderPlugin.js +6 -1
- package/lib/ModuleNotFoundError.js +1 -0
- package/lib/ModuleParseError.js +5 -1
- package/lib/ModuleProfile.js +1 -1
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleSourceTypeConstants.js +1 -11
- package/lib/ModuleStoreError.js +2 -0
- package/lib/ModuleWarning.js +3 -1
- package/lib/MultiCompiler.js +11 -7
- package/lib/MultiWatching.js +2 -2
- package/lib/NoModeWarning.js +1 -0
- package/lib/NodeStuffInWebError.js +1 -0
- package/lib/NormalModule.js +26 -5
- package/lib/NormalModuleFactory.js +20 -4
- package/lib/OptionsApply.js +3 -1
- package/lib/ProgressPlugin.js +4 -0
- package/lib/RawModule.js +2 -0
- package/lib/RuntimeModule.js +10 -0
- package/lib/RuntimePlugin.js +7 -9
- package/lib/RuntimeTemplate.js +14 -7
- package/lib/SourceMapDevToolPlugin.js +30 -23
- package/lib/Template.js +10 -5
- package/lib/TemplatedPathPlugin.js +4 -2
- package/lib/UnhandledSchemeError.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -1
- package/lib/Watching.js +5 -0
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsApply.js +60 -40
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +9 -3
- package/lib/asset/AssetModulesPlugin.js +33 -2
- package/lib/asset/AssetSourceGenerator.js +1 -0
- package/lib/asset/RawDataUrlModule.js +4 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +31 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +41 -8
- package/lib/cache/getLazyHashedEtag.js +13 -4
- package/lib/cache/mergeEtags.js +3 -1
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +65 -44
- package/lib/config/normalization.js +96 -0
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/RemoteModule.js +19 -0
- package/lib/css/CssGenerator.js +31 -4
- package/lib/css/CssModulesPlugin.js +26 -30
- package/lib/css/CssParser.js +12 -9
- package/lib/debug/ProfilingPlugin.js +1 -0
- package/lib/dependencies/AMDDefineDependency.js +3 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
- package/lib/dependencies/AMDPlugin.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
- package/lib/dependencies/CachedConstDependency.js +1 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
- package/lib/dependencies/ConstDependency.js +1 -0
- package/lib/dependencies/ContextDependencyHelpers.js +11 -4
- package/lib/dependencies/ContextElementDependency.js +1 -0
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +5 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
- package/lib/dependencies/CssUrlDependency.js +2 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
- package/lib/dependencies/ImportDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +53 -11
- package/lib/dependencies/ImportParserPlugin.js +7 -12
- package/lib/dependencies/LoaderPlugin.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
- package/lib/dependencies/ProvidedDependency.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +9 -3
- package/lib/dependencies/WorkerPlugin.js +1 -0
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/errors/BuildCycleError.js +4 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
- package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +5 -0
- package/lib/hmr/lazyCompilationBackend.js +3 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
- package/lib/ids/SyncModuleIdsPlugin.js +5 -1
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
- package/lib/javascript/JavascriptModulesPlugin.js +29 -8
- package/lib/javascript/JavascriptParser.js +47 -14
- package/lib/json/JsonParser.js +6 -0
- package/lib/library/AbstractLibraryPlugin.js +4 -1
- package/lib/library/AmdLibraryPlugin.js +2 -1
- package/lib/library/AssignLibraryPlugin.js +6 -2
- package/lib/library/EnableLibraryPlugin.js +1 -0
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +130 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +4 -3
- package/lib/logging/createConsoleLogger.js +3 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
- package/lib/optimize/ConcatenatedModule.js +33 -19
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
- package/lib/optimize/InnerGraph.js +5 -3
- package/lib/optimize/InnerGraphPlugin.js +25 -25
- package/lib/optimize/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
- package/lib/optimize/RealContentHashPlugin.js +35 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +14 -3
- package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
- package/lib/performance/NoAsyncChunksWarning.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +2 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
- package/lib/rules/RuleSetCompiler.js +2 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +27 -7
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/BinaryMiddleware.js +4 -0
- package/lib/serialization/FileMiddleware.js +9 -4
- package/lib/serialization/ObjectMiddleware.js +34 -11
- package/lib/serialization/PlainObjectSerializer.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +60 -0
- package/lib/sharing/ConsumeSharedPlugin.js +5 -4
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +24 -25
- package/lib/sharing/resolveMatchedConfigs.js +2 -2
- package/lib/sharing/utils.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +4 -3
- package/lib/util/AppendOnlyStackedSet.js +57 -0
- package/lib/util/Hash.js +1 -0
- package/lib/util/IterableHelpers.js +1 -0
- package/lib/util/LazyBucketSortedSet.js +1 -0
- package/lib/util/LazySet.js +1 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/SortableSet.js +1 -0
- package/lib/util/StringXor.js +1 -0
- package/lib/util/binarySearchBounds.js +15 -8
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +6 -1
- package/lib/util/comparators.js +21 -1
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +3 -2
- package/lib/util/conventions.js +3 -2
- package/lib/util/deterministicGrouping.js +13 -1
- package/lib/util/extractSourceMap.js +12 -13
- package/lib/util/fs.js +15 -19
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/BulkUpdateHash.js +7 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +16 -1
- package/lib/util/identifier.js +7 -2
- package/lib/util/magicComment.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -0
- package/lib/util/runtime.js +15 -1
- package/lib/util/semver.js +1 -0
- package/lib/util/serialization.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/webpack.js +13 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/package.json +20 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +71 -5
- package/types.d.ts +339 -93
|
@@ -35,7 +35,7 @@ const CssImportDependency = require("../dependencies/CssImportDependency");
|
|
|
35
35
|
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
|
36
36
|
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
|
37
37
|
const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin");
|
|
38
|
-
const {
|
|
38
|
+
const { compareModulesByFullName } = require("../util/comparators");
|
|
39
39
|
const createSchemaValidation = require("../util/create-schema-validation");
|
|
40
40
|
const createHash = require("../util/createHash");
|
|
41
41
|
const { getUndoPath } = require("../util/identifier");
|
|
@@ -311,7 +311,7 @@ class CssModulesPlugin {
|
|
|
311
311
|
(compilation.moduleGraph.getParentModule(dependency));
|
|
312
312
|
|
|
313
313
|
if (parent instanceof CssModule) {
|
|
314
|
-
/** @type {
|
|
314
|
+
/** @type {Inheritance | undefined} */
|
|
315
315
|
let inheritance;
|
|
316
316
|
|
|
317
317
|
if (
|
|
@@ -417,6 +417,7 @@ class CssModulesPlugin {
|
|
|
417
417
|
|
|
418
418
|
return source;
|
|
419
419
|
});
|
|
420
|
+
/** @type {WeakMap<Chunk, CssModule[]>} */
|
|
420
421
|
const orderedCssModulesPerChunk = new WeakMap();
|
|
421
422
|
compilation.hooks.afterCodeGeneration.tap(PLUGIN_NAME, () => {
|
|
422
423
|
const { chunkGraph } = compilation;
|
|
@@ -526,6 +527,7 @@ class CssModulesPlugin {
|
|
|
526
527
|
: globalChunkLoading;
|
|
527
528
|
return chunkLoading === "jsonp" || chunkLoading === "import";
|
|
528
529
|
};
|
|
530
|
+
/** @type {WeakSet<Chunk>} */
|
|
529
531
|
const onceForChunkSet = new WeakSet();
|
|
530
532
|
/**
|
|
531
533
|
* @param {Chunk} chunk chunk to check
|
|
@@ -597,7 +599,7 @@ class CssModulesPlugin {
|
|
|
597
599
|
|
|
598
600
|
/**
|
|
599
601
|
* @param {Chunk} chunk chunk
|
|
600
|
-
* @param {Iterable<Module>} modules unordered modules
|
|
602
|
+
* @param {Iterable<Module> | undefined} modules unordered modules
|
|
601
603
|
* @param {Compilation} compilation compilation
|
|
602
604
|
* @returns {Module[]} ordered modules
|
|
603
605
|
*/
|
|
@@ -632,8 +634,8 @@ class CssModulesPlugin {
|
|
|
632
634
|
return modulesByChunkGroup[0].list.reverse();
|
|
633
635
|
}
|
|
634
636
|
|
|
635
|
-
const
|
|
636
|
-
compilation.
|
|
637
|
+
const boundCompareModulesByFullName = compareModulesByFullName(
|
|
638
|
+
compilation.compiler
|
|
637
639
|
);
|
|
638
640
|
|
|
639
641
|
/**
|
|
@@ -646,10 +648,7 @@ class CssModulesPlugin {
|
|
|
646
648
|
return b.length === 0 ? 0 : 1;
|
|
647
649
|
}
|
|
648
650
|
if (b.length === 0) return -1;
|
|
649
|
-
return
|
|
650
|
-
a[a.length - 1],
|
|
651
|
-
b[b.length - 1]
|
|
652
|
-
);
|
|
651
|
+
return boundCompareModulesByFullName(a[a.length - 1], b[b.length - 1]);
|
|
653
652
|
};
|
|
654
653
|
|
|
655
654
|
modulesByChunkGroup.sort(compareModuleLists);
|
|
@@ -658,6 +657,7 @@ class CssModulesPlugin {
|
|
|
658
657
|
const finalModules = [];
|
|
659
658
|
|
|
660
659
|
for (;;) {
|
|
660
|
+
/** @type {Set<Module>} */
|
|
661
661
|
const failedModules = new Set();
|
|
662
662
|
const list = modulesByChunkGroup[0].list;
|
|
663
663
|
if (list.length === 0) {
|
|
@@ -666,6 +666,7 @@ class CssModulesPlugin {
|
|
|
666
666
|
}
|
|
667
667
|
/** @type {Module} */
|
|
668
668
|
let selectedModule = list[list.length - 1];
|
|
669
|
+
/** @type {undefined | false | Module} */
|
|
669
670
|
let hasFailed;
|
|
670
671
|
outer: for (;;) {
|
|
671
672
|
for (const { list, set } of modulesByChunkGroup) {
|
|
@@ -690,10 +691,9 @@ class CssModulesPlugin {
|
|
|
690
691
|
// TODO print better warning
|
|
691
692
|
compilation.warnings.push(
|
|
692
693
|
new WebpackError(
|
|
693
|
-
`chunk ${chunk.name || chunk.id}\nConflicting order between ${
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
} and ${selectedModule.readableIdentifier(
|
|
694
|
+
`chunk ${chunk.name || chunk.id}\nConflicting order between ${hasFailed.readableIdentifier(
|
|
695
|
+
compilation.requestShortener
|
|
696
|
+
)} and ${selectedModule.readableIdentifier(
|
|
697
697
|
compilation.requestShortener
|
|
698
698
|
)}`
|
|
699
699
|
)
|
|
@@ -721,35 +721,29 @@ class CssModulesPlugin {
|
|
|
721
721
|
* @param {Chunk} chunk chunk
|
|
722
722
|
* @param {ChunkGraph} chunkGraph chunk graph
|
|
723
723
|
* @param {Compilation} compilation compilation
|
|
724
|
-
* @returns {
|
|
724
|
+
* @returns {CssModule[]} ordered css modules
|
|
725
725
|
*/
|
|
726
726
|
getOrderedChunkCssModules(chunk, chunkGraph, compilation) {
|
|
727
|
-
return [
|
|
727
|
+
return /** @type {CssModule[]} */ ([
|
|
728
728
|
...this.getModulesInOrder(
|
|
729
729
|
chunk,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
CSS_IMPORT_TYPE,
|
|
735
|
-
compareModulesByIdOrIdentifier(chunkGraph)
|
|
736
|
-
)
|
|
730
|
+
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
731
|
+
chunk,
|
|
732
|
+
CSS_IMPORT_TYPE,
|
|
733
|
+
compareModulesByFullName(compilation.compiler)
|
|
737
734
|
),
|
|
738
735
|
compilation
|
|
739
736
|
),
|
|
740
737
|
...this.getModulesInOrder(
|
|
741
738
|
chunk,
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
CSS_TYPE,
|
|
747
|
-
compareModulesByIdOrIdentifier(chunkGraph)
|
|
748
|
-
)
|
|
739
|
+
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
|
740
|
+
chunk,
|
|
741
|
+
CSS_TYPE,
|
|
742
|
+
compareModulesByFullName(compilation.compiler)
|
|
749
743
|
),
|
|
750
744
|
compilation
|
|
751
745
|
)
|
|
752
|
-
];
|
|
746
|
+
]);
|
|
753
747
|
}
|
|
754
748
|
|
|
755
749
|
/**
|
|
@@ -768,6 +762,7 @@ class CssModulesPlugin {
|
|
|
768
762
|
inheritance.push(...module.inheritance);
|
|
769
763
|
}
|
|
770
764
|
|
|
765
|
+
/** @type {CachedSource} */
|
|
771
766
|
let source;
|
|
772
767
|
if (
|
|
773
768
|
cacheEntry &&
|
|
@@ -792,6 +787,7 @@ class CssModulesPlugin {
|
|
|
792
787
|
);
|
|
793
788
|
/** @type {Source} */
|
|
794
789
|
let moduleSource = new ReplaceSource(moduleSourceContent);
|
|
790
|
+
/** @type {null | RegExpExecArray} */
|
|
795
791
|
let match;
|
|
796
792
|
while ((match = publicPathAutoRegex.exec(moduleSourceCode))) {
|
|
797
793
|
/** @type {ReplaceSource} */ (moduleSource).replace(
|
package/lib/css/CssParser.js
CHANGED
|
@@ -56,11 +56,11 @@ const CC_EQUAL = "=".charCodeAt(0);
|
|
|
56
56
|
const STRING_MULTILINE = /\\[\n\r\f]/g;
|
|
57
57
|
// https://www.w3.org/TR/css-syntax-3/#whitespace
|
|
58
58
|
const TRIM_WHITE_SPACES = /(^[ \t\n\r\f]*|[ \t\n\r\f]*$)/g;
|
|
59
|
-
const UNESCAPE = /\\([0-9a-
|
|
60
|
-
const IMAGE_SET_FUNCTION = /^(
|
|
61
|
-
const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(
|
|
62
|
-
const COMPOSES_PROPERTY = /^(composes|compose-with)$/i;
|
|
63
|
-
const IS_MODULES = /\.
|
|
59
|
+
const UNESCAPE = /\\([0-9a-f]{1,6}[ \t\n\r\f]?|[\s\S])/gi;
|
|
60
|
+
const IMAGE_SET_FUNCTION = /^(?:-\w+-)?image-set$/i;
|
|
61
|
+
const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(?:-\w+-)?keyframes$/;
|
|
62
|
+
const COMPOSES_PROPERTY = /^(?:composes|compose-with)$/i;
|
|
63
|
+
const IS_MODULES = /\.modules?\.[^.]+$/i;
|
|
64
64
|
const CSS_COMMENT = /\/\*((?!\*\/).*?)\*\//g;
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -72,6 +72,7 @@ const matchAll = (regexp, str) => {
|
|
|
72
72
|
/** @type {RegExpExecArray[]} */
|
|
73
73
|
const result = [];
|
|
74
74
|
|
|
75
|
+
/** @type {null | RegExpExecArray} */
|
|
75
76
|
let match;
|
|
76
77
|
|
|
77
78
|
// Use a while loop with exec() to find all matches
|
|
@@ -123,8 +124,7 @@ const normalizeUrl = (str, isString) => {
|
|
|
123
124
|
return str;
|
|
124
125
|
};
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
const regexSingleEscape = /[ -,.\/:-@[\]\^`{-~]/;
|
|
127
|
+
const regexSingleEscape = /[ -,./:-@[\]^`{-~]/;
|
|
128
128
|
const regexExcessiveSpaces =
|
|
129
129
|
/(^|\\+)?(\\[A-F0-9]{1,6})\u0020(?![a-fA-F0-9\u0020])/g;
|
|
130
130
|
|
|
@@ -139,10 +139,10 @@ const escapeIdentifier = (str) => {
|
|
|
139
139
|
while (counter < str.length) {
|
|
140
140
|
const character = str.charAt(counter++);
|
|
141
141
|
|
|
142
|
+
/** @type {string} */
|
|
142
143
|
let value;
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
if (/[\t\n\f\r\u000B]/.test(character)) {
|
|
145
|
+
if (/[\t\n\f\r\v]/.test(character)) {
|
|
146
146
|
const codePoint = character.charCodeAt(0);
|
|
147
147
|
|
|
148
148
|
value = `\\${codePoint.toString(16).toUpperCase()} `;
|
|
@@ -829,12 +829,14 @@ class CssParser extends Parser {
|
|
|
829
829
|
return newline;
|
|
830
830
|
}
|
|
831
831
|
|
|
832
|
+
/** @type {undefined | string} */
|
|
832
833
|
let layer;
|
|
833
834
|
|
|
834
835
|
if (tokens[1]) {
|
|
835
836
|
layer = input.slice(tokens[1][0] + 6, tokens[1][1] - 1).trim();
|
|
836
837
|
}
|
|
837
838
|
|
|
839
|
+
/** @type {undefined | string} */
|
|
838
840
|
let supports;
|
|
839
841
|
|
|
840
842
|
if (tokens[2]) {
|
|
@@ -847,6 +849,7 @@ class CssParser extends Parser {
|
|
|
847
849
|
last[1]
|
|
848
850
|
)[0];
|
|
849
851
|
|
|
852
|
+
/** @type {undefined | string} */
|
|
850
853
|
let media;
|
|
851
854
|
|
|
852
855
|
if (mediaStart !== semi - 1) {
|
|
@@ -10,6 +10,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
10
10
|
const NullDependency = require("./NullDependency");
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
13
|
+
/** @typedef {import("./LocalModule")} LocalModule */
|
|
13
14
|
/** @typedef {import("../Dependency")} Dependency */
|
|
14
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
15
16
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
@@ -120,6 +121,7 @@ class AMDDefineDependency extends NullDependency {
|
|
|
120
121
|
this.functionRange = functionRange;
|
|
121
122
|
this.objectRange = objectRange;
|
|
122
123
|
this.namedModule = namedModule;
|
|
124
|
+
/** @type {LocalModule | null} */
|
|
123
125
|
this.localModule = null;
|
|
124
126
|
}
|
|
125
127
|
|
|
@@ -182,7 +184,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends (
|
|
|
182
184
|
|
|
183
185
|
/**
|
|
184
186
|
* @param {AMDDefineDependency} dependency dependency
|
|
185
|
-
* @returns {string} variable name
|
|
187
|
+
* @returns {string | false | null} variable name
|
|
186
188
|
*/
|
|
187
189
|
localModuleVar(dependency) {
|
|
188
190
|
return (
|
|
@@ -26,11 +26,13 @@ const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers");
|
|
|
26
26
|
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
|
27
27
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
28
28
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
29
|
+
/** @typedef {import("../Dependency")} Dependency */
|
|
29
30
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
30
31
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
31
32
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
32
33
|
/** @typedef {import("../javascript/JavascriptParser").ExportedVariableInfo} ExportedVariableInfo */
|
|
33
34
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
35
|
+
/** @typedef {import("./LocalModule")} LocalModule */
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* @param {Expression | SpreadElement} expr expression
|
|
@@ -123,7 +125,9 @@ class AMDDefineDependencyParserPlugin {
|
|
|
123
125
|
const deps = [];
|
|
124
126
|
const array = /** @type {string[]} */ (param.array);
|
|
125
127
|
for (const [idx, request] of array.entries()) {
|
|
128
|
+
/** @type {string | LocalModuleDependency | AMDRequireItemDependency} */
|
|
126
129
|
let dep;
|
|
130
|
+
/** @type {undefined | null | LocalModule} */
|
|
127
131
|
let localModule;
|
|
128
132
|
if (request === "require") {
|
|
129
133
|
identifiers[idx] = request;
|
|
@@ -174,7 +178,9 @@ class AMDDefineDependencyParserPlugin {
|
|
|
174
178
|
|
|
175
179
|
return true;
|
|
176
180
|
} else if (param.isString()) {
|
|
181
|
+
/** @type {Dependency} */
|
|
177
182
|
let dep;
|
|
183
|
+
/** @type {undefined | null | LocalModule} */
|
|
178
184
|
let localModule;
|
|
179
185
|
|
|
180
186
|
if (param.string === "require") {
|
|
@@ -25,10 +25,12 @@ const getFunctionExpression = require("./getFunctionExpression");
|
|
|
25
25
|
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
|
26
26
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
27
27
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
28
|
+
/** @typedef {import("../Dependency")} Dependency */
|
|
28
29
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
29
30
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
30
31
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
31
32
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
33
|
+
/** @typedef {import("./LocalModule")} LocalModule */
|
|
32
34
|
|
|
33
35
|
const PLUGIN_NAME = "AMDRequireDependenciesBlockParserPlugin";
|
|
34
36
|
|
|
@@ -102,8 +104,10 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
102
104
|
} else if (param.isConstArray()) {
|
|
103
105
|
/** @type {(string | LocalModuleDependency | AMDRequireItemDependency)[]} */
|
|
104
106
|
const deps = [];
|
|
105
|
-
for (const request of /** @type {
|
|
107
|
+
for (const request of /** @type {string[]} */ (param.array)) {
|
|
108
|
+
/** @type {string | LocalModuleDependency | AMDRequireItemDependency} */
|
|
106
109
|
let dep;
|
|
110
|
+
/** @type {undefined | null | LocalModule} */
|
|
107
111
|
let localModule;
|
|
108
112
|
if (request === "require") {
|
|
109
113
|
dep = RuntimeGlobals.require;
|
|
@@ -152,7 +156,9 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
152
156
|
}
|
|
153
157
|
return true;
|
|
154
158
|
} else if (param.isString()) {
|
|
159
|
+
/** @type {Dependency} */
|
|
155
160
|
let dep;
|
|
161
|
+
/** @type {LocalModule | null | undefined} */
|
|
156
162
|
let localModule;
|
|
157
163
|
if (param.string === "require") {
|
|
158
164
|
dep = new ConstDependency(
|
|
@@ -41,7 +41,9 @@ class CommonJsFullRequireDependency extends ModuleDependency {
|
|
|
41
41
|
this.range = range;
|
|
42
42
|
this.names = names;
|
|
43
43
|
this.idRanges = idRanges;
|
|
44
|
+
/** @type {boolean} */
|
|
44
45
|
this.call = false;
|
|
46
|
+
/** @type {undefined | boolean} */
|
|
45
47
|
this.asiSafe = undefined;
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -40,6 +40,7 @@ const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency
|
|
|
40
40
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
41
41
|
/** @typedef {import("../javascript/JavascriptParser").Members} Members */
|
|
42
42
|
/** @typedef {import("../javascript/JavascriptParser").CalleeMembers} CalleeMembers */
|
|
43
|
+
/** @typedef {import("./LocalModule")} LocalModule */
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* @typedef {object} CommonJsImportSettings
|
|
@@ -299,6 +300,7 @@ class CommonJsImportsParserPlugin {
|
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
if (expr.arguments.length !== 1) return;
|
|
303
|
+
/** @type {null | LocalModule} */
|
|
302
304
|
let localModule;
|
|
303
305
|
const param = parser.evaluateExpression(expr.arguments[0]);
|
|
304
306
|
if (param.isConditional()) {
|
|
@@ -586,6 +588,7 @@ class CommonJsImportsParserPlugin {
|
|
|
586
588
|
moduleName = ["module", "node:module"];
|
|
587
589
|
specifierName = "createRequire";
|
|
588
590
|
} else {
|
|
591
|
+
/** @type {undefined | string} */
|
|
589
592
|
let moduleName;
|
|
590
593
|
const match = /^(.*) from (.*)$/.exec(options.createRequire);
|
|
591
594
|
if (match) {
|
|
@@ -18,8 +18,8 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
|
|
18
18
|
/**
|
|
19
19
|
* @param {ContextDependencyOptions} options options for the context module
|
|
20
20
|
* @param {Range} range location in source code
|
|
21
|
-
* @param {Range
|
|
22
|
-
* @param {boolean | string} inShorthand true or name
|
|
21
|
+
* @param {Range=} valueRange location of the require call
|
|
22
|
+
* @param {boolean | string=} inShorthand true or name
|
|
23
23
|
* @param {string=} context context
|
|
24
24
|
*/
|
|
25
25
|
constructor(options, range, valueRange, inShorthand, context) {
|
|
@@ -26,7 +26,7 @@ const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @param {string} prefix prefix
|
|
29
|
-
* @returns {{prefix: string, context: string}} result
|
|
29
|
+
* @returns {{ prefix: string, context: string }} result
|
|
30
30
|
*/
|
|
31
31
|
const splitContextFromPrefix = (prefix) => {
|
|
32
32
|
const idx = prefix.lastIndexOf("/");
|
|
@@ -42,17 +42,23 @@ const splitContextFromPrefix = (prefix) => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
|
|
45
|
-
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */
|
|
45
|
+
/** @typedef {{ new (options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* @
|
|
48
|
+
* @template T
|
|
49
|
+
* @typedef {T extends new (options: ContextDependencyOptions, range: Range, valueRange: Range, ...remains: infer R) => EXPECTED_ANY ? R : []} GetAdditionalDepArgs
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @template {ContextDependencyConstructor} T
|
|
54
|
+
* @param {T} Dep the Dependency class
|
|
49
55
|
* @param {Range} range source range
|
|
50
56
|
* @param {BasicEvaluatedExpression} param context param
|
|
51
57
|
* @param {Expression} expr expr
|
|
52
58
|
* @param {Pick<JavascriptParserOptions, `${"expr" | "wrapped"}Context${"Critical" | "Recursive" | "RegExp"}` | "exprContextRequest">} options options for context creation
|
|
53
59
|
* @param {PartialContextDependencyOptions} contextOptions options for the ContextModule
|
|
54
60
|
* @param {JavascriptParser} parser the parser
|
|
55
|
-
* @param {
|
|
61
|
+
* @param {GetAdditionalDepArgs<T>} depArgs depArgs
|
|
56
62
|
* @returns {ContextDependency} the created Dependency
|
|
57
63
|
*/
|
|
58
64
|
module.exports.create = (
|
|
@@ -216,6 +222,7 @@ module.exports.create = (
|
|
|
216
222
|
...depArgs
|
|
217
223
|
);
|
|
218
224
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
225
|
+
/** @type {Replaces} */
|
|
219
226
|
const replaces = [];
|
|
220
227
|
if (prefixRange) {
|
|
221
228
|
replaces.push({
|
|
@@ -82,6 +82,7 @@ class ContextElementDependency extends ModuleDependency {
|
|
|
82
82
|
*/
|
|
83
83
|
getReferencedExports(moduleGraph, runtime) {
|
|
84
84
|
if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
85
|
+
/** @type {ReferencedExports} */
|
|
85
86
|
const refs = [];
|
|
86
87
|
for (const referencedExport of this.referencedExports) {
|
|
87
88
|
if (
|
|
@@ -60,7 +60,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
60
60
|
|
|
61
61
|
let localIdentHash = "";
|
|
62
62
|
|
|
63
|
-
if (/\[(fullhash|hash)\]/.test(localIdentName)) {
|
|
63
|
+
if (/\[(?:fullhash|hash)\]/.test(localIdentName)) {
|
|
64
64
|
const hashSalt = generator.options.localIdentHashSalt;
|
|
65
65
|
const hashDigest =
|
|
66
66
|
/** @type {string} */
|
|
@@ -113,8 +113,8 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
113
113
|
if (typeof id !== "string") return id;
|
|
114
114
|
|
|
115
115
|
return id
|
|
116
|
-
.replace(/^([.-]|[^a-
|
|
117
|
-
.replace(/[^a-
|
|
116
|
+
.replace(/^([.-]|[^a-z0-9_-])+/i, "")
|
|
117
|
+
.replace(/[^a-z0-9_-]+/gi, "_");
|
|
118
118
|
},
|
|
119
119
|
filename: relativeResourcePath,
|
|
120
120
|
hash: localIdentHash,
|
|
@@ -135,7 +135,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// Protect the first character from unsupported values
|
|
138
|
-
return localIdent.replace(/^((
|
|
138
|
+
return localIdent.replace(/^((-?\d)|--)/, "_$1");
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
// 0 - replace, 1 - replace, 2 - append, 2 - once
|
|
@@ -170,6 +170,7 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
170
170
|
this.interpolate = interpolate;
|
|
171
171
|
this.exportMode = exportMode;
|
|
172
172
|
this.exportType = exportType;
|
|
173
|
+
/** @type {undefined | string} */
|
|
173
174
|
this._hashUpdate = undefined;
|
|
174
175
|
}
|
|
175
176
|
|
|
@@ -16,6 +16,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
16
16
|
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
|
17
17
|
/** @typedef {import("../Module")} Module */
|
|
18
18
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
19
|
+
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
19
20
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
20
21
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
21
22
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
@@ -173,9 +174,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
|
173
174
|
return "data:,";
|
|
174
175
|
}
|
|
175
176
|
const codeGen = codeGenerationResults.get(module, runtime);
|
|
176
|
-
const data =
|
|
177
|
-
/** @type {NonNullable<CodeGenerationResult["data"]>} */
|
|
178
|
-
(codeGen.data);
|
|
177
|
+
const data = codeGen.data;
|
|
179
178
|
if (!data) return "data:,";
|
|
180
179
|
const url = data.get("url");
|
|
181
180
|
if (!url || !url["css-url"]) return "data:,";
|
|
@@ -13,7 +13,8 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
13
13
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
14
14
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
15
15
|
/** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */
|
|
16
|
-
/** @typedef {
|
|
16
|
+
/** @typedef {Set<string>} ImportSpecifier */
|
|
17
|
+
/** @typedef {Map<string, ImportSpecifier>} ImportSpecifiers */
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* @extends {InitFragment<GenerateContext>}
|
|
@@ -38,6 +39,7 @@ class ExternalModuleInitFragment extends InitFragment {
|
|
|
38
39
|
for (const { name, value } of specifiers) {
|
|
39
40
|
let specifiers = this.specifiers.get(name);
|
|
40
41
|
if (!specifiers) {
|
|
42
|
+
/** @type {ImportSpecifier} */
|
|
41
43
|
specifiers = new Set();
|
|
42
44
|
this.specifiers.set(name, specifiers);
|
|
43
45
|
}
|
|
@@ -77,6 +79,7 @@ class ExternalModuleInitFragment extends InitFragment {
|
|
|
77
79
|
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
|
78
80
|
*/
|
|
79
81
|
getContent({ runtimeRequirements }) {
|
|
82
|
+
/** @type {string[]} */
|
|
80
83
|
const namedImports = [];
|
|
81
84
|
|
|
82
85
|
for (const [name, specifiers] of this.specifiers) {
|
|
@@ -31,15 +31,6 @@ class ExternalModuleInitFragmentDependency extends NullDependency {
|
|
|
31
31
|
this.default = defaultImport;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* @returns {string} hash update
|
|
36
|
-
*/
|
|
37
|
-
_createHashUpdate() {
|
|
38
|
-
return `${this.importedModule}${JSON.stringify(this.specifiers)}${
|
|
39
|
-
this.default || "null"
|
|
40
|
-
}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
34
|
/**
|
|
44
35
|
* @param {ObjectSerializerContext} context context
|
|
45
36
|
*/
|
|
@@ -114,8 +114,11 @@ HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate extends
|
|
|
114
114
|
* @returns {HarmonyImportDependency[]} array of related harmony import dependencies
|
|
115
115
|
*/
|
|
116
116
|
const getHarmonyImportDependencies = (dependency) => {
|
|
117
|
+
/** @type {HarmonyImportDependency[]} */
|
|
117
118
|
const result = [];
|
|
119
|
+
/** @type {HarmonyImportDependency | null} */
|
|
118
120
|
let deferDependency = null;
|
|
121
|
+
/** @type {HarmonyImportDependency | null} */
|
|
119
122
|
let noDeferredDependency = null;
|
|
120
123
|
|
|
121
124
|
for (const d of module.dependencies) {
|
|
@@ -21,6 +21,7 @@ const NullDependency = require("./NullDependency");
|
|
|
21
21
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
22
22
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
23
23
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
24
|
+
/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
|
|
24
25
|
|
|
25
26
|
class HarmonyExportExpressionDependency extends NullDependency {
|
|
26
27
|
/**
|
|
@@ -120,6 +121,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
|
120
121
|
const { declarationId } = dep;
|
|
121
122
|
const exportsName = module.exportsArgument;
|
|
122
123
|
if (declarationId) {
|
|
124
|
+
/** @type {string} */
|
|
123
125
|
let name;
|
|
124
126
|
if (typeof declarationId === "string") {
|
|
125
127
|
name = declarationId;
|
|
@@ -139,6 +141,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
|
139
141
|
.getExportsInfo(module)
|
|
140
142
|
.getUsedName("default", runtime);
|
|
141
143
|
if (used) {
|
|
144
|
+
/** @type {ExportMap} */
|
|
142
145
|
const map = new Map();
|
|
143
146
|
map.set(used, `/* export default binding */ ${name}`);
|
|
144
147
|
initFragments.push(new HarmonyExportInitFragment(exportsName, map));
|
|
@@ -164,6 +167,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
|
164
167
|
.getUsedName("default", runtime);
|
|
165
168
|
if (used) {
|
|
166
169
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
170
|
+
/** @type {ExportMap} */
|
|
167
171
|
const map = new Map();
|
|
168
172
|
map.set(used, name);
|
|
169
173
|
initFragments.push(new HarmonyExportInitFragment(exportsName, map));
|