@eriche/webpack 4.47.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/LICENSE +20 -0
- package/README.md +784 -0
- package/SECURITY.md +9 -0
- package/bin/webpack.js +171 -0
- package/buildin/amd-define.js +3 -0
- package/buildin/amd-options.js +2 -0
- package/buildin/global.js +20 -0
- package/buildin/harmony-module.js +24 -0
- package/buildin/module.js +22 -0
- package/buildin/system.js +7 -0
- package/declarations/WebpackOptions.d.ts +1466 -0
- package/declarations/plugins/BannerPlugin.d.ts +49 -0
- package/declarations/plugins/DllPlugin.d.ts +32 -0
- package/declarations/plugins/DllReferencePlugin.d.ts +126 -0
- package/declarations/plugins/HashedModuleIdsPlugin.d.ts +24 -0
- package/declarations/plugins/IgnorePlugin.d.ts +27 -0
- package/declarations/plugins/LoaderOptionsPlugin.d.ts +27 -0
- package/declarations/plugins/ProgressPlugin.d.ts +42 -0
- package/declarations/plugins/SourceMapDevToolPlugin.d.ts +94 -0
- package/declarations/plugins/WatchIgnorePlugin.d.ts +10 -0
- package/declarations/plugins/debug/ProfilingPlugin.d.ts +12 -0
- package/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +24 -0
- package/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +16 -0
- package/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +12 -0
- package/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +12 -0
- package/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +12 -0
- package/hot/dev-server.js +61 -0
- package/hot/emitter.js +2 -0
- package/hot/log-apply-result.js +44 -0
- package/hot/log.js +59 -0
- package/hot/only-dev-server.js +102 -0
- package/hot/poll.js +37 -0
- package/hot/signal.js +62 -0
- package/lib/APIPlugin.js +84 -0
- package/lib/AbstractMethodError.js +43 -0
- package/lib/AmdMainTemplatePlugin.js +106 -0
- package/lib/AsyncDependenciesBlock.js +110 -0
- package/lib/AsyncDependencyToInitialChunkError.js +31 -0
- package/lib/AutomaticPrefetchPlugin.js +57 -0
- package/lib/BannerPlugin.js +122 -0
- package/lib/BasicEvaluatedExpression.js +248 -0
- package/lib/CachePlugin.js +100 -0
- package/lib/CaseSensitiveModulesWarning.js +67 -0
- package/lib/Chunk.js +875 -0
- package/lib/ChunkGroup.js +513 -0
- package/lib/ChunkRenderError.js +32 -0
- package/lib/ChunkTemplate.js +87 -0
- package/lib/CommentCompilationWarning.js +32 -0
- package/lib/CommonJsStuffPlugin.js +116 -0
- package/lib/CompatibilityPlugin.js +70 -0
- package/lib/Compilation.js +2327 -0
- package/lib/Compiler.js +735 -0
- package/lib/ConcurrentCompilationError.js +19 -0
- package/lib/ConstPlugin.js +348 -0
- package/lib/ContextExclusionPlugin.js +28 -0
- package/lib/ContextModule.js +872 -0
- package/lib/ContextModuleFactory.js +262 -0
- package/lib/ContextReplacementPlugin.js +133 -0
- package/lib/DefinePlugin.js +289 -0
- package/lib/DelegatedModule.js +114 -0
- package/lib/DelegatedModuleFactoryPlugin.js +95 -0
- package/lib/DelegatedPlugin.js +39 -0
- package/lib/DependenciesBlock.js +124 -0
- package/lib/DependenciesBlockVariable.js +72 -0
- package/lib/Dependency.js +89 -0
- package/lib/DllEntryPlugin.js +54 -0
- package/lib/DllModule.js +60 -0
- package/lib/DllModuleFactory.js +29 -0
- package/lib/DllPlugin.js +49 -0
- package/lib/DllReferencePlugin.js +156 -0
- package/lib/DynamicEntryPlugin.js +94 -0
- package/lib/EntryModuleNotFoundError.js +21 -0
- package/lib/EntryOptionPlugin.js +46 -0
- package/lib/Entrypoint.js +64 -0
- package/lib/EnvironmentPlugin.js +72 -0
- package/lib/ErrorHelpers.js +60 -0
- package/lib/EvalDevToolModulePlugin.js +27 -0
- package/lib/EvalDevToolModuleTemplatePlugin.js +61 -0
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +120 -0
- package/lib/EvalSourceMapDevToolPlugin.js +41 -0
- package/lib/ExportPropertyMainTemplatePlugin.js +53 -0
- package/lib/ExtendedAPIPlugin.js +88 -0
- package/lib/ExternalModule.js +179 -0
- package/lib/ExternalModuleFactoryPlugin.js +110 -0
- package/lib/ExternalsPlugin.js +23 -0
- package/lib/FlagAllModulesAsUsedPlugin.js +38 -0
- package/lib/FlagDependencyExportsPlugin.js +174 -0
- package/lib/FlagDependencyUsagePlugin.js +116 -0
- package/lib/FlagInitialModulesAsUsedPlugin.js +36 -0
- package/lib/FunctionModulePlugin.js +19 -0
- package/lib/FunctionModuleTemplatePlugin.js +102 -0
- package/lib/Generator.js +60 -0
- package/lib/GraphHelpers.js +65 -0
- package/lib/HarmonyLinkingError.js +17 -0
- package/lib/HashedModuleIdsPlugin.js +63 -0
- package/lib/HotModuleReplacement.runtime.js +721 -0
- package/lib/HotModuleReplacementPlugin.js +425 -0
- package/lib/HotUpdateChunk.js +17 -0
- package/lib/HotUpdateChunkTemplate.js +78 -0
- package/lib/IgnorePlugin.js +91 -0
- package/lib/JavascriptGenerator.js +229 -0
- package/lib/JavascriptModulesPlugin.js +185 -0
- package/lib/JsonGenerator.js +57 -0
- package/lib/JsonModulesPlugin.js +30 -0
- package/lib/JsonParser.js +27 -0
- package/lib/LibManifestPlugin.js +90 -0
- package/lib/LibraryTemplatePlugin.js +186 -0
- package/lib/LoaderOptionsPlugin.js +58 -0
- package/lib/LoaderTargetPlugin.js +24 -0
- package/lib/MainTemplate.js +568 -0
- package/lib/MemoryOutputFileSystem.js +5 -0
- package/lib/Module.js +435 -0
- package/lib/ModuleBuildError.js +52 -0
- package/lib/ModuleDependencyError.js +35 -0
- package/lib/ModuleDependencyWarning.js +25 -0
- package/lib/ModuleError.js +36 -0
- package/lib/ModuleFilenameHelpers.js +179 -0
- package/lib/ModuleNotFoundError.js +23 -0
- package/lib/ModuleParseError.js +67 -0
- package/lib/ModuleReason.js +48 -0
- package/lib/ModuleTemplate.js +93 -0
- package/lib/ModuleWarning.js +36 -0
- package/lib/MultiCompiler.js +290 -0
- package/lib/MultiEntryPlugin.js +80 -0
- package/lib/MultiModule.js +87 -0
- package/lib/MultiModuleFactory.js +23 -0
- package/lib/MultiStats.js +92 -0
- package/lib/MultiWatching.js +50 -0
- package/lib/NamedChunksPlugin.js +29 -0
- package/lib/NamedModulesPlugin.js +58 -0
- package/lib/NoEmitOnErrorsPlugin.js +20 -0
- package/lib/NoModeWarning.js +23 -0
- package/lib/NodeStuffPlugin.js +118 -0
- package/lib/NormalModule.js +582 -0
- package/lib/NormalModuleFactory.js +528 -0
- package/lib/NormalModuleReplacementPlugin.js +51 -0
- package/lib/NullFactory.js +12 -0
- package/lib/OptionsApply.js +10 -0
- package/lib/OptionsDefaulter.js +141 -0
- package/lib/Parser.js +2454 -0
- package/lib/ParserHelpers.js +103 -0
- package/lib/PrefetchPlugin.js +37 -0
- package/lib/ProgressPlugin.js +307 -0
- package/lib/ProvidePlugin.js +86 -0
- package/lib/RawModule.js +56 -0
- package/lib/RecordIdsPlugin.js +236 -0
- package/lib/RemovedPluginError.js +11 -0
- package/lib/RequestShortener.js +83 -0
- package/lib/RequireJsStuffPlugin.js +66 -0
- package/lib/ResolverFactory.js +74 -0
- package/lib/RuleSet.js +567 -0
- package/lib/RuntimeTemplate.js +336 -0
- package/lib/SetVarMainTemplatePlugin.js +69 -0
- package/lib/SingleEntryPlugin.js +63 -0
- package/lib/SizeFormatHelpers.js +24 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +49 -0
- package/lib/SourceMapDevToolPlugin.js +418 -0
- package/lib/Stats.js +1685 -0
- package/lib/SystemMainTemplatePlugin.js +137 -0
- package/lib/Template.js +291 -0
- package/lib/TemplatedPathPlugin.js +188 -0
- package/lib/UmdMainTemplatePlugin.js +305 -0
- package/lib/UnsupportedFeatureWarning.js +30 -0
- package/lib/UseStrictPlugin.js +54 -0
- package/lib/WarnCaseSensitiveModulesPlugin.js +37 -0
- package/lib/WarnNoModeSetPlugin.js +17 -0
- package/lib/WatchIgnorePlugin.js +106 -0
- package/lib/Watching.js +211 -0
- package/lib/WebpackError.js +31 -0
- package/lib/WebpackOptionsApply.js +546 -0
- package/lib/WebpackOptionsDefaulter.js +391 -0
- package/lib/WebpackOptionsValidationError.js +390 -0
- package/lib/buildChunkGraph.js +712 -0
- package/lib/compareLocations.js +52 -0
- package/lib/debug/ProfilingPlugin.js +442 -0
- package/lib/dependencies/AMDDefineDependency.js +137 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +336 -0
- package/lib/dependencies/AMDPlugin.js +249 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +49 -0
- package/lib/dependencies/AMDRequireContextDependency.js +20 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +47 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +274 -0
- package/lib/dependencies/AMDRequireDependency.js +135 -0
- package/lib/dependencies/AMDRequireItemDependency.js +22 -0
- package/lib/dependencies/CommonJsPlugin.js +158 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +23 -0
- package/lib/dependencies/CommonJsRequireDependency.js +22 -0
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +138 -0
- package/lib/dependencies/ConstDependency.js +33 -0
- package/lib/dependencies/ContextDependency.js +68 -0
- package/lib/dependencies/ContextDependencyHelpers.js +232 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +43 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +39 -0
- package/lib/dependencies/ContextElementDependency.js +21 -0
- package/lib/dependencies/CriticalDependencyWarning.js +20 -0
- package/lib/dependencies/DelegatedExportsDependency.js +33 -0
- package/lib/dependencies/DelegatedSourceDependency.js +18 -0
- package/lib/dependencies/DependencyReference.js +64 -0
- package/lib/dependencies/DllEntryDependency.js +20 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +48 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +31 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +96 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +154 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +58 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +30 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +659 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +54 -0
- package/lib/dependencies/HarmonyImportDependency.js +109 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +222 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +31 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +163 -0
- package/lib/dependencies/HarmonyInitDependency.js +60 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +143 -0
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +26 -0
- package/lib/dependencies/ImportContextDependency.js +23 -0
- package/lib/dependencies/ImportDependenciesBlock.js +18 -0
- package/lib/dependencies/ImportDependency.js +34 -0
- package/lib/dependencies/ImportEagerDependency.js +32 -0
- package/lib/dependencies/ImportParserPlugin.js +248 -0
- package/lib/dependencies/ImportPlugin.js +79 -0
- package/lib/dependencies/ImportWeakDependency.js +34 -0
- package/lib/dependencies/JsonExportsDependency.js +26 -0
- package/lib/dependencies/LoaderDependency.js +21 -0
- package/lib/dependencies/LoaderPlugin.js +115 -0
- package/lib/dependencies/LocalModule.js +23 -0
- package/lib/dependencies/LocalModuleDependency.js +28 -0
- package/lib/dependencies/LocalModulesHelpers.js +52 -0
- package/lib/dependencies/ModuleDependency.js +23 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +17 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +17 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +23 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +23 -0
- package/lib/dependencies/MultiEntryDependency.js +25 -0
- package/lib/dependencies/NullDependency.js +20 -0
- package/lib/dependencies/PrefetchDependency.js +18 -0
- package/lib/dependencies/RequireContextDependency.js +22 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +56 -0
- package/lib/dependencies/RequireContextPlugin.js +143 -0
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +33 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +116 -0
- package/lib/dependencies/RequireEnsureDependency.js +58 -0
- package/lib/dependencies/RequireEnsureItemDependency.js +21 -0
- package/lib/dependencies/RequireEnsurePlugin.js +74 -0
- package/lib/dependencies/RequireHeaderDependency.js +26 -0
- package/lib/dependencies/RequireIncludeDependency.js +39 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +23 -0
- package/lib/dependencies/RequireIncludePlugin.js +61 -0
- package/lib/dependencies/RequireResolveContextDependency.js +23 -0
- package/lib/dependencies/RequireResolveDependency.js +22 -0
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +86 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +26 -0
- package/lib/dependencies/SingleEntryDependency.js +21 -0
- package/lib/dependencies/SystemPlugin.js +122 -0
- package/lib/dependencies/UnsupportedDependency.js +27 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +31 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +54 -0
- package/lib/dependencies/WebpackMissingModule.js +20 -0
- package/lib/dependencies/getFunctionExpression.js +52 -0
- package/lib/formatLocation.js +75 -0
- package/lib/logging/Logger.js +128 -0
- package/lib/logging/createConsoleLogger.js +210 -0
- package/lib/logging/runtime.js +36 -0
- package/lib/logging/truncateArgs.js +76 -0
- package/lib/node/NodeChunkTemplatePlugin.js +31 -0
- package/lib/node/NodeEnvironmentPlugin.js +44 -0
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -0
- package/lib/node/NodeMainTemplate.runtime.js +32 -0
- package/lib/node/NodeMainTemplateAsync.runtime.js +50 -0
- package/lib/node/NodeMainTemplatePlugin.js +321 -0
- package/lib/node/NodeOutputFileSystem.js +22 -0
- package/lib/node/NodeSourcePlugin.js +141 -0
- package/lib/node/NodeTargetPlugin.js +19 -0
- package/lib/node/NodeTemplatePlugin.js +31 -0
- package/lib/node/NodeWatchFileSystem.js +109 -0
- package/lib/node/ReadFileCompileWasmTemplatePlugin.js +61 -0
- package/lib/node/nodeConsole.js +135 -0
- package/lib/optimize/AggressiveMergingPlugin.js +87 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +294 -0
- package/lib/optimize/ChunkModuleIdRangePlugin.js +66 -0
- package/lib/optimize/ConcatenatedModule.js +1477 -0
- package/lib/optimize/EnsureChunkConditionsPlugin.js +70 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +99 -0
- package/lib/optimize/LimitChunkCountPlugin.js +231 -0
- package/lib/optimize/MergeDuplicateChunksPlugin.js +78 -0
- package/lib/optimize/MinChunkSizePlugin.js +82 -0
- package/lib/optimize/MinMaxSizeWarning.js +29 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +485 -0
- package/lib/optimize/NaturalChunkOrderPlugin.js +41 -0
- package/lib/optimize/OccurrenceChunkOrderPlugin.js +66 -0
- package/lib/optimize/OccurrenceModuleOrderPlugin.js +112 -0
- package/lib/optimize/OccurrenceOrderPlugin.js +135 -0
- package/lib/optimize/RemoveEmptyChunksPlugin.js +42 -0
- package/lib/optimize/RemoveParentModulesPlugin.js +127 -0
- package/lib/optimize/RuntimeChunkPlugin.js +41 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +352 -0
- package/lib/optimize/SplitChunksPlugin.js +971 -0
- package/lib/performance/AssetsOverSizeLimitWarning.js +30 -0
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +30 -0
- package/lib/performance/NoAsyncChunksWarning.js +21 -0
- package/lib/performance/SizeLimitsPlugin.js +125 -0
- package/lib/util/LazyBucketSortedSet.js +235 -0
- package/lib/util/Queue.js +46 -0
- package/lib/util/Semaphore.js +53 -0
- package/lib/util/SetHelpers.js +48 -0
- package/lib/util/SortableSet.js +140 -0
- package/lib/util/StackedSetMap.js +142 -0
- package/lib/util/TrackingSet.js +35 -0
- package/lib/util/cachedMerge.js +35 -0
- package/lib/util/cleverMerge.js +77 -0
- package/lib/util/createHash.js +174 -0
- package/lib/util/deterministicGrouping.js +274 -0
- package/lib/util/hash/BatchedHash.js +71 -0
- package/lib/util/hash/md4.js +25 -0
- package/lib/util/hash/wasm-hash.js +174 -0
- package/lib/util/identifier.js +127 -0
- package/lib/util/objectToMap.js +16 -0
- package/lib/validateSchema.js +67 -0
- package/lib/wasm/UnsupportedWebAssemblyFeatureError.js +17 -0
- package/lib/wasm/WasmFinalizeExportsPlugin.js +69 -0
- package/lib/wasm/WasmMainTemplatePlugin.js +341 -0
- package/lib/wasm/WebAssemblyGenerator.js +458 -0
- package/lib/wasm/WebAssemblyInInitialChunkError.js +88 -0
- package/lib/wasm/WebAssemblyJavascriptGenerator.js +152 -0
- package/lib/wasm/WebAssemblyModulesPlugin.js +128 -0
- package/lib/wasm/WebAssemblyParser.js +175 -0
- package/lib/wasm/WebAssemblyUtils.js +59 -0
- package/lib/web/FetchCompileWasmTemplatePlugin.js +37 -0
- package/lib/web/JsonpChunkTemplatePlugin.js +71 -0
- package/lib/web/JsonpExportMainTemplatePlugin.js +50 -0
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -0
- package/lib/web/JsonpMainTemplate.runtime.js +71 -0
- package/lib/web/JsonpMainTemplatePlugin.js +615 -0
- package/lib/web/JsonpTemplatePlugin.js +23 -0
- package/lib/web/WebEnvironmentPlugin.js +18 -0
- package/lib/webpack.js +206 -0
- package/lib/webpack.web.js +31 -0
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -0
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -0
- package/lib/webworker/WebWorkerMainTemplate.runtime.js +73 -0
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +192 -0
- package/lib/webworker/WebWorkerTemplatePlugin.js +25 -0
- package/package.json +211 -0
- package/schemas/WebpackOptions.json +2285 -0
- package/schemas/ajv.absolutePath.js +57 -0
- package/schemas/plugins/BannerPlugin.json +101 -0
- package/schemas/plugins/DllPlugin.json +36 -0
- package/schemas/plugins/DllReferencePlugin.json +205 -0
- package/schemas/plugins/HashedModuleIdsPlugin.json +26 -0
- package/schemas/plugins/IgnorePlugin.json +37 -0
- package/schemas/plugins/LoaderOptionsPlugin.json +27 -0
- package/schemas/plugins/ProgressPlugin.json +52 -0
- package/schemas/plugins/SourceMapDevToolPlugin.json +185 -0
- package/schemas/plugins/WatchIgnorePlugin.json +18 -0
- package/schemas/plugins/debug/ProfilingPlugin.json +13 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -0
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +16 -0
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +12 -0
- package/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +11 -0
- package/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +11 -0
- package/web_modules/node-libs-browser.js +0 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const DependencyReference = require("./DependencyReference");
|
|
8
|
+
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
9
|
+
const Template = require("../Template");
|
|
10
|
+
const HarmonyLinkingError = require("../HarmonyLinkingError");
|
|
11
|
+
|
|
12
|
+
/** @typedef {import("../Module")} Module */
|
|
13
|
+
|
|
14
|
+
/** @typedef {"missing"|"unused"|"empty-star"|"reexport-non-harmony-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-non-harmony-default-strict"|"reexport-fake-namespace-object"|"rexport-non-harmony-undefined"|"safe-reexport"|"checked-reexport"|"dynamic-reexport"} ExportModeType */
|
|
15
|
+
|
|
16
|
+
/** @type {Map<string, string>} */
|
|
17
|
+
const EMPTY_MAP = new Map();
|
|
18
|
+
|
|
19
|
+
class ExportMode {
|
|
20
|
+
/**
|
|
21
|
+
* @param {ExportModeType} type type of the mode
|
|
22
|
+
*/
|
|
23
|
+
constructor(type) {
|
|
24
|
+
/** @type {ExportModeType} */
|
|
25
|
+
this.type = type;
|
|
26
|
+
/** @type {string|null} */
|
|
27
|
+
this.name = null;
|
|
28
|
+
/** @type {Map<string, string>} */
|
|
29
|
+
this.map = EMPTY_MAP;
|
|
30
|
+
/** @type {Set<string>|null} */
|
|
31
|
+
this.ignored = null;
|
|
32
|
+
/** @type {Module|null} */
|
|
33
|
+
this.module = null;
|
|
34
|
+
/** @type {string|null} */
|
|
35
|
+
this.userRequest = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const EMPTY_STAR_MODE = new ExportMode("empty-star");
|
|
40
|
+
|
|
41
|
+
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
42
|
+
constructor(
|
|
43
|
+
request,
|
|
44
|
+
originModule,
|
|
45
|
+
sourceOrder,
|
|
46
|
+
parserScope,
|
|
47
|
+
id,
|
|
48
|
+
name,
|
|
49
|
+
activeExports,
|
|
50
|
+
otherStarExports,
|
|
51
|
+
strictExportPresence
|
|
52
|
+
) {
|
|
53
|
+
super(request, originModule, sourceOrder, parserScope);
|
|
54
|
+
this.id = id;
|
|
55
|
+
this.redirectedId = undefined;
|
|
56
|
+
this.name = name;
|
|
57
|
+
this.activeExports = activeExports;
|
|
58
|
+
this.otherStarExports = otherStarExports;
|
|
59
|
+
this.strictExportPresence = strictExportPresence;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get type() {
|
|
63
|
+
return "harmony export imported specifier";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get _id() {
|
|
67
|
+
return this.redirectedId || this.id;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getMode(ignoreUnused) {
|
|
71
|
+
const name = this.name;
|
|
72
|
+
const id = this._id;
|
|
73
|
+
const used = this.originModule.isUsed(name);
|
|
74
|
+
const importedModule = this._module;
|
|
75
|
+
|
|
76
|
+
if (!importedModule) {
|
|
77
|
+
const mode = new ExportMode("missing");
|
|
78
|
+
mode.userRequest = this.userRequest;
|
|
79
|
+
return mode;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (
|
|
83
|
+
!ignoreUnused &&
|
|
84
|
+
(name ? !used : this.originModule.usedExports === false)
|
|
85
|
+
) {
|
|
86
|
+
const mode = new ExportMode("unused");
|
|
87
|
+
mode.name = name || "*";
|
|
88
|
+
return mode;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const strictHarmonyModule = this.originModule.buildMeta.strictHarmonyModule;
|
|
92
|
+
if (name && id === "default" && importedModule.buildMeta) {
|
|
93
|
+
if (!importedModule.buildMeta.exportsType) {
|
|
94
|
+
const mode = new ExportMode(
|
|
95
|
+
strictHarmonyModule
|
|
96
|
+
? "reexport-non-harmony-default-strict"
|
|
97
|
+
: "reexport-non-harmony-default"
|
|
98
|
+
);
|
|
99
|
+
mode.name = name;
|
|
100
|
+
mode.module = importedModule;
|
|
101
|
+
return mode;
|
|
102
|
+
} else if (importedModule.buildMeta.exportsType === "named") {
|
|
103
|
+
const mode = new ExportMode("reexport-named-default");
|
|
104
|
+
mode.name = name;
|
|
105
|
+
mode.module = importedModule;
|
|
106
|
+
return mode;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isNotAHarmonyModule =
|
|
111
|
+
importedModule.buildMeta && !importedModule.buildMeta.exportsType;
|
|
112
|
+
if (name) {
|
|
113
|
+
let mode;
|
|
114
|
+
if (id) {
|
|
115
|
+
// export { name as name }
|
|
116
|
+
if (isNotAHarmonyModule && strictHarmonyModule) {
|
|
117
|
+
mode = new ExportMode("rexport-non-harmony-undefined");
|
|
118
|
+
mode.name = name;
|
|
119
|
+
} else {
|
|
120
|
+
mode = new ExportMode("safe-reexport");
|
|
121
|
+
mode.map = new Map([[name, id]]);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
// export { * as name }
|
|
125
|
+
if (isNotAHarmonyModule && strictHarmonyModule) {
|
|
126
|
+
mode = new ExportMode("reexport-fake-namespace-object");
|
|
127
|
+
mode.name = name;
|
|
128
|
+
} else {
|
|
129
|
+
mode = new ExportMode("reexport-namespace-object");
|
|
130
|
+
mode.name = name;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
mode.module = importedModule;
|
|
134
|
+
return mode;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const hasUsedExports = Array.isArray(this.originModule.usedExports);
|
|
138
|
+
const hasProvidedExports = Array.isArray(
|
|
139
|
+
importedModule.buildMeta.providedExports
|
|
140
|
+
);
|
|
141
|
+
const activeFromOtherStarExports = this._discoverActiveExportsFromOtherStartExports();
|
|
142
|
+
|
|
143
|
+
// export *
|
|
144
|
+
if (hasUsedExports) {
|
|
145
|
+
// reexport * with known used exports
|
|
146
|
+
if (hasProvidedExports) {
|
|
147
|
+
const map = new Map(
|
|
148
|
+
this.originModule.usedExports
|
|
149
|
+
.filter(id => {
|
|
150
|
+
if (id === "default") return false;
|
|
151
|
+
if (this.activeExports.has(id)) return false;
|
|
152
|
+
if (activeFromOtherStarExports.has(id)) return false;
|
|
153
|
+
if (!importedModule.buildMeta.providedExports.includes(id))
|
|
154
|
+
return false;
|
|
155
|
+
return true;
|
|
156
|
+
})
|
|
157
|
+
.map(item => [item, item])
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
if (map.size === 0) {
|
|
161
|
+
return EMPTY_STAR_MODE;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const mode = new ExportMode("safe-reexport");
|
|
165
|
+
mode.module = importedModule;
|
|
166
|
+
mode.map = map;
|
|
167
|
+
return mode;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const map = new Map(
|
|
171
|
+
this.originModule.usedExports
|
|
172
|
+
.filter(id => {
|
|
173
|
+
if (id === "default") return false;
|
|
174
|
+
if (this.activeExports.has(id)) return false;
|
|
175
|
+
if (activeFromOtherStarExports.has(id)) return false;
|
|
176
|
+
|
|
177
|
+
return true;
|
|
178
|
+
})
|
|
179
|
+
.map(item => [item, item])
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
if (map.size === 0) {
|
|
183
|
+
return EMPTY_STAR_MODE;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const mode = new ExportMode("checked-reexport");
|
|
187
|
+
mode.module = importedModule;
|
|
188
|
+
mode.map = map;
|
|
189
|
+
return mode;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (hasProvidedExports) {
|
|
193
|
+
const map = new Map(
|
|
194
|
+
importedModule.buildMeta.providedExports
|
|
195
|
+
.filter(id => {
|
|
196
|
+
if (id === "default") return false;
|
|
197
|
+
if (this.activeExports.has(id)) return false;
|
|
198
|
+
if (activeFromOtherStarExports.has(id)) return false;
|
|
199
|
+
|
|
200
|
+
return true;
|
|
201
|
+
})
|
|
202
|
+
.map(item => [item, item])
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
if (map.size === 0) {
|
|
206
|
+
return EMPTY_STAR_MODE;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const mode = new ExportMode("safe-reexport");
|
|
210
|
+
mode.module = importedModule;
|
|
211
|
+
mode.map = map;
|
|
212
|
+
return mode;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const mode = new ExportMode("dynamic-reexport");
|
|
216
|
+
mode.module = importedModule;
|
|
217
|
+
mode.ignored = new Set([
|
|
218
|
+
"default",
|
|
219
|
+
...this.activeExports,
|
|
220
|
+
...activeFromOtherStarExports
|
|
221
|
+
]);
|
|
222
|
+
return mode;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
getReference() {
|
|
226
|
+
const mode = this.getMode(false);
|
|
227
|
+
|
|
228
|
+
switch (mode.type) {
|
|
229
|
+
case "missing":
|
|
230
|
+
case "unused":
|
|
231
|
+
case "empty-star":
|
|
232
|
+
return null;
|
|
233
|
+
|
|
234
|
+
case "reexport-non-harmony-default":
|
|
235
|
+
case "reexport-named-default":
|
|
236
|
+
return new DependencyReference(
|
|
237
|
+
mode.module,
|
|
238
|
+
["default"],
|
|
239
|
+
false,
|
|
240
|
+
this.sourceOrder
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
case "reexport-namespace-object":
|
|
244
|
+
case "reexport-non-harmony-default-strict":
|
|
245
|
+
case "reexport-fake-namespace-object":
|
|
246
|
+
case "rexport-non-harmony-undefined":
|
|
247
|
+
return new DependencyReference(
|
|
248
|
+
mode.module,
|
|
249
|
+
true,
|
|
250
|
+
false,
|
|
251
|
+
this.sourceOrder
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
case "safe-reexport":
|
|
255
|
+
case "checked-reexport":
|
|
256
|
+
return new DependencyReference(
|
|
257
|
+
mode.module,
|
|
258
|
+
Array.from(mode.map.values()),
|
|
259
|
+
false,
|
|
260
|
+
this.sourceOrder
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
case "dynamic-reexport":
|
|
264
|
+
return new DependencyReference(
|
|
265
|
+
mode.module,
|
|
266
|
+
true,
|
|
267
|
+
false,
|
|
268
|
+
this.sourceOrder
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
default:
|
|
272
|
+
throw new Error(`Unknown mode ${mode.type}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
_discoverActiveExportsFromOtherStartExports() {
|
|
277
|
+
if (!this.otherStarExports) return new Set();
|
|
278
|
+
const result = new Set();
|
|
279
|
+
// try to learn impossible exports from other star exports with provided exports
|
|
280
|
+
for (const otherStarExport of this.otherStarExports) {
|
|
281
|
+
const otherImportedModule = otherStarExport._module;
|
|
282
|
+
if (
|
|
283
|
+
otherImportedModule &&
|
|
284
|
+
Array.isArray(otherImportedModule.buildMeta.providedExports)
|
|
285
|
+
) {
|
|
286
|
+
for (const exportName of otherImportedModule.buildMeta
|
|
287
|
+
.providedExports) {
|
|
288
|
+
result.add(exportName);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
getExports() {
|
|
296
|
+
if (this.name) {
|
|
297
|
+
return {
|
|
298
|
+
exports: [this.name],
|
|
299
|
+
dependencies: undefined
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const importedModule = this._module;
|
|
304
|
+
|
|
305
|
+
if (!importedModule) {
|
|
306
|
+
// no imported module available
|
|
307
|
+
return {
|
|
308
|
+
exports: null,
|
|
309
|
+
dependencies: undefined
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (Array.isArray(importedModule.buildMeta.providedExports)) {
|
|
314
|
+
const activeFromOtherStarExports = this._discoverActiveExportsFromOtherStartExports();
|
|
315
|
+
return {
|
|
316
|
+
exports: importedModule.buildMeta.providedExports.filter(
|
|
317
|
+
id =>
|
|
318
|
+
id !== "default" &&
|
|
319
|
+
!activeFromOtherStarExports.has(id) &&
|
|
320
|
+
!this.activeExports.has(id)
|
|
321
|
+
),
|
|
322
|
+
dependencies: [importedModule]
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (importedModule.buildMeta.providedExports) {
|
|
327
|
+
return {
|
|
328
|
+
exports: true,
|
|
329
|
+
dependencies: undefined
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return {
|
|
334
|
+
exports: null,
|
|
335
|
+
dependencies: [importedModule]
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
getWarnings() {
|
|
340
|
+
if (
|
|
341
|
+
this.strictExportPresence ||
|
|
342
|
+
this.originModule.buildMeta.strictHarmonyModule
|
|
343
|
+
) {
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
return this._getErrors();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
getErrors() {
|
|
350
|
+
if (
|
|
351
|
+
this.strictExportPresence ||
|
|
352
|
+
this.originModule.buildMeta.strictHarmonyModule
|
|
353
|
+
) {
|
|
354
|
+
return this._getErrors();
|
|
355
|
+
}
|
|
356
|
+
return [];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
_getErrors() {
|
|
360
|
+
const importedModule = this._module;
|
|
361
|
+
if (!importedModule) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (!importedModule.buildMeta || !importedModule.buildMeta.exportsType) {
|
|
366
|
+
// It's not an harmony module
|
|
367
|
+
if (
|
|
368
|
+
this.originModule.buildMeta.strictHarmonyModule &&
|
|
369
|
+
this._id &&
|
|
370
|
+
this._id !== "default"
|
|
371
|
+
) {
|
|
372
|
+
// In strict harmony modules we only support the default export
|
|
373
|
+
return [
|
|
374
|
+
new HarmonyLinkingError(
|
|
375
|
+
`Can't reexport the named export '${this._id}' from non EcmaScript module (only default export is available)`
|
|
376
|
+
)
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (!this._id) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (importedModule.isProvided(this._id) !== false) {
|
|
387
|
+
// It's provided or we are not sure
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// We are sure that it's not provided
|
|
392
|
+
const idIsNotNameMessage =
|
|
393
|
+
this._id !== this.name ? ` (reexported as '${this.name}')` : "";
|
|
394
|
+
const errorMessage = `"export '${this._id}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
|
395
|
+
return [new HarmonyLinkingError(errorMessage)];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
updateHash(hash) {
|
|
399
|
+
super.updateHash(hash);
|
|
400
|
+
const hashValue = this.getHashValue(this._module);
|
|
401
|
+
hash.update(hashValue);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
getHashValue(importedModule) {
|
|
405
|
+
if (!importedModule) {
|
|
406
|
+
return "";
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const stringifiedUsedExport = JSON.stringify(importedModule.usedExports);
|
|
410
|
+
const stringifiedProvidedExport = JSON.stringify(
|
|
411
|
+
importedModule.buildMeta.providedExports
|
|
412
|
+
);
|
|
413
|
+
return (
|
|
414
|
+
importedModule.used + stringifiedUsedExport + stringifiedProvidedExport
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
disconnect() {
|
|
419
|
+
super.disconnect();
|
|
420
|
+
this.redirectedId = undefined;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
module.exports = HarmonyExportImportedSpecifierDependency;
|
|
425
|
+
|
|
426
|
+
HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate extends HarmonyImportDependency.Template {
|
|
427
|
+
harmonyInit(dep, source, runtime, dependencyTemplates) {
|
|
428
|
+
super.harmonyInit(dep, source, runtime, dependencyTemplates);
|
|
429
|
+
const content = this.getContent(dep);
|
|
430
|
+
source.insert(-1, content);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
getHarmonyInitOrder(dep) {
|
|
434
|
+
if (dep.name) {
|
|
435
|
+
const used = dep.originModule.isUsed(dep.name);
|
|
436
|
+
if (!used) return NaN;
|
|
437
|
+
} else {
|
|
438
|
+
const importedModule = dep._module;
|
|
439
|
+
|
|
440
|
+
const activeFromOtherStarExports = dep._discoverActiveExportsFromOtherStartExports();
|
|
441
|
+
|
|
442
|
+
if (Array.isArray(dep.originModule.usedExports)) {
|
|
443
|
+
// we know which exports are used
|
|
444
|
+
|
|
445
|
+
const unused = dep.originModule.usedExports.every(id => {
|
|
446
|
+
if (id === "default") return true;
|
|
447
|
+
if (dep.activeExports.has(id)) return true;
|
|
448
|
+
if (importedModule.isProvided(id) === false) return true;
|
|
449
|
+
if (activeFromOtherStarExports.has(id)) return true;
|
|
450
|
+
return false;
|
|
451
|
+
});
|
|
452
|
+
if (unused) return NaN;
|
|
453
|
+
} else if (
|
|
454
|
+
dep.originModule.usedExports &&
|
|
455
|
+
importedModule &&
|
|
456
|
+
Array.isArray(importedModule.buildMeta.providedExports)
|
|
457
|
+
) {
|
|
458
|
+
// not sure which exports are used, but we know which are provided
|
|
459
|
+
|
|
460
|
+
const unused = importedModule.buildMeta.providedExports.every(id => {
|
|
461
|
+
if (id === "default") return true;
|
|
462
|
+
if (dep.activeExports.has(id)) return true;
|
|
463
|
+
if (activeFromOtherStarExports.has(id)) return true;
|
|
464
|
+
return false;
|
|
465
|
+
});
|
|
466
|
+
if (unused) return NaN;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return super.getHarmonyInitOrder(dep);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
getContent(dep) {
|
|
473
|
+
const mode = dep.getMode(false);
|
|
474
|
+
const module = dep.originModule;
|
|
475
|
+
const importedModule = dep._module;
|
|
476
|
+
const importVar = dep.getImportVar();
|
|
477
|
+
|
|
478
|
+
switch (mode.type) {
|
|
479
|
+
case "missing":
|
|
480
|
+
return `throw new Error(${JSON.stringify(
|
|
481
|
+
`Cannot find module '${mode.userRequest}'`
|
|
482
|
+
)});\n`;
|
|
483
|
+
|
|
484
|
+
case "unused":
|
|
485
|
+
return `${Template.toNormalComment(
|
|
486
|
+
`unused harmony reexport ${mode.name}`
|
|
487
|
+
)}\n`;
|
|
488
|
+
|
|
489
|
+
case "reexport-non-harmony-default":
|
|
490
|
+
return (
|
|
491
|
+
"/* harmony reexport (default from non-harmony) */ " +
|
|
492
|
+
this.getReexportStatement(
|
|
493
|
+
module,
|
|
494
|
+
module.isUsed(mode.name),
|
|
495
|
+
importVar,
|
|
496
|
+
null
|
|
497
|
+
)
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
case "reexport-named-default":
|
|
501
|
+
return (
|
|
502
|
+
"/* harmony reexport (default from named exports) */ " +
|
|
503
|
+
this.getReexportStatement(
|
|
504
|
+
module,
|
|
505
|
+
module.isUsed(mode.name),
|
|
506
|
+
importVar,
|
|
507
|
+
""
|
|
508
|
+
)
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
case "reexport-fake-namespace-object":
|
|
512
|
+
return (
|
|
513
|
+
"/* harmony reexport (fake namespace object from non-harmony) */ " +
|
|
514
|
+
this.getReexportFakeNamespaceObjectStatement(
|
|
515
|
+
module,
|
|
516
|
+
module.isUsed(mode.name),
|
|
517
|
+
importVar
|
|
518
|
+
)
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
case "rexport-non-harmony-undefined":
|
|
522
|
+
return (
|
|
523
|
+
"/* harmony reexport (non default export from non-harmony) */ " +
|
|
524
|
+
this.getReexportStatement(
|
|
525
|
+
module,
|
|
526
|
+
module.isUsed(mode.name),
|
|
527
|
+
"undefined",
|
|
528
|
+
""
|
|
529
|
+
)
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
case "reexport-non-harmony-default-strict":
|
|
533
|
+
return (
|
|
534
|
+
"/* harmony reexport (default from non-harmony) */ " +
|
|
535
|
+
this.getReexportStatement(
|
|
536
|
+
module,
|
|
537
|
+
module.isUsed(mode.name),
|
|
538
|
+
importVar,
|
|
539
|
+
""
|
|
540
|
+
)
|
|
541
|
+
);
|
|
542
|
+
|
|
543
|
+
case "reexport-namespace-object":
|
|
544
|
+
return (
|
|
545
|
+
"/* harmony reexport (module object) */ " +
|
|
546
|
+
this.getReexportStatement(
|
|
547
|
+
module,
|
|
548
|
+
module.isUsed(mode.name),
|
|
549
|
+
importVar,
|
|
550
|
+
""
|
|
551
|
+
)
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
case "empty-star":
|
|
555
|
+
return "/* empty/unused harmony star reexport */";
|
|
556
|
+
|
|
557
|
+
case "safe-reexport":
|
|
558
|
+
return Array.from(mode.map.entries())
|
|
559
|
+
.map(item => {
|
|
560
|
+
return (
|
|
561
|
+
"/* harmony reexport (safe) */ " +
|
|
562
|
+
this.getReexportStatement(
|
|
563
|
+
module,
|
|
564
|
+
module.isUsed(item[0]),
|
|
565
|
+
importVar,
|
|
566
|
+
importedModule.isUsed(item[1])
|
|
567
|
+
) +
|
|
568
|
+
"\n"
|
|
569
|
+
);
|
|
570
|
+
})
|
|
571
|
+
.join("");
|
|
572
|
+
|
|
573
|
+
case "checked-reexport":
|
|
574
|
+
return Array.from(mode.map.entries())
|
|
575
|
+
.map(item => {
|
|
576
|
+
return (
|
|
577
|
+
"/* harmony reexport (checked) */ " +
|
|
578
|
+
this.getConditionalReexportStatement(
|
|
579
|
+
module,
|
|
580
|
+
item[0],
|
|
581
|
+
importVar,
|
|
582
|
+
item[1]
|
|
583
|
+
) +
|
|
584
|
+
"\n"
|
|
585
|
+
);
|
|
586
|
+
})
|
|
587
|
+
.join("");
|
|
588
|
+
|
|
589
|
+
case "dynamic-reexport": {
|
|
590
|
+
const ignoredExports = mode.ignored;
|
|
591
|
+
let content =
|
|
592
|
+
"/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " +
|
|
593
|
+
importVar +
|
|
594
|
+
") ";
|
|
595
|
+
|
|
596
|
+
// Filter out exports which are defined by other exports
|
|
597
|
+
// and filter out default export because it cannot be reexported with *
|
|
598
|
+
if (ignoredExports.size > 0) {
|
|
599
|
+
content +=
|
|
600
|
+
"if(" +
|
|
601
|
+
JSON.stringify(Array.from(ignoredExports)) +
|
|
602
|
+
".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
|
603
|
+
} else {
|
|
604
|
+
content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
|
|
605
|
+
}
|
|
606
|
+
const exportsName = dep.originModule.exportsArgument;
|
|
607
|
+
return (
|
|
608
|
+
content +
|
|
609
|
+
`(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${importVar}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
default:
|
|
614
|
+
throw new Error(`Unknown mode ${mode.type}`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
getReexportStatement(module, key, name, valueKey) {
|
|
619
|
+
const exportsName = module.exportsArgument;
|
|
620
|
+
const returnValue = this.getReturnValue(name, valueKey);
|
|
621
|
+
return `__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
622
|
+
key
|
|
623
|
+
)}, function() { return ${returnValue}; });\n`;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
getReexportFakeNamespaceObjectStatement(module, key, name) {
|
|
627
|
+
const exportsName = module.exportsArgument;
|
|
628
|
+
return `__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
629
|
+
key
|
|
630
|
+
)}, function() { return __webpack_require__.t(${name}); });\n`;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
getConditionalReexportStatement(module, key, name, valueKey) {
|
|
634
|
+
if (valueKey === false) {
|
|
635
|
+
return "/* unused export */\n";
|
|
636
|
+
}
|
|
637
|
+
const exportsName = module.exportsArgument;
|
|
638
|
+
const returnValue = this.getReturnValue(name, valueKey);
|
|
639
|
+
return `if(__webpack_require__.o(${name}, ${JSON.stringify(
|
|
640
|
+
valueKey
|
|
641
|
+
)})) __webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
642
|
+
key
|
|
643
|
+
)}, function() { return ${returnValue}; });\n`;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
getReturnValue(name, valueKey) {
|
|
647
|
+
if (valueKey === null) {
|
|
648
|
+
return `${name}_default.a`;
|
|
649
|
+
}
|
|
650
|
+
if (valueKey === "") {
|
|
651
|
+
return name;
|
|
652
|
+
}
|
|
653
|
+
if (valueKey === false) {
|
|
654
|
+
return "/* unused export */ undefined";
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
return `${name}[${JSON.stringify(valueKey)}]`;
|
|
658
|
+
}
|
|
659
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
const NullDependency = require("./NullDependency");
|
|
7
|
+
|
|
8
|
+
class HarmonyExportSpecifierDependency extends NullDependency {
|
|
9
|
+
constructor(originModule, id, name) {
|
|
10
|
+
super();
|
|
11
|
+
this.originModule = originModule;
|
|
12
|
+
this.id = id;
|
|
13
|
+
this.name = name;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get type() {
|
|
17
|
+
return "harmony export specifier";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getExports() {
|
|
21
|
+
return {
|
|
22
|
+
exports: [this.name],
|
|
23
|
+
dependencies: undefined
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependencyTemplate {
|
|
29
|
+
apply(dep, source) {}
|
|
30
|
+
|
|
31
|
+
getHarmonyInitOrder(dep) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
harmonyInit(dep, source, runtime) {
|
|
36
|
+
const content = this.getContent(dep);
|
|
37
|
+
source.insert(-1, content);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getContent(dep) {
|
|
41
|
+
const used = dep.originModule.isUsed(dep.name);
|
|
42
|
+
if (!used) {
|
|
43
|
+
return `/* unused harmony export ${dep.name || "namespace"} */\n`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const exportsName = dep.originModule.exportsArgument;
|
|
47
|
+
|
|
48
|
+
return `/* harmony export (binding) */ __webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
49
|
+
used
|
|
50
|
+
)}, function() { return ${dep.id}; });\n`;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = HarmonyExportSpecifierDependency;
|