webpack 5.90.3 → 5.92.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +5 -5
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +14 -6
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -1
- package/lib/Cache.js +8 -2
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +7 -4
- package/lib/ChunkGraph.js +52 -25
- package/lib/ChunkGroup.js +23 -17
- package/lib/CleanPlugin.js +8 -6
- package/lib/Compilation.js +295 -120
- package/lib/Compiler.js +223 -87
- package/lib/ConcatenationScope.js +3 -3
- package/lib/ConditionalInitFragment.js +4 -5
- package/lib/ContextModule.js +95 -41
- package/lib/ContextModuleFactory.js +4 -2
- package/lib/ContextReplacementPlugin.js +3 -2
- package/lib/DefinePlugin.js +18 -6
- package/lib/Dependency.js +12 -10
- package/lib/DependencyTemplate.js +17 -7
- package/lib/DllModule.js +1 -0
- package/lib/DllReferencePlugin.js +7 -3
- package/lib/EntryOptionPlugin.js +4 -1
- package/lib/EntryPlugin.js +6 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +11 -0
- package/lib/ExportsInfo.js +23 -8
- package/lib/ExternalModule.js +160 -35
- package/lib/ExternalModuleFactoryPlugin.js +37 -2
- package/lib/FileSystemInfo.js +69 -42
- package/lib/FlagDependencyExportsPlugin.js +21 -7
- package/lib/Generator.js +4 -4
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +108 -45
- package/lib/IgnorePlugin.js +4 -1
- package/lib/InitFragment.js +5 -3
- package/lib/LibManifestPlugin.js +17 -9
- package/lib/Module.js +41 -14
- package/lib/ModuleFactory.js +3 -3
- package/lib/ModuleFilenameHelpers.js +30 -17
- package/lib/ModuleGraph.js +60 -31
- package/lib/ModuleGraphConnection.js +2 -1
- package/lib/MultiCompiler.js +62 -9
- package/lib/NodeStuffPlugin.js +14 -3
- package/lib/NormalModule.js +13 -13
- package/lib/NormalModuleFactory.js +18 -9
- package/lib/NormalModuleReplacementPlugin.js +5 -1
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/ProgressPlugin.js +1 -1
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +2 -1
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/ResolverFactory.js +6 -4
- package/lib/RuntimeModule.js +4 -4
- package/lib/RuntimePlugin.js +1 -0
- package/lib/RuntimeTemplate.js +124 -52
- package/lib/SourceMapDevToolPlugin.js +4 -1
- package/lib/Stats.js +11 -4
- package/lib/Template.js +5 -5
- package/lib/TemplatedPathPlugin.js +48 -7
- package/lib/Watching.js +67 -60
- package/lib/WebpackError.js +6 -6
- package/lib/WebpackOptionsApply.js +18 -5
- package/lib/asset/AssetGenerator.js +15 -0
- package/lib/asset/RawDataUrlModule.js +3 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
- package/lib/buildChunkGraph.js +120 -67
- package/lib/cache/IdleFileCachePlugin.js +8 -3
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +51 -18
- package/lib/cache/ResolverCachePlugin.js +22 -14
- package/lib/cache/getLazyHashedEtag.js +2 -2
- package/lib/cli.js +5 -5
- package/lib/config/browserslistTargetHandler.js +7 -1
- package/lib/config/defaults.js +108 -34
- package/lib/config/normalization.js +3 -1
- package/lib/config/target.js +18 -11
- package/lib/container/ContainerEntryDependency.js +2 -1
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerPlugin.js +14 -10
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +12 -3
- package/lib/css/CssExportsGenerator.js +68 -25
- package/lib/css/CssGenerator.js +34 -6
- package/lib/css/CssLoadingRuntimeModule.js +217 -98
- package/lib/css/CssModulesPlugin.js +238 -107
- package/lib/css/CssParser.js +24 -15
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +28 -3
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
- package/lib/dependencies/CommonJsExportsDependency.js +13 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
- package/lib/dependencies/ContextDependencyHelpers.js +49 -29
- package/lib/dependencies/ContextElementDependency.js +8 -1
- package/lib/dependencies/CssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
- package/lib/dependencies/CssUrlDependency.js +10 -7
- package/lib/dependencies/ExportsInfoDependency.js +5 -4
- package/lib/dependencies/ExternalModuleDependency.js +4 -2
- package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
- package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
- package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
- package/lib/dependencies/HarmonyImportDependency.js +28 -12
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
- package/lib/dependencies/ImportDependency.js +9 -2
- package/lib/dependencies/ImportEagerDependency.js +4 -2
- package/lib/dependencies/ImportMetaContextDependency.js +7 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
- package/lib/dependencies/ImportMetaPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +15 -5
- package/lib/dependencies/ImportWeakDependency.js +4 -2
- package/lib/dependencies/LoaderDependency.js +2 -1
- package/lib/dependencies/LoaderImportDependency.js +2 -1
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/ModuleDependency.js +4 -5
- package/lib/dependencies/PureExpressionDependency.js +64 -47
- package/lib/dependencies/RequireContextPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
- package/lib/dependencies/RequireEnsureDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +7 -4
- package/lib/dependencies/WorkerDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -1
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +6 -6
- package/lib/ids/NamedChunkIdsPlugin.js +1 -1
- package/lib/ids/NamedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/index.js +11 -0
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +0 -1
- package/lib/javascript/JavascriptModulesPlugin.js +174 -17
- package/lib/javascript/JavascriptParser.js +204 -71
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/javascript/StartupHelpers.js +22 -5
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +3 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +2 -2
- package/lib/library/SystemLibraryPlugin.js +2 -2
- package/lib/library/UmdLibraryPlugin.js +33 -12
- package/lib/logging/Logger.js +27 -2
- package/lib/logging/createConsoleLogger.js +13 -9
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeEnvironmentPlugin.js +14 -8
- package/lib/node/NodeTemplatePlugin.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +37 -26
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
- package/lib/node/nodeConsole.js +24 -1
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +140 -121
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/InnerGraph.js +8 -3
- package/lib/optimize/InnerGraphPlugin.js +36 -13
- package/lib/optimize/LimitChunkCountPlugin.js +1 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
- package/lib/optimize/RealContentHashPlugin.js +3 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/RuntimeChunkPlugin.js +6 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
- package/lib/optimize/SplitChunksPlugin.js +10 -10
- package/lib/performance/SizeLimitsPlugin.js +13 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
- package/lib/rules/RuleSetCompiler.js +9 -7
- package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +4 -4
- package/lib/serialization/FileMiddleware.js +4 -3
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
- package/lib/serialization/ObjectMiddleware.js +8 -5
- package/lib/serialization/PlainObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +19 -0
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +17 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
- package/lib/sharing/ProvideSharedPlugin.js +13 -6
- package/lib/sharing/resolveMatchedConfigs.js +3 -3
- package/lib/sharing/utils.js +13 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/stats/StatsPrinter.js +6 -6
- package/lib/util/ArrayQueue.js +14 -21
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Queue.js +8 -2
- package/lib/util/SortableSet.js +16 -4
- package/lib/util/StackedCacheMap.js +26 -0
- package/lib/util/TupleQueue.js +8 -2
- package/lib/util/WeakTupleMap.js +57 -13
- package/lib/util/binarySearchBounds.js +1 -1
- package/lib/util/cleverMerge.js +26 -13
- package/lib/util/comparators.js +37 -15
- package/lib/util/conventions.js +129 -0
- package/lib/util/createHash.js +3 -5
- package/lib/util/deprecation.js +3 -3
- package/lib/util/deterministicGrouping.js +2 -2
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +383 -69
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +5 -5
- package/lib/util/mergeScope.js +79 -0
- package/lib/util/runtime.js +2 -17
- package/lib/util/semver.js +3 -0
- package/lib/util/smartGrouping.js +3 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyParser.js +7 -4
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
- package/lib/webpack.js +19 -6
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
- package/package.json +40 -39
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +97 -8
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +5 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/types.d.ts +1826 -639
@@ -24,19 +24,23 @@ const processExportInfo = require("./processExportInfo");
|
|
24
24
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
25
25
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
26
26
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
27
|
+
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
27
28
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
28
29
|
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
29
30
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
30
31
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
31
32
|
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
32
33
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
34
|
+
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
33
35
|
/** @typedef {import("../Module")} Module */
|
36
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
37
|
+
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
34
38
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
35
39
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
36
40
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
37
41
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
38
42
|
/** @typedef {import("../WebpackError")} WebpackError */
|
39
|
-
/** @typedef {import("../javascript/JavascriptParser").
|
43
|
+
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
40
44
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
41
45
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
42
46
|
/** @typedef {import("../util/Hash")} Hash */
|
@@ -78,7 +82,7 @@ class ExportMode {
|
|
78
82
|
this.items = null;
|
79
83
|
|
80
84
|
// for "reexport-named-default" | "reexport-fake-namespace-object" | "reexport-namespace-object"
|
81
|
-
/** @type {string|null} */
|
85
|
+
/** @type {string | null} */
|
82
86
|
this.name = null;
|
83
87
|
/** @type {ExportInfo | null} */
|
84
88
|
this.partialNamespaceExportInfo = null;
|
@@ -176,7 +180,7 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
176
180
|
|
177
181
|
const name = dep.name;
|
178
182
|
const runtime = keyToRuntime(runtimeKey);
|
179
|
-
const parentModule = moduleGraph.getParentModule(dep);
|
183
|
+
const parentModule = /** @type {Module} */ (moduleGraph.getParentModule(dep));
|
180
184
|
const exportsInfo = moduleGraph.getExportsInfo(parentModule);
|
181
185
|
|
182
186
|
if (
|
@@ -193,7 +197,7 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
193
197
|
|
194
198
|
const importedExportsType = importedModule.getExportsType(
|
195
199
|
moduleGraph,
|
196
|
-
parentModule.buildMeta.strictHarmonyModule
|
200
|
+
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule
|
197
201
|
);
|
198
202
|
|
199
203
|
const ids = dep.getIds(moduleGraph);
|
@@ -333,7 +337,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
333
337
|
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency> | null} otherStarExports other star exports in the module before this import
|
334
338
|
* @param {number} exportPresenceMode mode of checking export names
|
335
339
|
* @param {HarmonyStarExportsList | null} allStarExports all star exports in the module
|
336
|
-
* @param {
|
340
|
+
* @param {ImportAttributes=} attributes import attributes
|
337
341
|
*/
|
338
342
|
constructor(
|
339
343
|
request,
|
@@ -344,9 +348,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
344
348
|
otherStarExports,
|
345
349
|
exportPresenceMode,
|
346
350
|
allStarExports,
|
347
|
-
|
351
|
+
attributes
|
348
352
|
) {
|
349
|
-
super(request, sourceOrder,
|
353
|
+
super(request, sourceOrder, attributes);
|
350
354
|
|
351
355
|
this.ids = ids;
|
352
356
|
this.name = name;
|
@@ -422,11 +426,12 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
422
426
|
getStarReexports(
|
423
427
|
moduleGraph,
|
424
428
|
runtime,
|
425
|
-
exportsInfo = moduleGraph.getExportsInfo(
|
426
|
-
|
429
|
+
exportsInfo = moduleGraph.getExportsInfo(
|
430
|
+
/** @type {Module} */ (moduleGraph.getParentModule(this))
|
431
|
+
),
|
432
|
+
importedModule = /** @type {Module} */ (moduleGraph.getModule(this))
|
427
433
|
) {
|
428
434
|
const importedExportsInfo = moduleGraph.getExportsInfo(importedModule);
|
429
|
-
|
430
435
|
const noExtraExports =
|
431
436
|
importedExportsInfo.otherExportsInfo.provided === false;
|
432
437
|
const noExtraImports =
|
@@ -456,7 +461,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
456
461
|
const exports = new Set();
|
457
462
|
/** @type {Set<string>} */
|
458
463
|
const checked = new Set();
|
459
|
-
/** @type {Set<string>} */
|
464
|
+
/** @type {Set<string> | undefined} */
|
460
465
|
const hidden = hiddenExports !== undefined ? new Set() : undefined;
|
461
466
|
|
462
467
|
if (noExtraImports) {
|
@@ -468,7 +473,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
468
473
|
importedExportsInfo.getReadOnlyExportInfo(name);
|
469
474
|
if (importedExportInfo.provided === false) continue;
|
470
475
|
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
471
|
-
|
476
|
+
/** @type {Set<string>} */
|
477
|
+
(hidden).add(name);
|
472
478
|
continue;
|
473
479
|
}
|
474
480
|
exports.add(name);
|
@@ -483,7 +489,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
483
489
|
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
484
490
|
if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;
|
485
491
|
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
486
|
-
|
492
|
+
/** @type {Set<string>} */
|
493
|
+
(hidden).add(name);
|
487
494
|
continue;
|
488
495
|
}
|
489
496
|
exports.add(name);
|
@@ -497,7 +504,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
497
504
|
|
498
505
|
/**
|
499
506
|
* @param {ModuleGraph} moduleGraph module graph
|
500
|
-
* @returns {null | false |
|
507
|
+
* @returns {null | false | GetConditionFn} function to determine if the connection is active
|
501
508
|
*/
|
502
509
|
getCondition(moduleGraph) {
|
503
510
|
return (connection, runtime) => {
|
@@ -633,7 +640,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
633
640
|
case "missing":
|
634
641
|
return undefined;
|
635
642
|
case "dynamic-reexport": {
|
636
|
-
const from =
|
643
|
+
const from =
|
644
|
+
/** @type {ModuleGraphConnection} */
|
645
|
+
(moduleGraph.getConnection(this));
|
637
646
|
return {
|
638
647
|
exports: true,
|
639
648
|
from,
|
@@ -649,11 +658,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
649
658
|
return {
|
650
659
|
exports: [],
|
651
660
|
hideExports: mode.hidden,
|
652
|
-
dependencies: [moduleGraph.getModule(this)]
|
661
|
+
dependencies: [/** @type {Module} */ (moduleGraph.getModule(this))]
|
653
662
|
};
|
654
663
|
// falls through
|
655
664
|
case "normal-reexport": {
|
656
|
-
const from =
|
665
|
+
const from =
|
666
|
+
/** @type {ModuleGraphConnection} */
|
667
|
+
(moduleGraph.getConnection(this));
|
657
668
|
return {
|
658
669
|
exports: Array.from(mode.items, item => ({
|
659
670
|
name: item.name,
|
@@ -667,11 +678,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
667
678
|
}
|
668
679
|
case "reexport-dynamic-default": {
|
669
680
|
{
|
670
|
-
const from =
|
681
|
+
const from =
|
682
|
+
/** @type {ModuleGraphConnection} */
|
683
|
+
(moduleGraph.getConnection(this));
|
671
684
|
return {
|
672
685
|
exports: [
|
673
686
|
{
|
674
|
-
name: mode.name,
|
687
|
+
name: /** @type {string} */ (mode.name),
|
675
688
|
from,
|
676
689
|
export: ["default"]
|
677
690
|
}
|
@@ -683,15 +696,17 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
683
696
|
}
|
684
697
|
case "reexport-undefined":
|
685
698
|
return {
|
686
|
-
exports: [mode.name],
|
687
|
-
dependencies: [moduleGraph.getModule(this)]
|
699
|
+
exports: [/** @type {string} */ (mode.name)],
|
700
|
+
dependencies: [/** @type {Module} */ (moduleGraph.getModule(this))]
|
688
701
|
};
|
689
702
|
case "reexport-fake-namespace-object": {
|
690
|
-
const from =
|
703
|
+
const from =
|
704
|
+
/** @type {ModuleGraphConnection} */
|
705
|
+
(moduleGraph.getConnection(this));
|
691
706
|
return {
|
692
707
|
exports: [
|
693
708
|
{
|
694
|
-
name: mode.name,
|
709
|
+
name: /** @type {string} */ (mode.name),
|
695
710
|
from,
|
696
711
|
export: null,
|
697
712
|
exports: [
|
@@ -709,11 +724,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
709
724
|
};
|
710
725
|
}
|
711
726
|
case "reexport-namespace-object": {
|
712
|
-
const from =
|
727
|
+
const from =
|
728
|
+
/** @type {ModuleGraphConnection} */
|
729
|
+
(moduleGraph.getConnection(this));
|
713
730
|
return {
|
714
731
|
exports: [
|
715
732
|
{
|
716
|
-
name: mode.name,
|
733
|
+
name: /** @type {string} */ (mode.name),
|
717
734
|
from,
|
718
735
|
export: null
|
719
736
|
}
|
@@ -723,11 +740,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
723
740
|
};
|
724
741
|
}
|
725
742
|
case "reexport-named-default": {
|
726
|
-
const from =
|
743
|
+
const from =
|
744
|
+
/** @type {ModuleGraphConnection} */
|
745
|
+
(moduleGraph.getConnection(this));
|
727
746
|
return {
|
728
747
|
exports: [
|
729
748
|
{
|
730
|
-
name: mode.name,
|
749
|
+
name: /** @type {string} */ (mode.name),
|
731
750
|
from,
|
732
751
|
export: ["default"]
|
733
752
|
}
|
@@ -748,7 +767,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
748
767
|
_getEffectiveExportPresenceLevel(moduleGraph) {
|
749
768
|
if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
|
750
769
|
return this.exportPresenceMode;
|
751
|
-
|
770
|
+
const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
|
771
|
+
return /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule
|
752
772
|
? ExportPresenceModes.ERROR
|
753
773
|
: ExportPresenceModes.WARN;
|
754
774
|
}
|
@@ -826,7 +846,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
826
846
|
);
|
827
847
|
if (conflictingModule === importedModule) continue;
|
828
848
|
const conflictingExportInfo = moduleGraph.getExportInfo(
|
829
|
-
conflictingModule,
|
849
|
+
/** @type {Module} */ (conflictingModule),
|
830
850
|
exportInfo.name
|
831
851
|
);
|
832
852
|
const conflictingTarget =
|
@@ -948,14 +968,14 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
948
968
|
}
|
949
969
|
|
950
970
|
/**
|
951
|
-
* @param {InitFragment[]} initFragments target array for init fragments
|
971
|
+
* @param {InitFragment<GenerateContext>[]} initFragments target array for init fragments
|
952
972
|
* @param {HarmonyExportImportedSpecifierDependency} dep dependency
|
953
973
|
* @param {ExportMode} mode the export mode
|
954
974
|
* @param {Module} module the current module
|
955
975
|
* @param {ModuleGraph} moduleGraph the module graph
|
956
976
|
* @param {RuntimeSpec} runtime the runtime
|
957
977
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
958
|
-
* @param {
|
978
|
+
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
959
979
|
* @returns {void}
|
960
980
|
*/
|
961
981
|
_addExportFragments(
|
@@ -968,7 +988,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
968
988
|
runtimeTemplate,
|
969
989
|
runtimeRequirements
|
970
990
|
) {
|
971
|
-
const importedModule = moduleGraph.getModule(dep);
|
991
|
+
const importedModule = /** @type {Module} */ (moduleGraph.getModule(dep));
|
972
992
|
const importVar = dep.getImportVar(moduleGraph);
|
973
993
|
|
974
994
|
switch (mode.type) {
|
@@ -1169,6 +1189,14 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1169
1189
|
return new HarmonyExportInitFragment(module.exportsArgument, map);
|
1170
1190
|
}
|
1171
1191
|
|
1192
|
+
/**
|
1193
|
+
* @param {Module} module module
|
1194
|
+
* @param {string | string[] | false} key key
|
1195
|
+
* @param {string} name name
|
1196
|
+
* @param {number} fakeType fake type
|
1197
|
+
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
1198
|
+
* @returns {[InitFragment<GenerateContext>, HarmonyExportInitFragment]} init fragments
|
1199
|
+
*/
|
1172
1200
|
getReexportFakeNamespaceObjectFragments(
|
1173
1201
|
module,
|
1174
1202
|
key,
|
@@ -1199,6 +1227,14 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1199
1227
|
];
|
1200
1228
|
}
|
1201
1229
|
|
1230
|
+
/**
|
1231
|
+
* @param {Module} module module
|
1232
|
+
* @param {string} key key
|
1233
|
+
* @param {string} name name
|
1234
|
+
* @param {string | string[] | false} valueKey value key
|
1235
|
+
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
1236
|
+
* @returns {string} result
|
1237
|
+
*/
|
1202
1238
|
getConditionalReexportStatement(
|
1203
1239
|
module,
|
1204
1240
|
key,
|
@@ -1226,6 +1262,11 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1226
1262
|
)}: function() { return ${returnValue}; } });\n`;
|
1227
1263
|
}
|
1228
1264
|
|
1265
|
+
/**
|
1266
|
+
* @param {string} name name
|
1267
|
+
* @param {null | false | string | string[]} valueKey value key
|
1268
|
+
* @returns {string | undefined} value
|
1269
|
+
*/
|
1229
1270
|
getReturnValue(name, valueKey) {
|
1230
1271
|
if (valueKey === null) {
|
1231
1272
|
return `${name}_default.a`;
|
@@ -13,6 +13,10 @@ const { propertyName } = require("../util/propertyName");
|
|
13
13
|
/** @typedef {import("webpack-sources").Source} Source */
|
14
14
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
15
15
|
|
16
|
+
/**
|
17
|
+
* @param {Iterable<string>} iterable iterable strings
|
18
|
+
* @returns {string} result
|
19
|
+
*/
|
16
20
|
const joinIterableWithComma = iterable => {
|
17
21
|
// This is more performant than Array.from().join(", ")
|
18
22
|
// as it doesn't create an array
|
@@ -33,7 +37,7 @@ const EMPTY_MAP = new Map();
|
|
33
37
|
const EMPTY_SET = new Set();
|
34
38
|
|
35
39
|
/**
|
36
|
-
* @
|
40
|
+
* @extends {InitFragment<GenerateContext>} Context
|
37
41
|
*/
|
38
42
|
class HarmonyExportInitFragment extends InitFragment {
|
39
43
|
/**
|
@@ -99,6 +103,10 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
99
103
|
);
|
100
104
|
}
|
101
105
|
|
106
|
+
/**
|
107
|
+
* @param {HarmonyExportInitFragment} other other
|
108
|
+
* @returns {HarmonyExportInitFragment} merged result
|
109
|
+
*/
|
102
110
|
merge(other) {
|
103
111
|
let exportMap;
|
104
112
|
if (this.exportMap.size === 0) {
|
@@ -131,7 +139,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
131
139
|
|
132
140
|
/**
|
133
141
|
* @param {GenerateContext} context context
|
134
|
-
* @returns {string | Source} the source code that will be included as initialization code
|
142
|
+
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
135
143
|
*/
|
136
144
|
getContent({ runtimeTemplate, runtimeRequirements }) {
|
137
145
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
@@ -20,11 +20,13 @@ const ModuleDependency = require("./ModuleDependency");
|
|
20
20
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
21
21
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
22
22
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
23
|
+
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
23
24
|
/** @typedef {import("../Module")} Module */
|
25
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
24
26
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
25
27
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
26
28
|
/** @typedef {import("../WebpackError")} WebpackError */
|
27
|
-
/** @typedef {import("../javascript/JavascriptParser").
|
29
|
+
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
28
30
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
29
31
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
30
32
|
/** @typedef {import("../util/Hash")} Hash */
|
@@ -35,6 +37,10 @@ const ExportPresenceModes = {
|
|
35
37
|
WARN: /** @type {1} */ (1),
|
36
38
|
AUTO: /** @type {2} */ (2),
|
37
39
|
ERROR: /** @type {3} */ (3),
|
40
|
+
/**
|
41
|
+
* @param {string | false} str param
|
42
|
+
* @returns {0 | 1 | 2 | 3} result
|
43
|
+
*/
|
38
44
|
fromUserOption(str) {
|
39
45
|
switch (str) {
|
40
46
|
case "error":
|
@@ -56,12 +62,12 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
56
62
|
*
|
57
63
|
* @param {string} request request string
|
58
64
|
* @param {number} sourceOrder source order
|
59
|
-
* @param {
|
65
|
+
* @param {ImportAttributes=} attributes import attributes
|
60
66
|
*/
|
61
|
-
constructor(request, sourceOrder,
|
67
|
+
constructor(request, sourceOrder, attributes) {
|
62
68
|
super(request);
|
63
69
|
this.sourceOrder = sourceOrder;
|
64
|
-
this.assertions =
|
70
|
+
this.assertions = attributes;
|
65
71
|
}
|
66
72
|
|
67
73
|
get category() {
|
@@ -84,15 +90,20 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
84
90
|
*/
|
85
91
|
getImportVar(moduleGraph) {
|
86
92
|
const module = moduleGraph.getParentModule(this);
|
87
|
-
const meta = moduleGraph.getMeta(module);
|
93
|
+
const meta = /** @type {TODO} */ (moduleGraph.getMeta(module));
|
88
94
|
let importVarMap = meta.importVarMap;
|
89
95
|
if (!importVarMap) meta.importVarMap = importVarMap = new Map();
|
90
|
-
let importVar = importVarMap.get(
|
96
|
+
let importVar = importVarMap.get(
|
97
|
+
/** @type {Module} */ (moduleGraph.getModule(this))
|
98
|
+
);
|
91
99
|
if (importVar) return importVar;
|
92
100
|
importVar = `${Template.toIdentifier(
|
93
101
|
`${this.userRequest}`
|
94
102
|
)}__WEBPACK_IMPORTED_MODULE_${importVarMap.size}__`;
|
95
|
-
importVarMap.set(
|
103
|
+
importVarMap.set(
|
104
|
+
/** @type {Module} */ (moduleGraph.getModule(this)),
|
105
|
+
importVar
|
106
|
+
);
|
96
107
|
return importVar;
|
97
108
|
}
|
98
109
|
|
@@ -107,7 +118,7 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
107
118
|
) {
|
108
119
|
return runtimeTemplate.importStatement({
|
109
120
|
update,
|
110
|
-
module: moduleGraph.getModule(this),
|
121
|
+
module: /** @type {Module} */ (moduleGraph.getModule(this)),
|
111
122
|
chunkGraph,
|
112
123
|
importVar: this.getImportVar(moduleGraph),
|
113
124
|
request: this.request,
|
@@ -129,10 +140,12 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
129
140
|
return;
|
130
141
|
}
|
131
142
|
|
132
|
-
const parentModule =
|
143
|
+
const parentModule =
|
144
|
+
/** @type {Module} */
|
145
|
+
(moduleGraph.getParentModule(this));
|
133
146
|
const exportsType = importedModule.getExportsType(
|
134
147
|
moduleGraph,
|
135
|
-
parentModule.buildMeta.strictHarmonyModule
|
148
|
+
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule
|
136
149
|
);
|
137
150
|
if (exportsType === "namespace" || exportsType === "default-with-named") {
|
138
151
|
if (ids.length === 0) {
|
@@ -170,7 +183,9 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
170
183
|
)
|
171
184
|
];
|
172
185
|
}
|
173
|
-
exportsInfo =
|
186
|
+
exportsInfo =
|
187
|
+
/** @type {ExportsInfo} */
|
188
|
+
(exportInfo.getNestedExportsInfo());
|
174
189
|
}
|
175
190
|
|
176
191
|
// General error message
|
@@ -207,7 +222,8 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
207
222
|
if (
|
208
223
|
ids.length > 0 &&
|
209
224
|
ids[0] !== "default" &&
|
210
|
-
|
225
|
+
/** @type {BuildMeta} */
|
226
|
+
(importedModule.buildMeta).defaultObject === "redirect-warn"
|
211
227
|
) {
|
212
228
|
// For these modules only the default export is supported
|
213
229
|
return [
|
@@ -21,11 +21,16 @@ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDepend
|
|
21
21
|
/** @typedef {import("estree").Identifier} Identifier */
|
22
22
|
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
|
23
23
|
/** @typedef {import("estree").ImportExpression} ImportExpression */
|
24
|
+
/** @typedef {import("estree").Literal} Literal */
|
24
25
|
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
26
|
+
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
27
|
+
/** @typedef {import("estree").Property} Property */
|
25
28
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
26
29
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
27
30
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
28
31
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
32
|
+
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
|
33
|
+
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
29
34
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
30
35
|
/** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */
|
31
36
|
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
|
@@ -34,7 +39,7 @@ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDepend
|
|
34
39
|
const harmonySpecifierTag = Symbol("harmony import");
|
35
40
|
|
36
41
|
/**
|
37
|
-
* @typedef {
|
42
|
+
* @typedef {object} HarmonySettings
|
38
43
|
* @property {string[]} ids
|
39
44
|
* @property {string} source
|
40
45
|
* @property {number} sourceOrder
|
@@ -44,24 +49,68 @@ const harmonySpecifierTag = Symbol("harmony import");
|
|
44
49
|
*/
|
45
50
|
|
46
51
|
/**
|
47
|
-
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ImportExpression} node node with assertions
|
48
|
-
* @returns {
|
52
|
+
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | (ImportExpression & { arguments?: ObjectExpression[] })} node node with assertions
|
53
|
+
* @returns {ImportAttributes} import attributes
|
49
54
|
*/
|
50
|
-
function
|
55
|
+
function getAttributes(node) {
|
56
|
+
if (
|
57
|
+
node.type === "ImportExpression" &&
|
58
|
+
node.arguments &&
|
59
|
+
node.arguments[0] &&
|
60
|
+
node.arguments[0].type === "ObjectExpression" &&
|
61
|
+
node.arguments[0].properties[0] &&
|
62
|
+
node.arguments[0].properties[0].type === "Property" &&
|
63
|
+
node.arguments[0].properties[0].value.type === "ObjectExpression" &&
|
64
|
+
node.arguments[0].properties[0].value.properties
|
65
|
+
) {
|
66
|
+
const properties =
|
67
|
+
/** @type {Property[]} */
|
68
|
+
(node.arguments[0].properties[0].value.properties);
|
69
|
+
const result = /** @type {ImportAttributes} */ ({});
|
70
|
+
for (const property of properties) {
|
71
|
+
const key =
|
72
|
+
/** @type {string} */
|
73
|
+
(
|
74
|
+
property.key.type === "Identifier"
|
75
|
+
? property.key.name
|
76
|
+
: /** @type {Literal} */ (property.key).value
|
77
|
+
);
|
78
|
+
result[key] =
|
79
|
+
/** @type {string} */
|
80
|
+
(/** @type {Literal} */ (property.value).value);
|
81
|
+
}
|
82
|
+
const key =
|
83
|
+
node.arguments[0].properties[0].key.type === "Identifier"
|
84
|
+
? node.arguments[0].properties[0].key.name
|
85
|
+
: /** @type {Literal} */ (node.arguments[0].properties[0].key).value;
|
86
|
+
if (key === "assert") {
|
87
|
+
result._isLegacyAssert = true;
|
88
|
+
}
|
89
|
+
return result;
|
90
|
+
}
|
51
91
|
// TODO remove cast when @types/estree has been updated to import assertions
|
52
|
-
const
|
53
|
-
node
|
54
|
-
|
55
|
-
|
92
|
+
const isImportAssertion =
|
93
|
+
/** @type {{ assertions?: ImportAttributeNode[] }} */ (node).assertions !==
|
94
|
+
undefined;
|
95
|
+
const attributes = isImportAssertion
|
96
|
+
? /** @type {{ assertions?: ImportAttributeNode[] }} */ (node).assertions
|
97
|
+
: /** @type {{ attributes?: ImportAttributeNode[] }} */ (node).attributes;
|
98
|
+
if (attributes === undefined) {
|
56
99
|
return undefined;
|
57
100
|
}
|
58
|
-
const result = {};
|
59
|
-
for (const
|
101
|
+
const result = /** @type {ImportAttributes} */ ({});
|
102
|
+
for (const attribute of attributes) {
|
60
103
|
const key =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
104
|
+
/** @type {string} */
|
105
|
+
(
|
106
|
+
attribute.key.type === "Identifier"
|
107
|
+
? attribute.key.name
|
108
|
+
: attribute.key.value
|
109
|
+
);
|
110
|
+
result[key] = /** @type {string} */ (attribute.value.value);
|
111
|
+
}
|
112
|
+
if (isImportAssertion) {
|
113
|
+
result._isLegacyAssert = true;
|
65
114
|
}
|
66
115
|
return result;
|
67
116
|
}
|
@@ -125,11 +174,11 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
125
174
|
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
|
126
175
|
parser.state.module.addPresentationalDependency(clearDep);
|
127
176
|
parser.unsetAsiPosition(/** @type {Range} */ (statement.range)[1]);
|
128
|
-
const
|
177
|
+
const attributes = getAttributes(statement);
|
129
178
|
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
130
|
-
source,
|
179
|
+
/** @type {string} */ (source),
|
131
180
|
parser.state.lastHarmonyImportOrder,
|
132
|
-
|
181
|
+
attributes
|
133
182
|
);
|
134
183
|
sideEffectDep.loc = /** @type {DependencyLocation} */ (statement.loc);
|
135
184
|
parser.state.module.addDependency(sideEffectDep);
|
@@ -145,7 +194,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
145
194
|
source,
|
146
195
|
ids,
|
147
196
|
sourceOrder: parser.state.lastHarmonyImportOrder,
|
148
|
-
assertions:
|
197
|
+
assertions: getAttributes(statement)
|
149
198
|
});
|
150
199
|
return true;
|
151
200
|
}
|
@@ -368,4 +417,6 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
368
417
|
};
|
369
418
|
|
370
419
|
module.exports.harmonySpecifierTag = harmonySpecifierTag;
|
371
|
-
|
420
|
+
// TODO remove it in webpack@6 in favor getAttributes
|
421
|
+
module.exports.getAssertions = getAttributes;
|
422
|
+
module.exports.getAttributes = getAttributes;
|
@@ -10,23 +10,24 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
10
10
|
|
11
11
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
12
12
|
/** @typedef {import("../Dependency")} Dependency */
|
13
|
+
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
13
14
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
14
15
|
/** @typedef {import("../Module")} Module */
|
15
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
17
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
17
18
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
18
|
-
/** @typedef {import("../javascript/JavascriptParser").
|
19
|
+
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
19
20
|
/** @typedef {import("../util/Hash")} Hash */
|
20
21
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
21
22
|
|
22
23
|
class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
|
23
24
|
/**
|
24
|
-
* @param {
|
25
|
+
* @param {string} request the request string
|
25
26
|
* @param {number} sourceOrder source order
|
26
|
-
* @param {
|
27
|
+
* @param {ImportAttributes=} attributes import attributes
|
27
28
|
*/
|
28
|
-
constructor(request, sourceOrder,
|
29
|
-
super(request, sourceOrder,
|
29
|
+
constructor(request, sourceOrder, attributes) {
|
30
|
+
super(request, sourceOrder, attributes);
|
30
31
|
}
|
31
32
|
|
32
33
|
get type() {
|
@@ -35,7 +36,7 @@ class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
|
|
35
36
|
|
36
37
|
/**
|
37
38
|
* @param {ModuleGraph} moduleGraph module graph
|
38
|
-
* @returns {null | false |
|
39
|
+
* @returns {null | false | GetConditionFn} function to determine if the connection is active
|
39
40
|
*/
|
40
41
|
getCondition(moduleGraph) {
|
41
42
|
return connection => {
|