webpack 5.93.0 → 5.95.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +33 -20
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +75 -68
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +6 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +41 -15
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +130 -69
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +21 -13
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +84 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +93 -81
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +32 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +26 -24
- package/lib/css/CssGenerator.js +9 -4
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +7 -2
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +35 -8
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +7 -7
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +133 -86
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +8 -10
- package/lib/library/EnableLibraryPlugin.js +15 -14
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +8 -6
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +81 -51
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +13 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +8 -11
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +32 -32
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +109 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +18 -17
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +5 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +681 -355
@@ -58,9 +58,9 @@ class CssExportDependency extends NullDependency {
|
|
58
58
|
*/
|
59
59
|
getExports(moduleGraph) {
|
60
60
|
const module = /** @type {CssModule} */ (moduleGraph.getParentModule(this));
|
61
|
-
const convention =
|
62
|
-
|
63
|
-
|
61
|
+
const convention =
|
62
|
+
/** @type {CssGenerator | CssExportsGenerator} */
|
63
|
+
(module.generator).convention;
|
64
64
|
const names = this.getExportsConventionNames(this.name, convention);
|
65
65
|
return {
|
66
66
|
exports: names.map(name => ({
|
@@ -81,14 +81,14 @@ class CssExportDependency extends NullDependency {
|
|
81
81
|
const module = /** @type {CssModule} */ (
|
82
82
|
chunkGraph.moduleGraph.getParentModule(this)
|
83
83
|
);
|
84
|
-
const generator =
|
85
|
-
|
86
|
-
|
84
|
+
const generator =
|
85
|
+
/** @type {CssGenerator | CssExportsGenerator} */
|
86
|
+
(module.generator);
|
87
87
|
const names = this.getExportsConventionNames(
|
88
88
|
this.name,
|
89
89
|
generator.convention
|
90
90
|
);
|
91
|
-
hash.update(
|
91
|
+
hash.update("exportsConvention");
|
92
92
|
hash.update(JSON.stringify(names));
|
93
93
|
}
|
94
94
|
|
@@ -26,9 +26,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
26
26
|
class CssImportDependency extends ModuleDependency {
|
27
27
|
/**
|
28
28
|
* Example of dependency:
|
29
|
-
*
|
30
29
|
* \@import url("landscape.css") layer(forms) screen and (orientation: landscape) screen and (orientation: landscape);
|
31
|
-
*
|
32
30
|
* @param {string} request request
|
33
31
|
* @param {Range} range range of the argument
|
34
32
|
* @param {string | undefined} layer layer
|
@@ -141,9 +141,9 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
141
141
|
this.name,
|
142
142
|
generator.convention
|
143
143
|
);
|
144
|
-
hash.update(
|
144
|
+
hash.update("exportsConvention");
|
145
145
|
hash.update(JSON.stringify(names));
|
146
|
-
hash.update(
|
146
|
+
hash.update("localIdentName");
|
147
147
|
hash.update(generator.localIdentName);
|
148
148
|
}
|
149
149
|
|
@@ -178,7 +178,7 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
178
178
|
const escapeCssIdentifier = (str, omitUnderscore) => {
|
179
179
|
const escaped = `${str}`.replace(
|
180
180
|
// cspell:word uffff
|
181
|
-
/[^a-zA-Z0-9_\u0081-\
|
181
|
+
/[^a-zA-Z0-9_\u0081-\uFFFF-]/g,
|
182
182
|
s => `\\${s}`
|
183
183
|
);
|
184
184
|
return !omitUnderscore && /^(?!--)[0-9-]/.test(escaped)
|
@@ -43,8 +43,9 @@ class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
|
43
43
|
* @returns {string | null} an identifier to merge equal requests
|
44
44
|
*/
|
45
45
|
getResourceIdentifier() {
|
46
|
-
return
|
46
|
+
return "self";
|
47
47
|
}
|
48
|
+
|
48
49
|
/**
|
49
50
|
* Returns the exported names
|
50
51
|
* @param {ModuleGraph} moduleGraph module graph
|
@@ -25,9 +25,9 @@ const ModuleDependency = require("./ModuleDependency");
|
|
25
25
|
/** @typedef {import("../util/Hash")} Hash */
|
26
26
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
27
27
|
|
28
|
-
const getIgnoredRawDataUrlModule = memoize(
|
29
|
-
|
30
|
-
|
28
|
+
const getIgnoredRawDataUrlModule = memoize(
|
29
|
+
() => new RawDataUrlModule("data:,", "ignored-asset", "(ignored asset)")
|
30
|
+
);
|
31
31
|
|
32
32
|
class CssUrlDependency extends ModuleDependency {
|
33
33
|
/**
|
@@ -106,9 +106,8 @@ const cssEscapeString = str => {
|
|
106
106
|
return str.replace(/[\n\t ()'"\\]/g, m => `\\${m}`);
|
107
107
|
} else if (countQuotation <= countApostrophe) {
|
108
108
|
return `"${str.replace(/[\n"\\]/g, m => `\\${m}`)}"`;
|
109
|
-
} else {
|
110
|
-
return `'${str.replace(/[\n'\\]/g, m => `\\${m}`)}'`;
|
111
109
|
}
|
110
|
+
return `'${str.replace(/[\n'\\]/g, m => `\\${m}`)}'`;
|
112
111
|
};
|
113
112
|
|
114
113
|
CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
@@ -15,7 +15,7 @@ const parserStateExportsState = new WeakMap();
|
|
15
15
|
* @param {ParserState} parserState parser state
|
16
16
|
* @returns {void}
|
17
17
|
*/
|
18
|
-
exports.bailout = parserState => {
|
18
|
+
module.exports.bailout = parserState => {
|
19
19
|
const value = parserStateExportsState.get(parserState);
|
20
20
|
parserStateExportsState.set(parserState, false);
|
21
21
|
if (value === true) {
|
@@ -29,7 +29,7 @@ exports.bailout = parserState => {
|
|
29
29
|
* @param {ParserState} parserState parser state
|
30
30
|
* @returns {void}
|
31
31
|
*/
|
32
|
-
exports.enable = parserState => {
|
32
|
+
module.exports.enable = parserState => {
|
33
33
|
const value = parserStateExportsState.get(parserState);
|
34
34
|
if (value === false) return;
|
35
35
|
parserStateExportsState.set(parserState, true);
|
@@ -44,7 +44,7 @@ exports.enable = parserState => {
|
|
44
44
|
* @param {ParserState} parserState parser state
|
45
45
|
* @returns {void}
|
46
46
|
*/
|
47
|
-
exports.setFlagged = parserState => {
|
47
|
+
module.exports.setFlagged = parserState => {
|
48
48
|
const value = parserStateExportsState.get(parserState);
|
49
49
|
if (value !== true) return;
|
50
50
|
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
@@ -56,7 +56,7 @@ exports.setFlagged = parserState => {
|
|
56
56
|
* @param {ParserState} parserState parser state
|
57
57
|
* @returns {void}
|
58
58
|
*/
|
59
|
-
exports.setDynamic = parserState => {
|
59
|
+
module.exports.setDynamic = parserState => {
|
60
60
|
const value = parserStateExportsState.get(parserState);
|
61
61
|
if (value !== true) return;
|
62
62
|
/** @type {BuildMeta} */
|
@@ -67,7 +67,7 @@ exports.setDynamic = parserState => {
|
|
67
67
|
* @param {ParserState} parserState parser state
|
68
68
|
* @returns {boolean} true, when enabled
|
69
69
|
*/
|
70
|
-
exports.isEnabled = parserState => {
|
70
|
+
module.exports.isEnabled = parserState => {
|
71
71
|
const value = parserStateExportsState.get(parserState);
|
72
72
|
return value === true;
|
73
73
|
};
|
@@ -72,7 +72,7 @@ const getProperty = (moduleGraph, module, _exportName, property, runtime) => {
|
|
72
72
|
case UsageState.Unused:
|
73
73
|
return false;
|
74
74
|
case UsageState.NoInfo:
|
75
|
-
return
|
75
|
+
return;
|
76
76
|
case UsageState.Unknown:
|
77
77
|
return null;
|
78
78
|
default:
|
@@ -82,7 +82,6 @@ const getProperty = (moduleGraph, module, _exportName, property, runtime) => {
|
|
82
82
|
case "provideInfo":
|
83
83
|
return moduleGraph.getExportsInfo(module).isExportProvided(exportName);
|
84
84
|
}
|
85
|
-
return undefined;
|
86
85
|
};
|
87
86
|
|
88
87
|
class ExportsInfoDependency extends NullDependency {
|
@@ -112,11 +112,10 @@ HarmonyEvaluatedImportSpecifierDependency.Template = class HarmonyEvaluatedImpor
|
|
112
112
|
break;
|
113
113
|
}
|
114
114
|
case "namespace": {
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
115
|
+
value =
|
116
|
+
ids[0] === "__esModule"
|
117
|
+
? ids.length === 1 || undefined
|
118
|
+
: exportsInfo.isExportProvided(ids);
|
120
119
|
break;
|
121
120
|
}
|
122
121
|
case "dynamic": {
|
@@ -145,30 +145,34 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
145
145
|
"HarmonyExportDependencyParserPlugin",
|
146
146
|
(statement, id, name, idx) => {
|
147
147
|
const settings = parser.getTagData(id, harmonySpecifierTag);
|
148
|
-
let dep;
|
149
148
|
const harmonyNamedExports = (parser.state.harmonyNamedExports =
|
150
149
|
parser.state.harmonyNamedExports || new Set());
|
151
150
|
harmonyNamedExports.add(name);
|
152
151
|
InnerGraph.addVariableUsage(parser, id, name);
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
dep = new HarmonyExportSpecifierDependency(id, name);
|
167
|
-
}
|
152
|
+
const dep = settings
|
153
|
+
? new HarmonyExportImportedSpecifierDependency(
|
154
|
+
settings.source,
|
155
|
+
settings.sourceOrder,
|
156
|
+
settings.ids,
|
157
|
+
name,
|
158
|
+
harmonyNamedExports,
|
159
|
+
null,
|
160
|
+
exportPresenceMode,
|
161
|
+
null,
|
162
|
+
settings.assertions
|
163
|
+
)
|
164
|
+
: new HarmonyExportSpecifierDependency(id, name);
|
168
165
|
dep.loc = Object.create(
|
169
166
|
/** @type {DependencyLocation} */ (statement.loc)
|
170
167
|
);
|
171
168
|
dep.loc.index = idx;
|
169
|
+
const isAsiSafe = !parser.isAsiPosition(
|
170
|
+
/** @type {Range} */
|
171
|
+
(statement.range)[0]
|
172
|
+
);
|
173
|
+
if (!isAsiSafe) {
|
174
|
+
parser.setAsiPosition(/** @type {Range} */ (statement.range)[1]);
|
175
|
+
}
|
172
176
|
parser.state.current.addDependency(dep);
|
173
177
|
return true;
|
174
178
|
}
|
@@ -202,6 +206,13 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
202
206
|
/** @type {DependencyLocation} */ (statement.loc)
|
203
207
|
);
|
204
208
|
dep.loc.index = idx;
|
209
|
+
const isAsiSafe = !parser.isAsiPosition(
|
210
|
+
/** @type {Range} */
|
211
|
+
(statement.range)[0]
|
212
|
+
);
|
213
|
+
if (!isAsiSafe) {
|
214
|
+
parser.setAsiPosition(/** @type {Range} */ (statement.range)[1]);
|
215
|
+
}
|
205
216
|
parser.state.current.addDependency(dep);
|
206
217
|
return true;
|
207
218
|
}
|
@@ -193,7 +193,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
193
193
|
source.replace(
|
194
194
|
dep.rangeStatement[0],
|
195
195
|
dep.range[0] - 1,
|
196
|
-
content
|
196
|
+
`${content}(${dep.prefix}`
|
197
197
|
);
|
198
198
|
source.replace(dep.range[1], dep.rangeStatement[1] - 0.5, ");");
|
199
199
|
return;
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const ConditionalInitFragment = require("../ConditionalInitFragment");
|
8
9
|
const Dependency = require("../Dependency");
|
9
10
|
const { UsageState } = require("../ExportsInfo");
|
10
11
|
const HarmonyLinkingError = require("../HarmonyLinkingError");
|
@@ -16,7 +17,11 @@ const { first, combine } = require("../util/SetHelpers");
|
|
16
17
|
const makeSerializable = require("../util/makeSerializable");
|
17
18
|
const propertyAccess = require("../util/propertyAccess");
|
18
19
|
const { propertyName } = require("../util/propertyName");
|
19
|
-
const {
|
20
|
+
const {
|
21
|
+
getRuntimeKey,
|
22
|
+
keyToRuntime,
|
23
|
+
filterRuntime
|
24
|
+
} = require("../util/runtime");
|
20
25
|
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
21
26
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
22
27
|
const processExportInfo = require("./processExportInfo");
|
@@ -31,6 +36,7 @@ const processExportInfo = require("./processExportInfo");
|
|
31
36
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
32
37
|
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
33
38
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
39
|
+
/** @typedef {import("../ExportsInfo").UsedName} UsedName */
|
34
40
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
35
41
|
/** @typedef {import("../Module")} Module */
|
36
42
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
@@ -45,6 +51,7 @@ const processExportInfo = require("./processExportInfo");
|
|
45
51
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
46
52
|
/** @typedef {import("../util/Hash")} Hash */
|
47
53
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
54
|
+
/** @typedef {import("./processExportInfo").ReferencedExports} ReferencedExports */
|
48
55
|
|
49
56
|
/** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
|
50
57
|
|
@@ -69,6 +76,9 @@ class NormalReexportItem {
|
|
69
76
|
}
|
70
77
|
}
|
71
78
|
|
79
|
+
/** @typedef {Set<string>} ExportModeIgnored */
|
80
|
+
/** @typedef {Set<string>} ExportModeHidden */
|
81
|
+
|
72
82
|
class ExportMode {
|
73
83
|
/**
|
74
84
|
* @param {ExportModeType} type type of the mode
|
@@ -88,11 +98,11 @@ class ExportMode {
|
|
88
98
|
this.partialNamespaceExportInfo = null;
|
89
99
|
|
90
100
|
// for "dynamic-reexport":
|
91
|
-
/** @type {
|
101
|
+
/** @type {ExportModeIgnored | null} */
|
92
102
|
this.ignored = null;
|
93
103
|
|
94
104
|
// for "dynamic-reexport" | "empty-star":
|
95
|
-
/** @type {
|
105
|
+
/** @type {ExportModeHidden | null} */
|
96
106
|
this.hidden = null;
|
97
107
|
|
98
108
|
// for "missing":
|
@@ -306,7 +316,8 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
306
316
|
exportName,
|
307
317
|
[exportName],
|
308
318
|
exportsInfo.getReadOnlyExportInfo(exportName),
|
309
|
-
|
319
|
+
/** @type {Set<string>} */
|
320
|
+
(checked).has(exportName),
|
310
321
|
false
|
311
322
|
)
|
312
323
|
);
|
@@ -327,11 +338,17 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|
327
338
|
return mode;
|
328
339
|
};
|
329
340
|
|
341
|
+
/** @typedef {string[]} Ids */
|
342
|
+
/** @typedef {Set<string>} Exports */
|
343
|
+
/** @typedef {Set<string>} Checked */
|
344
|
+
/** @typedef {Set<string>} Hidden */
|
345
|
+
/** @typedef {Set<string>} IgnoredExports */
|
346
|
+
|
330
347
|
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
331
348
|
/**
|
332
349
|
* @param {string} request the request string
|
333
350
|
* @param {number} sourceOrder the order in the original source file
|
334
|
-
* @param {
|
351
|
+
* @param {Ids} ids the requested export name of the imported module
|
335
352
|
* @param {string | null} name the export name of for this module
|
336
353
|
* @param {Set<string>} activeExports other named exports in the module
|
337
354
|
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency> | null} otherStarExports other star exports in the module before this import
|
@@ -388,7 +405,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
388
405
|
|
389
406
|
/**
|
390
407
|
* @param {ModuleGraph} moduleGraph the module graph
|
391
|
-
* @returns {
|
408
|
+
* @returns {Ids} the imported id
|
392
409
|
*/
|
393
410
|
getIds(moduleGraph) {
|
394
411
|
return moduleGraph.getMeta(this)[idsSymbol] || this.ids;
|
@@ -396,7 +413,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
396
413
|
|
397
414
|
/**
|
398
415
|
* @param {ModuleGraph} moduleGraph the module graph
|
399
|
-
* @param {
|
416
|
+
* @param {Ids} ids the imported ids
|
400
417
|
* @returns {void}
|
401
418
|
*/
|
402
419
|
setIds(moduleGraph, ids) {
|
@@ -421,7 +438,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
421
438
|
* @param {RuntimeSpec} runtime the runtime
|
422
439
|
* @param {ExportsInfo} exportsInfo exports info about the current module (optional)
|
423
440
|
* @param {Module} importedModule the imported module (optional)
|
424
|
-
* @returns {{exports?:
|
441
|
+
* @returns {{exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden}} information
|
425
442
|
*/
|
426
443
|
getStarReexports(
|
427
444
|
moduleGraph,
|
@@ -439,7 +456,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
439
456
|
|
440
457
|
const ignoredExports = new Set(["default", ...this.activeExports]);
|
441
458
|
|
442
|
-
let hiddenExports
|
459
|
+
let hiddenExports;
|
443
460
|
const otherStarExports =
|
444
461
|
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
|
445
462
|
if (otherStarExports !== undefined) {
|
@@ -457,11 +474,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
457
474
|
};
|
458
475
|
}
|
459
476
|
|
460
|
-
/** @type {
|
477
|
+
/** @type {Exports} */
|
461
478
|
const exports = new Set();
|
462
|
-
/** @type {
|
479
|
+
/** @type {Checked} */
|
463
480
|
const checked = new Set();
|
464
|
-
/** @type {
|
481
|
+
/** @type {Hidden | undefined} */
|
465
482
|
const hidden = hiddenExports !== undefined ? new Set() : undefined;
|
466
483
|
|
467
484
|
if (noExtraImports) {
|
@@ -489,7 +506,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
489
506
|
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
490
507
|
if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;
|
491
508
|
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
492
|
-
/** @type {
|
509
|
+
/** @type {ExportModeHidden} */
|
493
510
|
(hidden).add(name);
|
494
511
|
continue;
|
495
512
|
}
|
@@ -543,7 +560,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
543
560
|
case "reexport-named-default": {
|
544
561
|
if (!mode.partialNamespaceExportInfo)
|
545
562
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
546
|
-
/** @type {
|
563
|
+
/** @type {ReferencedExports} */
|
547
564
|
const referencedExports = [];
|
548
565
|
processExportInfo(
|
549
566
|
runtime,
|
@@ -558,7 +575,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
558
575
|
case "reexport-fake-namespace-object": {
|
559
576
|
if (!mode.partialNamespaceExportInfo)
|
560
577
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
561
|
-
/** @type {
|
578
|
+
/** @type {ReferencedExports} */
|
562
579
|
const referencedExports = [];
|
563
580
|
processExportInfo(
|
564
581
|
runtime,
|
@@ -574,6 +591,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
574
591
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
575
592
|
|
576
593
|
case "normal-reexport": {
|
594
|
+
/** @type {ReferencedExports} */
|
577
595
|
const referencedExports = [];
|
578
596
|
for (const { ids, exportInfo, hidden } of mode.items) {
|
579
597
|
if (hidden) continue;
|
@@ -592,13 +610,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
592
610
|
* @returns {{ names: string[], namesSlice: number, dependencyIndices: number[], dependencyIndex: number } | undefined} exported names and their origin dependency
|
593
611
|
*/
|
594
612
|
_discoverActiveExportsFromOtherStarExports(moduleGraph) {
|
595
|
-
if (!this.otherStarExports) return
|
613
|
+
if (!this.otherStarExports) return;
|
596
614
|
|
597
615
|
const i =
|
598
616
|
"length" in this.otherStarExports
|
599
617
|
? this.otherStarExports.length
|
600
618
|
: countIterable(this.otherStarExports);
|
601
|
-
if (i === 0) return
|
619
|
+
if (i === 0) return;
|
602
620
|
|
603
621
|
if (this.allStarExports) {
|
604
622
|
const { names, dependencyIndices } = moduleGraph.cached(
|
@@ -638,7 +656,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
638
656
|
|
639
657
|
switch (mode.type) {
|
640
658
|
case "missing":
|
641
|
-
return
|
659
|
+
return;
|
642
660
|
case "dynamic-reexport": {
|
643
661
|
const from =
|
644
662
|
/** @type {ModuleGraphConnection} */
|
@@ -648,8 +666,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
648
666
|
from,
|
649
667
|
canMangle: false,
|
650
668
|
excludeExports: mode.hidden
|
651
|
-
? combine(
|
652
|
-
|
669
|
+
? combine(
|
670
|
+
/** @type {ExportModeIgnored} */ (mode.ignored),
|
671
|
+
mode.hidden
|
672
|
+
)
|
673
|
+
: /** @type {ExportModeIgnored} */ (mode.ignored),
|
653
674
|
hideExports: mode.hidden,
|
654
675
|
dependencies: [from.module]
|
655
676
|
};
|
@@ -677,22 +698,20 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
677
698
|
};
|
678
699
|
}
|
679
700
|
case "reexport-dynamic-default": {
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
{
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
};
|
695
|
-
}
|
701
|
+
const from =
|
702
|
+
/** @type {ModuleGraphConnection} */
|
703
|
+
(moduleGraph.getConnection(this));
|
704
|
+
return {
|
705
|
+
exports: [
|
706
|
+
{
|
707
|
+
name: /** @type {string} */ (mode.name),
|
708
|
+
from,
|
709
|
+
export: ["default"]
|
710
|
+
}
|
711
|
+
],
|
712
|
+
priority: 1,
|
713
|
+
dependencies: [from.module]
|
714
|
+
};
|
696
715
|
}
|
697
716
|
case "reexport-undefined":
|
698
717
|
return {
|
@@ -825,6 +844,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
825
844
|
const importedModule = moduleGraph.getModule(this);
|
826
845
|
if (importedModule) {
|
827
846
|
const exportsInfo = moduleGraph.getExportsInfo(importedModule);
|
847
|
+
/** @type {Map<string, string[]>} */
|
828
848
|
const conflicts = new Map();
|
829
849
|
for (const exportInfo of exportsInfo.orderedExports) {
|
830
850
|
if (exportInfo.provided !== true) continue;
|
@@ -841,12 +861,12 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
841
861
|
if (!conflictingDependency) continue;
|
842
862
|
const target = exportInfo.getTerminalBinding(moduleGraph);
|
843
863
|
if (!target) continue;
|
844
|
-
const conflictingModule =
|
845
|
-
|
846
|
-
|
864
|
+
const conflictingModule =
|
865
|
+
/** @type {Module} */
|
866
|
+
(moduleGraph.getModule(conflictingDependency));
|
847
867
|
if (conflictingModule === importedModule) continue;
|
848
868
|
const conflictingExportInfo = moduleGraph.getExportInfo(
|
849
|
-
|
869
|
+
conflictingModule,
|
850
870
|
exportInfo.name
|
851
871
|
);
|
852
872
|
const conflictingTarget =
|
@@ -944,7 +964,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
944
964
|
switch (mode.type) {
|
945
965
|
case "reexport-undefined":
|
946
966
|
concatenationScope.registerRawExport(
|
947
|
-
mode.name,
|
967
|
+
/** @type {NonNullable<ExportMode["name"]>} */ (mode.name),
|
948
968
|
"/* reexport non-default export from non-harmony */ undefined"
|
949
969
|
);
|
950
970
|
}
|
@@ -1080,23 +1100,36 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1080
1100
|
break;
|
1081
1101
|
|
1082
1102
|
case "normal-reexport":
|
1083
|
-
for (const {
|
1103
|
+
for (const {
|
1104
|
+
name,
|
1105
|
+
ids,
|
1106
|
+
checked,
|
1107
|
+
hidden
|
1108
|
+
} of /** @type {NormalReexportItem[]} */ (mode.items)) {
|
1084
1109
|
if (hidden) continue;
|
1085
1110
|
if (checked) {
|
1111
|
+
const connection = moduleGraph.getConnection(dep);
|
1112
|
+
const key = `harmony reexport (checked) ${importVar} ${name}`;
|
1113
|
+
const runtimeCondition = dep.weak
|
1114
|
+
? false
|
1115
|
+
: connection
|
1116
|
+
? filterRuntime(runtime, r => connection.isTargetActive(r))
|
1117
|
+
: true;
|
1086
1118
|
initFragments.push(
|
1087
|
-
new
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
),
|
1119
|
+
new ConditionalInitFragment(
|
1120
|
+
`/* harmony reexport (checked) */ ${this.getConditionalReexportStatement(
|
1121
|
+
module,
|
1122
|
+
name,
|
1123
|
+
importVar,
|
1124
|
+
ids,
|
1125
|
+
runtimeRequirements
|
1126
|
+
)}`,
|
1096
1127
|
moduleGraph.isAsync(importedModule)
|
1097
1128
|
? InitFragment.STAGE_ASYNC_HARMONY_IMPORTS
|
1098
1129
|
: InitFragment.STAGE_HARMONY_IMPORTS,
|
1099
|
-
dep.sourceOrder
|
1130
|
+
dep.sourceOrder,
|
1131
|
+
key,
|
1132
|
+
runtimeCondition
|
1100
1133
|
)
|
1101
1134
|
);
|
1102
1135
|
} else {
|
@@ -1118,8 +1151,12 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1118
1151
|
|
1119
1152
|
case "dynamic-reexport": {
|
1120
1153
|
const ignored = mode.hidden
|
1121
|
-
? combine(
|
1122
|
-
|
1154
|
+
? combine(
|
1155
|
+
/** @type {ExportModeIgnored} */
|
1156
|
+
(mode.ignored),
|
1157
|
+
mode.hidden
|
1158
|
+
)
|
1159
|
+
: /** @type {ExportModeIgnored} */ (mode.ignored);
|
1123
1160
|
const modern =
|
1124
1161
|
runtimeTemplate.supportsConst() &&
|
1125
1162
|
runtimeTemplate.supportsArrowFunction();
|
@@ -1132,22 +1169,19 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1132
1169
|
// Filter out exports which are defined by other exports
|
1133
1170
|
// and filter out default export because it cannot be reexported with *
|
1134
1171
|
if (ignored.size > 1) {
|
1135
|
-
content +=
|
1136
|
-
|
1137
|
-
|
1138
|
-
".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
1172
|
+
content += `if(${JSON.stringify(
|
1173
|
+
Array.from(ignored)
|
1174
|
+
)}.indexOf(__WEBPACK_IMPORT_KEY__) < 0) `;
|
1139
1175
|
} else if (ignored.size === 1) {
|
1140
1176
|
content += `if(__WEBPACK_IMPORT_KEY__ !== ${JSON.stringify(
|
1141
1177
|
first(ignored)
|
1142
1178
|
)}) `;
|
1143
1179
|
}
|
1144
1180
|
|
1145
|
-
content +=
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
content += `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
1150
|
-
}
|
1181
|
+
content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = ";
|
1182
|
+
content += modern
|
1183
|
+
? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
|
1184
|
+
: `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
1151
1185
|
|
1152
1186
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
1153
1187
|
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
@@ -1170,6 +1204,15 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
1170
1204
|
}
|
1171
1205
|
}
|
1172
1206
|
|
1207
|
+
/**
|
1208
|
+
* @param {Module} module the current module
|
1209
|
+
* @param {string} comment comment
|
1210
|
+
* @param {UsedName} key key
|
1211
|
+
* @param {string} name name
|
1212
|
+
* @param {string | string[] | null | false} valueKey value key
|
1213
|
+
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
1214
|
+
* @returns {HarmonyExportInitFragment} harmony export init fragment
|
1215
|
+
*/
|
1173
1216
|
getReexportFragment(
|
1174
1217
|
module,
|
1175
1218
|
comment,
|
@@ -19,7 +19,7 @@ const parserStateExportsState = new WeakMap();
|
|
19
19
|
* @param {boolean} isStrictHarmony strict harmony mode should be enabled
|
20
20
|
* @returns {void}
|
21
21
|
*/
|
22
|
-
exports.enable = (parserState, isStrictHarmony) => {
|
22
|
+
module.exports.enable = (parserState, isStrictHarmony) => {
|
23
23
|
const value = parserStateExportsState.get(parserState);
|
24
24
|
if (value === false) return;
|
25
25
|
parserStateExportsState.set(parserState, true);
|
@@ -40,7 +40,7 @@ exports.enable = (parserState, isStrictHarmony) => {
|
|
40
40
|
* @param {ParserState} parserState parser state
|
41
41
|
* @returns {boolean} true, when enabled
|
42
42
|
*/
|
43
|
-
exports.isEnabled = parserState => {
|
43
|
+
module.exports.isEnabled = parserState => {
|
44
44
|
const value = parserStateExportsState.get(parserState);
|
45
45
|
return value === true;
|
46
46
|
};
|