2015-10-22 03:05:01 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2018-07-30 23:08:51 +08:00
|
|
|
|
2017-01-05 02:04:43 +08:00
|
|
|
"use strict";
|
2018-04-04 15:17:10 +08:00
|
|
|
|
2018-07-30 23:08:51 +08:00
|
|
|
const HarmonyLinkingError = require("../HarmonyLinkingError");
|
2018-07-23 20:53:50 +08:00
|
|
|
const InitFragment = require("../InitFragment");
|
2018-07-30 23:08:51 +08:00
|
|
|
const Template = require("../Template");
|
2018-04-04 15:17:10 +08:00
|
|
|
const DependencyReference = require("./DependencyReference");
|
2017-08-08 15:32:43 +08:00
|
|
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-07-27 17:45:12 +08:00
|
|
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
2018-08-28 17:50:33 +08:00
|
|
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
2018-07-27 17:45:12 +08:00
|
|
|
/** @typedef {import("../Dependency")} Dependency */
|
2018-07-30 23:08:51 +08:00
|
|
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
2018-07-18 01:38:42 +08:00
|
|
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
2018-05-27 05:07:02 +08:00
|
|
|
/** @typedef {import("../Module")} Module */
|
2018-07-17 22:42:05 +08:00
|
|
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
2018-07-25 15:33:48 +08:00
|
|
|
/** @typedef {import("../WebpackError")} WebpackError */
|
2018-07-30 23:08:51 +08:00
|
|
|
/** @typedef {import("../util/createHash").Hash} Hash */
|
2018-05-27 05:07:02 +08:00
|
|
|
|
|
|
|
/** @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 */
|
|
|
|
|
|
|
|
/** @type {Map<string, string>} */
|
2018-04-04 15:50:35 +08:00
|
|
|
const EMPTY_MAP = new Map();
|
|
|
|
|
|
|
|
class ExportMode {
|
2018-05-27 05:07:02 +08:00
|
|
|
/**
|
|
|
|
* @param {ExportModeType} type type of the mode
|
|
|
|
*/
|
2018-04-04 15:50:35 +08:00
|
|
|
constructor(type) {
|
2018-05-27 05:07:02 +08:00
|
|
|
/** @type {ExportModeType} */
|
2018-04-04 15:50:35 +08:00
|
|
|
this.type = type;
|
2018-05-27 05:07:02 +08:00
|
|
|
/** @type {string|null} */
|
2018-04-04 15:50:35 +08:00
|
|
|
this.name = null;
|
2018-05-27 05:07:02 +08:00
|
|
|
/** @type {Map<string, string>} */
|
2018-04-04 15:50:35 +08:00
|
|
|
this.map = EMPTY_MAP;
|
2018-07-17 20:04:26 +08:00
|
|
|
/** @type {null | function(): Module} */
|
|
|
|
this.getModule = null;
|
2018-05-27 05:07:02 +08:00
|
|
|
/** @type {string|null} */
|
2018-04-04 15:50:35 +08:00
|
|
|
this.userRequest = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const EMPTY_STAR_MODE = new ExportMode("empty-star");
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2017-08-08 15:32:43 +08:00
|
|
|
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
2018-02-25 09:00:20 +08:00
|
|
|
constructor(
|
|
|
|
request,
|
|
|
|
sourceOrder,
|
|
|
|
parserScope,
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
activeExports,
|
|
|
|
otherStarExports,
|
|
|
|
strictExportPresence
|
|
|
|
) {
|
2018-08-07 20:20:53 +08:00
|
|
|
super(request, sourceOrder, parserScope);
|
2017-01-05 02:04:43 +08:00
|
|
|
this.id = id;
|
|
|
|
this.name = name;
|
2017-10-09 21:28:59 +08:00
|
|
|
this.activeExports = activeExports;
|
|
|
|
this.otherStarExports = otherStarExports;
|
2017-11-23 21:10:52 +08:00
|
|
|
this.strictExportPresence = strictExportPresence;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
get type() {
|
|
|
|
return "harmony export imported specifier";
|
|
|
|
}
|
|
|
|
|
2018-07-24 23:35:36 +08:00
|
|
|
/**
|
|
|
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
|
|
* @param {boolean=} ignoreUnused ignore the fact that exports are unused
|
|
|
|
* @returns {ExportMode} the export mode
|
|
|
|
*/
|
|
|
|
getMode(moduleGraph, ignoreUnused) {
|
2017-01-05 02:04:43 +08:00
|
|
|
const name = this.name;
|
2017-08-08 15:32:43 +08:00
|
|
|
const id = this.id;
|
2018-08-07 20:20:53 +08:00
|
|
|
const parentModule = moduleGraph.getParentModule(this);
|
|
|
|
const used = parentModule.getUsedName(moduleGraph, name);
|
2018-08-16 19:55:41 +08:00
|
|
|
const usedExports = moduleGraph.getUsedExports(parentModule);
|
2018-07-24 21:30:37 +08:00
|
|
|
const importedModule = moduleGraph.getModule(this);
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!importedModule) {
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("missing");
|
|
|
|
mode.userRequest = this.userRequest;
|
|
|
|
return mode;
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
2017-08-27 08:05:57 +08:00
|
|
|
|
2018-08-07 01:39:43 +08:00
|
|
|
if (!ignoreUnused && (name ? !used : usedExports === false)) {
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("unused");
|
|
|
|
mode.name = name || "*";
|
|
|
|
return mode;
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-08-07 20:20:53 +08:00
|
|
|
const strictHarmonyModule = parentModule.buildMeta.strictHarmonyModule;
|
2018-03-20 18:10:05 +08:00
|
|
|
if (name && id === "default" && importedModule.buildMeta) {
|
|
|
|
if (!importedModule.buildMeta.exportsType) {
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode(
|
|
|
|
strictHarmonyModule
|
|
|
|
? "reexport-non-harmony-default-strict"
|
|
|
|
: "reexport-non-harmony-default"
|
|
|
|
);
|
|
|
|
mode.name = name;
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
return mode;
|
2018-03-20 18:10:05 +08:00
|
|
|
} else if (importedModule.buildMeta.exportsType === "named") {
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("reexport-named-default");
|
|
|
|
mode.name = name;
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
return mode;
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
|
|
|
|
2018-03-20 18:10:05 +08:00
|
|
|
const isNotAHarmonyModule =
|
|
|
|
importedModule.buildMeta && !importedModule.buildMeta.exportsType;
|
2018-02-25 09:00:20 +08:00
|
|
|
if (name) {
|
2018-04-04 15:50:35 +08:00
|
|
|
let mode;
|
2018-02-25 09:00:20 +08:00
|
|
|
if (id) {
|
2018-04-04 15:50:35 +08:00
|
|
|
// export { name as name }
|
2018-02-25 09:00:20 +08:00
|
|
|
if (isNotAHarmonyModule && strictHarmonyModule) {
|
2018-04-04 15:50:35 +08:00
|
|
|
mode = new ExportMode("rexport-non-harmony-undefined");
|
|
|
|
mode.name = name;
|
2017-11-23 21:10:52 +08:00
|
|
|
} else {
|
2018-04-04 15:50:35 +08:00
|
|
|
mode = new ExportMode("safe-reexport");
|
|
|
|
mode.map = new Map([[name, id]]);
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
|
|
|
} else {
|
2018-04-04 15:50:35 +08:00
|
|
|
// export { * as name }
|
|
|
|
if (isNotAHarmonyModule && strictHarmonyModule) {
|
|
|
|
mode = new ExportMode("reexport-fake-namespace-object");
|
|
|
|
mode.name = name;
|
|
|
|
} else {
|
|
|
|
mode = new ExportMode("reexport-namespace-object");
|
|
|
|
mode.name = name;
|
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
return mode;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
2015-10-22 03:05:01 +08:00
|
|
|
|
2018-07-24 21:30:37 +08:00
|
|
|
const activeFromOtherStarExports = this._discoverActiveExportsFromOtherStartExports(
|
|
|
|
moduleGraph
|
|
|
|
);
|
2017-08-27 08:05:57 +08:00
|
|
|
|
2016-08-17 17:24:35 +08:00
|
|
|
// export *
|
2018-08-07 01:39:43 +08:00
|
|
|
if (usedExports && usedExports !== true) {
|
2016-08-17 17:24:35 +08:00
|
|
|
// reexport * with known used exports
|
2018-08-07 01:39:43 +08:00
|
|
|
const providedExports = importedModule.buildMeta.providedExports;
|
|
|
|
if (Array.isArray(providedExports)) {
|
2018-02-25 09:00:20 +08:00
|
|
|
const map = new Map(
|
2018-08-07 01:39:43 +08:00
|
|
|
Array.from(usedExports)
|
2018-02-25 09:00:20 +08:00
|
|
|
.filter(id => {
|
|
|
|
if (id === "default") return false;
|
|
|
|
if (this.activeExports.has(id)) return false;
|
|
|
|
if (activeFromOtherStarExports.has(id)) return false;
|
2018-08-07 01:39:43 +08:00
|
|
|
if (!providedExports.includes(id)) return false;
|
2018-02-25 09:00:20 +08:00
|
|
|
return true;
|
|
|
|
})
|
2018-08-07 01:39:43 +08:00
|
|
|
.map(item => {
|
|
|
|
/** @type {[string, string]} */
|
|
|
|
const tuple = [item, item];
|
|
|
|
return tuple;
|
|
|
|
})
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
if (map.size === 0) {
|
2018-04-04 15:50:35 +08:00
|
|
|
return EMPTY_STAR_MODE;
|
2017-08-27 08:05:57 +08:00
|
|
|
}
|
2017-08-08 15:32:43 +08:00
|
|
|
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("safe-reexport");
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
mode.map = map;
|
|
|
|
return mode;
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
const map = new Map(
|
2018-08-07 01:39:43 +08:00
|
|
|
Array.from(usedExports)
|
2018-02-25 09:00:20 +08:00
|
|
|
.filter(id => {
|
|
|
|
if (id === "default") return false;
|
|
|
|
if (this.activeExports.has(id)) return false;
|
|
|
|
if (activeFromOtherStarExports.has(id)) return false;
|
2017-10-09 21:28:59 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
return true;
|
|
|
|
})
|
2018-08-07 01:39:43 +08:00
|
|
|
.map(item => {
|
|
|
|
/** @type {[string, string]} */
|
|
|
|
const tuple = [item, item];
|
|
|
|
return tuple;
|
|
|
|
})
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (map.size === 0) {
|
2018-04-04 15:50:35 +08:00
|
|
|
return EMPTY_STAR_MODE;
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("checked-reexport");
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
mode.map = map;
|
|
|
|
return mode;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2018-08-07 01:39:43 +08:00
|
|
|
if (Array.isArray(importedModule.buildMeta.providedExports)) {
|
2018-02-25 09:00:20 +08:00
|
|
|
const map = new Map(
|
|
|
|
importedModule.buildMeta.providedExports
|
|
|
|
.filter(id => {
|
|
|
|
if (id === "default") return false;
|
|
|
|
if (this.activeExports.has(id)) return false;
|
|
|
|
if (activeFromOtherStarExports.has(id)) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
})
|
2018-08-07 01:39:43 +08:00
|
|
|
.map(item => {
|
|
|
|
/** @type {[string, string]} */
|
|
|
|
const tuple = [item, item];
|
|
|
|
return tuple;
|
|
|
|
})
|
2017-08-08 15:32:43 +08:00
|
|
|
);
|
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (map.size === 0) {
|
2018-04-04 15:50:35 +08:00
|
|
|
return EMPTY_STAR_MODE;
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
|
|
|
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("safe-reexport");
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
mode.map = map;
|
|
|
|
return mode;
|
2016-08-17 17:24:35 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-04-04 15:50:35 +08:00
|
|
|
const mode = new ExportMode("dynamic-reexport");
|
2018-07-24 21:30:37 +08:00
|
|
|
mode.getModule = () => moduleGraph.getModule(this);
|
2018-04-04 15:50:35 +08:00
|
|
|
return mode;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2018-07-25 15:33:48 +08:00
|
|
|
/**
|
|
|
|
* Returns the referenced module and export
|
2018-07-24 23:35:36 +08:00
|
|
|
* @param {ModuleGraph} moduleGraph module graph
|
2018-07-25 15:33:48 +08:00
|
|
|
* @returns {DependencyReference} reference
|
|
|
|
*/
|
2018-07-24 23:35:36 +08:00
|
|
|
getReference(moduleGraph) {
|
|
|
|
const mode = this.getMode(moduleGraph, false);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
switch (mode.type) {
|
2017-08-08 15:32:43 +08:00
|
|
|
case "missing":
|
|
|
|
case "unused":
|
|
|
|
case "empty-star":
|
|
|
|
return null;
|
|
|
|
|
|
|
|
case "reexport-non-harmony-default":
|
2018-03-20 18:10:05 +08:00
|
|
|
case "reexport-named-default":
|
2018-06-08 19:20:57 +08:00
|
|
|
return new DependencyReference(
|
2018-07-17 20:04:26 +08:00
|
|
|
mode.getModule,
|
2018-06-08 19:20:57 +08:00
|
|
|
["default"],
|
|
|
|
false,
|
|
|
|
this.sourceOrder
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "reexport-namespace-object":
|
2017-11-23 21:10:52 +08:00
|
|
|
case "reexport-non-harmony-default-strict":
|
|
|
|
case "reexport-fake-namespace-object":
|
|
|
|
case "rexport-non-harmony-undefined":
|
2018-06-08 19:20:57 +08:00
|
|
|
return new DependencyReference(
|
2018-07-17 20:04:26 +08:00
|
|
|
mode.getModule,
|
2018-06-08 19:20:57 +08:00
|
|
|
true,
|
|
|
|
false,
|
|
|
|
this.sourceOrder
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "safe-reexport":
|
|
|
|
case "checked-reexport":
|
2018-04-04 15:17:10 +08:00
|
|
|
return new DependencyReference(
|
2018-07-17 20:04:26 +08:00
|
|
|
mode.getModule,
|
2018-04-04 15:17:10 +08:00
|
|
|
Array.from(mode.map.values()),
|
2018-07-06 02:39:47 +08:00
|
|
|
false,
|
|
|
|
this.sourceOrder
|
2018-04-04 15:17:10 +08:00
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "dynamic-reexport":
|
2018-06-08 19:20:57 +08:00
|
|
|
return new DependencyReference(
|
2018-07-17 20:04:26 +08:00
|
|
|
mode.getModule,
|
2018-06-08 19:20:57 +08:00
|
|
|
true,
|
|
|
|
false,
|
|
|
|
this.sourceOrder
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
throw new Error(`Unknown mode ${mode.type}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 21:30:37 +08:00
|
|
|
/**
|
|
|
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
|
|
* @returns {Set<string>} exported names
|
|
|
|
*/
|
|
|
|
_discoverActiveExportsFromOtherStartExports(moduleGraph) {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!this.otherStarExports) return new Set();
|
2017-10-09 21:28:59 +08:00
|
|
|
const result = new Set();
|
|
|
|
// try to learn impossible exports from other star exports with provided exports
|
2018-02-25 09:00:20 +08:00
|
|
|
for (const otherStarExport of this.otherStarExports) {
|
2018-07-24 21:30:37 +08:00
|
|
|
const otherImportedModule = moduleGraph.getModule(otherStarExport);
|
2018-02-25 09:00:20 +08:00
|
|
|
if (
|
|
|
|
otherImportedModule &&
|
|
|
|
Array.isArray(otherImportedModule.buildMeta.providedExports)
|
|
|
|
) {
|
2018-08-09 17:46:44 +08:00
|
|
|
const providedExports = otherImportedModule.buildMeta.providedExports;
|
|
|
|
for (const exportName of providedExports) {
|
2017-10-09 21:28:59 +08:00
|
|
|
result.add(exportName);
|
2018-05-29 20:50:40 +08:00
|
|
|
}
|
2017-10-09 21:28:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-25 15:33:48 +08:00
|
|
|
/**
|
|
|
|
* Returns the exported names
|
2018-07-17 22:34:36 +08:00
|
|
|
* @param {ModuleGraph} moduleGraph module graph
|
2018-07-25 15:33:48 +08:00
|
|
|
* @returns {ExportsSpec | undefined} export names
|
|
|
|
*/
|
2018-07-17 22:34:36 +08:00
|
|
|
getExports(moduleGraph) {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (this.name) {
|
2016-08-17 17:24:35 +08:00
|
|
|
return {
|
2018-04-04 19:42:37 +08:00
|
|
|
exports: [this.name],
|
|
|
|
dependencies: undefined
|
2017-01-11 17:51:58 +08:00
|
|
|
};
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2018-07-24 21:30:37 +08:00
|
|
|
const importedModule = moduleGraph.getModule(this);
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!importedModule) {
|
2017-01-05 02:04:43 +08:00
|
|
|
// no imported module available
|
2018-07-17 22:34:36 +08:00
|
|
|
return undefined;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (Array.isArray(importedModule.buildMeta.providedExports)) {
|
2016-08-17 17:24:35 +08:00
|
|
|
return {
|
2018-02-25 09:00:20 +08:00
|
|
|
exports: importedModule.buildMeta.providedExports.filter(
|
|
|
|
id => id !== "default"
|
|
|
|
),
|
2017-01-05 02:04:43 +08:00
|
|
|
dependencies: [importedModule]
|
2016-08-17 17:24:35 +08:00
|
|
|
};
|
|
|
|
}
|
2015-12-23 23:24:45 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (importedModule.buildMeta.providedExports) {
|
2017-01-05 02:04:43 +08:00
|
|
|
return {
|
2018-04-04 19:42:37 +08:00
|
|
|
exports: true,
|
|
|
|
dependencies: undefined
|
2017-01-05 02:04:43 +08:00
|
|
|
};
|
2016-09-06 05:41:03 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2016-09-06 05:41:03 +08:00
|
|
|
return {
|
2017-01-05 02:04:43 +08:00
|
|
|
exports: null,
|
|
|
|
dependencies: [importedModule]
|
2016-09-06 05:41:03 +08:00
|
|
|
};
|
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-07-25 15:33:48 +08:00
|
|
|
/**
|
|
|
|
* Returns warnings
|
2018-07-24 23:35:36 +08:00
|
|
|
* @param {ModuleGraph} moduleGraph module graph
|
2018-07-25 15:33:48 +08:00
|
|
|
* @returns {WebpackError[]} warnings
|
|
|
|
*/
|
2018-07-24 23:35:36 +08:00
|
|
|
getWarnings(moduleGraph) {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (
|
|
|
|
this.strictExportPresence ||
|
2018-08-07 20:20:53 +08:00
|
|
|
moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
|
2018-02-25 09:00:20 +08:00
|
|
|
) {
|
2017-11-23 21:10:52 +08:00
|
|
|
return [];
|
|
|
|
}
|
2018-07-24 23:35:36 +08:00
|
|
|
return this._getErrors(moduleGraph);
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
|
|
|
|
2018-07-25 15:33:48 +08:00
|
|
|
/**
|
|
|
|
* Returns errors
|
2018-07-24 23:35:36 +08:00
|
|
|
* @param {ModuleGraph} moduleGraph module graph
|
2018-07-25 15:33:48 +08:00
|
|
|
* @returns {WebpackError[]} errors
|
|
|
|
*/
|
2018-07-24 23:35:36 +08:00
|
|
|
getErrors(moduleGraph) {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (
|
|
|
|
this.strictExportPresence ||
|
2018-08-07 20:20:53 +08:00
|
|
|
moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
|
2018-02-25 09:00:20 +08:00
|
|
|
) {
|
2018-07-24 23:35:36 +08:00
|
|
|
return this._getErrors(moduleGraph);
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2018-07-24 23:35:36 +08:00
|
|
|
_getErrors(moduleGraph) {
|
2018-07-24 21:30:37 +08:00
|
|
|
const importedModule = moduleGraph.getModule(this);
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!importedModule) {
|
2017-11-23 21:10:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!importedModule.buildMeta || !importedModule.buildMeta.exportsType) {
|
2017-11-23 21:10:52 +08:00
|
|
|
// It's not an harmony module
|
2018-02-25 09:00:20 +08:00
|
|
|
if (
|
2018-08-07 20:20:53 +08:00
|
|
|
moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule &&
|
2018-02-25 09:00:20 +08:00
|
|
|
this.id !== "default"
|
|
|
|
) {
|
2017-11-23 21:10:52 +08:00
|
|
|
// In strict harmony modules we only support the default export
|
2018-02-25 09:00:20 +08:00
|
|
|
const exportName = this.id
|
|
|
|
? `the named export '${this.id}'`
|
|
|
|
: "the namespace object";
|
2018-04-04 12:10:07 +08:00
|
|
|
return [
|
|
|
|
new HarmonyLinkingError(
|
|
|
|
`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`
|
|
|
|
)
|
|
|
|
];
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (!this.id) {
|
2017-11-23 21:10:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
if (importedModule.isProvided(this.id) !== false) {
|
2017-11-23 21:10:52 +08:00
|
|
|
// It's provided or we are not sure
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We are sure that it's not provided
|
2018-02-25 09:00:20 +08:00
|
|
|
const idIsNotNameMessage =
|
|
|
|
this.id !== this.name ? ` (reexported as '${this.name}')` : "";
|
2018-03-26 22:56:10 +08:00
|
|
|
const errorMessage = `"export '${
|
|
|
|
this.id
|
|
|
|
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
2018-04-04 12:10:07 +08:00
|
|
|
return [new HarmonyLinkingError(errorMessage)];
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
|
|
|
|
2018-07-25 15:33:48 +08:00
|
|
|
/**
|
|
|
|
* Update the hash
|
|
|
|
* @param {Hash} hash hash to be updated
|
2018-08-28 17:50:33 +08:00
|
|
|
* @param {ChunkGraph} chunkGraph chunk graph
|
2018-07-25 15:33:48 +08:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-08-28 17:50:33 +08:00
|
|
|
updateHash(hash, chunkGraph) {
|
|
|
|
super.updateHash(hash, chunkGraph);
|
|
|
|
const moduleGraph = chunkGraph.moduleGraph;
|
|
|
|
const importedModule = moduleGraph.getModule(this);
|
|
|
|
if (importedModule) {
|
|
|
|
const usedExports = moduleGraph.getUsedExports(importedModule);
|
|
|
|
const stringifiedUsedExports = JSON.stringify(usedExports);
|
|
|
|
const stringifiedProvidedExports = JSON.stringify(
|
|
|
|
importedModule.buildMeta.providedExports
|
|
|
|
);
|
|
|
|
hash.update(stringifiedUsedExports + stringifiedProvidedExports);
|
|
|
|
}
|
2016-09-06 05:41:03 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HarmonyExportImportedSpecifierDependency;
|
|
|
|
|
2017-08-08 15:32:43 +08:00
|
|
|
HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate extends HarmonyImportDependency.Template {
|
2018-07-27 17:45:12 +08:00
|
|
|
/**
|
|
|
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
2018-07-18 01:38:42 +08:00
|
|
|
* @param {DependencyTemplateContext} templateContext the template context
|
2018-07-27 17:45:12 +08:00
|
|
|
* @returns {InitFragment[]|null} the init fragments
|
|
|
|
*/
|
2018-07-31 03:39:17 +08:00
|
|
|
getInitFragments(dependency, templateContext) {
|
2018-07-27 17:45:12 +08:00
|
|
|
const dep = /** @type {HarmonyExportImportedSpecifierDependency} */ (dependency);
|
2018-07-24 21:30:37 +08:00
|
|
|
if (this.isUsed(dep, templateContext)) {
|
2018-07-31 03:39:17 +08:00
|
|
|
const importFragments = super.getInitFragments(dep, templateContext);
|
2018-08-08 20:12:54 +08:00
|
|
|
const exportFragment = this._getExportFragment(
|
|
|
|
dep,
|
|
|
|
templateContext.module,
|
|
|
|
templateContext.moduleGraph
|
2018-07-27 17:35:08 +08:00
|
|
|
);
|
|
|
|
return importFragments
|
|
|
|
? importFragments.concat(exportFragment)
|
|
|
|
: [exportFragment];
|
2018-07-23 20:53:50 +08:00
|
|
|
} else {
|
2018-07-27 03:39:46 +08:00
|
|
|
return null;
|
2018-07-23 20:53:50 +08:00
|
|
|
}
|
2016-02-17 05:31:12 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-07-27 17:45:12 +08:00
|
|
|
/**
|
2018-07-30 18:09:42 +08:00
|
|
|
* @param {HarmonyExportImportedSpecifierDependency} dep the dependency
|
2018-07-24 21:30:37 +08:00
|
|
|
* @param {DependencyTemplateContext} templateContext the template context
|
2018-07-30 18:09:42 +08:00
|
|
|
* @returns {Boolean} true, if (any) export is used
|
2018-07-27 17:45:12 +08:00
|
|
|
*/
|
2018-08-07 20:20:53 +08:00
|
|
|
isUsed(dep, { moduleGraph, module }) {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (dep.name) {
|
2018-08-07 20:20:53 +08:00
|
|
|
return module.isExportUsed(moduleGraph, dep.name);
|
2017-11-21 17:41:01 +08:00
|
|
|
} else {
|
2018-08-07 20:20:53 +08:00
|
|
|
const importedModule = moduleGraph.getModule(dep);
|
2018-07-24 21:30:37 +08:00
|
|
|
const activeFromOtherStarExports = dep._discoverActiveExportsFromOtherStartExports(
|
2018-08-07 20:20:53 +08:00
|
|
|
moduleGraph
|
2018-07-24 21:30:37 +08:00
|
|
|
);
|
2018-08-16 19:55:41 +08:00
|
|
|
const usedExports = moduleGraph.getUsedExports(module);
|
2017-10-12 17:28:25 +08:00
|
|
|
|
2018-08-07 01:39:43 +08:00
|
|
|
if (usedExports && usedExports !== true) {
|
2017-08-08 15:32:43 +08:00
|
|
|
// we know which exports are used
|
2018-08-07 01:39:43 +08:00
|
|
|
for (const id of usedExports) {
|
|
|
|
if (id === "default") continue;
|
|
|
|
if (dep.activeExports.has(id)) continue;
|
|
|
|
if (importedModule.isProvided(id) === false) continue;
|
|
|
|
if (activeFromOtherStarExports.has(id)) continue;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2018-02-25 09:00:20 +08:00
|
|
|
} else if (
|
2018-08-07 01:39:43 +08:00
|
|
|
usedExports &&
|
2018-02-25 09:00:20 +08:00
|
|
|
importedModule &&
|
|
|
|
Array.isArray(importedModule.buildMeta.providedExports)
|
|
|
|
) {
|
2017-08-08 15:32:43 +08:00
|
|
|
// not sure which exports are used, but we know which are provided
|
2017-12-07 00:39:42 +08:00
|
|
|
const unused = importedModule.buildMeta.providedExports.every(id => {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (id === "default") return true;
|
|
|
|
if (dep.activeExports.has(id)) return true;
|
|
|
|
if (activeFromOtherStarExports.has(id)) return true;
|
2017-08-08 15:32:43 +08:00
|
|
|
return false;
|
|
|
|
});
|
2018-07-23 20:53:50 +08:00
|
|
|
return !unused;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
2018-07-23 20:53:50 +08:00
|
|
|
return true;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
2017-08-08 15:32:43 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2018-07-24 23:35:36 +08:00
|
|
|
/**
|
|
|
|
* @param {HarmonyExportImportedSpecifierDependency} dep dependency
|
2018-08-07 20:20:53 +08:00
|
|
|
* @param {Module} module the current module
|
2018-07-24 23:35:36 +08:00
|
|
|
* @param {ModuleGraph} moduleGraph the module graph
|
2018-08-08 20:12:54 +08:00
|
|
|
* @returns {InitFragment} the generated init fragment
|
2018-07-24 23:35:36 +08:00
|
|
|
*/
|
2018-08-08 20:12:54 +08:00
|
|
|
_getExportFragment(dep, module, moduleGraph) {
|
2018-07-24 23:35:36 +08:00
|
|
|
const mode = dep.getMode(moduleGraph, false);
|
2018-07-24 21:30:37 +08:00
|
|
|
const importedModule = moduleGraph.getModule(dep);
|
2018-07-24 23:35:36 +08:00
|
|
|
const importVar = dep.getImportVar(moduleGraph);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
switch (mode.type) {
|
2017-08-08 15:32:43 +08:00
|
|
|
case "missing":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
|
|
|
"/* empty/unused harmony star reexport */\n",
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "unused":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
|
|
|
`${Template.toNormalComment(
|
|
|
|
`unused harmony reexport ${mode.name}`
|
|
|
|
)}\n`,
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "reexport-non-harmony-default":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-02-26 10:31:00 +08:00
|
|
|
"/* harmony reexport (default from non-harmony) */ " +
|
2018-08-08 20:12:54 +08:00
|
|
|
this.getReexportStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, mode.name),
|
|
|
|
importVar,
|
|
|
|
null
|
|
|
|
),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
2018-03-20 18:10:05 +08:00
|
|
|
case "reexport-named-default":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-03-20 18:10:05 +08:00
|
|
|
"/* harmony reexport (default from named exports) */ " +
|
2018-08-08 20:12:54 +08:00
|
|
|
this.getReexportStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, mode.name),
|
|
|
|
importVar,
|
|
|
|
""
|
|
|
|
),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
2018-03-20 18:10:05 +08:00
|
|
|
);
|
|
|
|
|
2017-11-23 21:10:52 +08:00
|
|
|
case "reexport-fake-namespace-object":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-02-26 10:31:00 +08:00
|
|
|
"/* harmony reexport (fake namespace object from non-harmony) */ " +
|
2018-08-08 20:12:54 +08:00
|
|
|
this.getReexportFakeNamespaceObjectStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, mode.name),
|
|
|
|
importVar
|
|
|
|
),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
2017-11-23 21:10:52 +08:00
|
|
|
|
|
|
|
case "rexport-non-harmony-undefined":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-02-26 10:31:00 +08:00
|
|
|
"/* harmony reexport (non default export from non-harmony) */ " +
|
2018-08-08 20:12:54 +08:00
|
|
|
this.getReexportStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, mode.name),
|
|
|
|
"undefined",
|
|
|
|
""
|
|
|
|
),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
2017-11-23 21:10:52 +08:00
|
|
|
|
|
|
|
case "reexport-non-harmony-default-strict":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-02-26 10:31:00 +08:00
|
|
|
"/* harmony reexport (default from non-harmony) */ " +
|
2018-08-08 20:12:54 +08:00
|
|
|
this.getReexportStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, mode.name),
|
|
|
|
importVar,
|
|
|
|
""
|
|
|
|
),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
2017-11-23 21:10:52 +08:00
|
|
|
|
2017-08-08 15:32:43 +08:00
|
|
|
case "reexport-namespace-object":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-02-25 09:00:20 +08:00
|
|
|
"/* harmony reexport (module object) */ " +
|
2018-08-08 20:12:54 +08:00
|
|
|
this.getReexportStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, mode.name),
|
|
|
|
importVar,
|
|
|
|
""
|
|
|
|
),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "empty-star":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
|
|
|
"/* empty/unused harmony star reexport */",
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "safe-reexport":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
|
|
|
Array.from(mode.map.entries())
|
|
|
|
.map(item => {
|
|
|
|
return (
|
|
|
|
"/* harmony reexport (safe) */ " +
|
|
|
|
this.getReexportStatement(
|
|
|
|
module,
|
|
|
|
module.getUsedName(moduleGraph, item[0]),
|
|
|
|
importVar,
|
|
|
|
importedModule.getUsedName(moduleGraph, item[1])
|
|
|
|
)
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.join(""),
|
|
|
|
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
|
|
1
|
|
|
|
);
|
2017-08-08 15:32:43 +08:00
|
|
|
|
|
|
|
case "checked-reexport":
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
|
|
|
Array.from(mode.map.entries())
|
|
|
|
.map(item => {
|
|
|
|
return (
|
|
|
|
"/* harmony reexport (checked) */ " +
|
|
|
|
this.getConditionalReexportStatement(
|
|
|
|
module,
|
|
|
|
item[0],
|
|
|
|
importVar,
|
|
|
|
item[1]
|
|
|
|
) +
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.join(""),
|
|
|
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
|
|
|
dep.sourceOrder
|
|
|
|
);
|
2018-02-25 09:00:20 +08:00
|
|
|
|
|
|
|
case "dynamic-reexport": {
|
|
|
|
const activeExports = new Set([
|
|
|
|
...dep.activeExports,
|
2018-07-24 21:30:37 +08:00
|
|
|
...dep._discoverActiveExportsFromOtherStartExports(moduleGraph)
|
2018-02-25 09:00:20 +08:00
|
|
|
]);
|
|
|
|
let content =
|
|
|
|
"/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " +
|
|
|
|
importVar +
|
|
|
|
") ";
|
|
|
|
|
|
|
|
// Filter out exports which are defined by other exports
|
|
|
|
// and filter out default export because it cannot be reexported with *
|
2018-05-29 20:50:40 +08:00
|
|
|
if (activeExports.size > 0) {
|
2018-02-25 09:00:20 +08:00
|
|
|
content +=
|
|
|
|
"if(" +
|
2018-04-06 14:18:25 +08:00
|
|
|
JSON.stringify(Array.from(activeExports).concat("default")) +
|
2018-02-25 09:00:20 +08:00
|
|
|
".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
2018-05-29 20:50:40 +08:00
|
|
|
} else {
|
|
|
|
content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
|
|
|
|
}
|
2018-08-07 20:20:53 +08:00
|
|
|
const exportsName = module.exportsArgument;
|
2018-08-08 20:12:54 +08:00
|
|
|
return new InitFragment(
|
2018-02-25 09:00:20 +08:00
|
|
|
content +
|
2018-08-08 20:12:54 +08:00
|
|
|
`(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${importVar}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`,
|
|
|
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
|
|
|
dep.sourceOrder
|
2018-02-25 09:00:20 +08:00
|
|
|
);
|
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2017-08-08 15:32:43 +08:00
|
|
|
default:
|
|
|
|
throw new Error(`Unknown mode ${mode.type}`);
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
2015-10-22 03:05:01 +08:00
|
|
|
}
|
2017-01-05 02:04:43 +08:00
|
|
|
|
2017-08-08 15:32:43 +08:00
|
|
|
getReexportStatement(module, key, name, valueKey) {
|
2017-11-12 01:48:29 +08:00
|
|
|
const exportsName = module.exportsArgument;
|
2018-06-23 21:10:56 +08:00
|
|
|
const returnValue = this.getReturnValue(name, valueKey);
|
2018-02-25 09:00:20 +08:00
|
|
|
return `__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
|
|
key
|
2018-06-23 21:10:56 +08:00
|
|
|
)}, function() { return ${returnValue}; });\n`;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2017-11-23 21:10:52 +08:00
|
|
|
getReexportFakeNamespaceObjectStatement(module, key, name) {
|
|
|
|
const exportsName = module.exportsArgument;
|
2018-02-25 09:00:20 +08:00
|
|
|
return `__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
|
|
key
|
2018-05-03 00:09:24 +08:00
|
|
|
)}, function() { return __webpack_require__.t(${name}); });\n`;
|
2017-11-23 21:10:52 +08:00
|
|
|
}
|
|
|
|
|
2017-08-08 15:32:43 +08:00
|
|
|
getConditionalReexportStatement(module, key, name, valueKey) {
|
2018-06-23 21:27:10 +08:00
|
|
|
if (valueKey === false) {
|
|
|
|
return "/* unused export */\n";
|
|
|
|
}
|
2017-11-12 01:48:29 +08:00
|
|
|
const exportsName = module.exportsArgument;
|
2018-06-23 21:10:56 +08:00
|
|
|
const returnValue = this.getReturnValue(name, valueKey);
|
2018-02-25 09:00:20 +08:00
|
|
|
return `if(__webpack_require__.o(${name}, ${JSON.stringify(
|
|
|
|
valueKey
|
|
|
|
)})) __webpack_require__.d(${exportsName}, ${JSON.stringify(
|
|
|
|
key
|
2018-06-23 21:10:56 +08:00
|
|
|
)}, function() { return ${returnValue}; });\n`;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2018-06-23 21:10:56 +08:00
|
|
|
getReturnValue(name, valueKey) {
|
2018-02-25 09:00:20 +08:00
|
|
|
if (valueKey === null) {
|
2018-06-23 21:10:56 +08:00
|
|
|
return `${name}_default.a`;
|
|
|
|
}
|
|
|
|
if (valueKey === "") {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
if (valueKey === false) {
|
|
|
|
return "/* unused export */ undefined";
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
|
|
|
|
2018-06-23 21:10:56 +08:00
|
|
|
return `${name}[${JSON.stringify(valueKey)}]`;
|
2017-01-05 02:04:43 +08:00
|
|
|
}
|
2017-01-11 17:51:58 +08:00
|
|
|
};
|