add comments to display what module syntax each part handles
This commit is contained in:
@@ -8,7 +8,7 @@ exports.ImportDeclaration = function (node) {
|
||||
|
||||
if (node.specifiers.length) {
|
||||
_.each(node.specifiers, function (specifier) {
|
||||
var variableName = specifier.name || specifier.id;
|
||||
var variableName = getSpecifierName(specifier.name);
|
||||
var key = specifier.id.name;
|
||||
|
||||
// import foo from "foo";
|
||||
@@ -28,6 +28,7 @@ exports.ImportDeclaration = function (node) {
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
// import "foo";
|
||||
nodes.push(util.template("require", {
|
||||
MODULE_NAME: node.source.raw
|
||||
}, true));
|
||||
@@ -38,14 +39,16 @@ exports.ImportDeclaration = function (node) {
|
||||
|
||||
var pushExportSpecifiers = function (node, nodes) {
|
||||
_.each(node.specifiers, function (specifier) {
|
||||
var variableName = specifier.name || specifier.id;
|
||||
var variableName = getSpecifierName(specifier);
|
||||
|
||||
if (node.source) {
|
||||
if (specifier.type === "ExportBatchSpecifier") {
|
||||
// export * from "foo";
|
||||
nodes.push(util.template("exports-wildcard", {
|
||||
MODULE_NAME: node.source.raw
|
||||
}, true));
|
||||
} else {
|
||||
// export { foo } from "test";
|
||||
nodes.push(util.template("exports-require-assign-key", {
|
||||
VARIABLE_NAME: variableName.name,
|
||||
MODULE_NAME: node.source.raw,
|
||||
@@ -53,6 +56,7 @@ var pushExportSpecifiers = function (node, nodes) {
|
||||
}, true));
|
||||
}
|
||||
} else {
|
||||
// export { foo };
|
||||
nodes.push(util.template("exports-assign", {
|
||||
VALUE: specifier.id,
|
||||
KEY: variableName
|
||||
@@ -61,6 +65,10 @@ var pushExportSpecifiers = function (node, nodes) {
|
||||
});
|
||||
};
|
||||
|
||||
var getSpecifierName = function (specifier) {
|
||||
return specifier.name || specifier.id;
|
||||
};
|
||||
|
||||
var pushExportDeclaration = function (node, parent, nodes) {
|
||||
var declar = node.declaration;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user