fix up node inheritance
This commit is contained in:
@@ -10,7 +10,8 @@ function CommonJSFormatter(file) {
|
|||||||
CommonJSFormatter.prototype.import = function (node, nodes) {
|
CommonJSFormatter.prototype.import = function (node, nodes) {
|
||||||
// import "foo";
|
// import "foo";
|
||||||
nodes.push(util.template("require", {
|
nodes.push(util.template("require", {
|
||||||
inherits: node,
|
//inherits: node,
|
||||||
|
|
||||||
MODULE_NAME: node.source.raw
|
MODULE_NAME: node.source.raw
|
||||||
}, true));
|
}, true));
|
||||||
};
|
};
|
||||||
@@ -29,7 +30,7 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes)
|
|||||||
if (specifier.type !== "ImportBatchSpecifier") templateName += "-key";
|
if (specifier.type !== "ImportBatchSpecifier") templateName += "-key";
|
||||||
|
|
||||||
nodes.push(util.template(templateName, {
|
nodes.push(util.template(templateName, {
|
||||||
inherits: node.specifiers.length === 1 && node,
|
//inherits: node.specifiers.length === 1 && node,
|
||||||
|
|
||||||
VARIABLE_NAME: variableName,
|
VARIABLE_NAME: variableName,
|
||||||
MODULE_NAME: node.source.raw,
|
MODULE_NAME: node.source.raw,
|
||||||
@@ -51,7 +52,7 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodes.push(util.template("exports-default", {
|
nodes.push(util.template("exports-default", {
|
||||||
inherits: node,
|
//inherits: node,
|
||||||
|
|
||||||
VALUE: ref
|
VALUE: ref
|
||||||
}, true));
|
}, true));
|
||||||
@@ -59,11 +60,11 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
|
|||||||
var assign;
|
var assign;
|
||||||
|
|
||||||
if (t.isVariableDeclaration(declar)) {
|
if (t.isVariableDeclaration(declar)) {
|
||||||
var decl = declar.declarations[0]
|
var decl = declar.declarations[0];
|
||||||
|
|
||||||
if (decl.init) {
|
if (decl.init) {
|
||||||
decl.init = util.template("exports-assign", {
|
decl.init = util.template("exports-assign", {
|
||||||
inherits: node,
|
//inherits: node,
|
||||||
|
|
||||||
VALUE: decl.init,
|
VALUE: decl.init,
|
||||||
KEY: decl.id
|
KEY: decl.id
|
||||||
@@ -73,7 +74,7 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
|
|||||||
nodes.push(declar);
|
nodes.push(declar);
|
||||||
} else {
|
} else {
|
||||||
assign = util.template("exports-assign", {
|
assign = util.template("exports-assign", {
|
||||||
inherits: node,
|
//inherits: node,
|
||||||
|
|
||||||
VALUE: declar.id,
|
VALUE: declar.id,
|
||||||
KEY: declar.id
|
KEY: declar.id
|
||||||
@@ -99,14 +100,14 @@ CommonJSFormatter.prototype._exportSpecifier = function (getRef, specifier, node
|
|||||||
if (t.isExportBatchSpecifier(specifier)) {
|
if (t.isExportBatchSpecifier(specifier)) {
|
||||||
// export * from "foo";
|
// export * from "foo";
|
||||||
nodes.push(util.template("exports-wildcard", {
|
nodes.push(util.template("exports-wildcard", {
|
||||||
inherits: inherits,
|
//inherits: inherits,
|
||||||
|
|
||||||
OBJECT: getRef()
|
OBJECT: getRef()
|
||||||
}, true));
|
}, true));
|
||||||
} else {
|
} else {
|
||||||
// export { foo } from "test";
|
// export { foo } from "test";
|
||||||
nodes.push(util.template("exports-assign-key", {
|
nodes.push(util.template("exports-assign-key", {
|
||||||
inherits: inherits,
|
//inherits: inherits,
|
||||||
|
|
||||||
VARIABLE_NAME: variableName.name,
|
VARIABLE_NAME: variableName.name,
|
||||||
OBJECT: getRef(),
|
OBJECT: getRef(),
|
||||||
@@ -116,7 +117,7 @@ CommonJSFormatter.prototype._exportSpecifier = function (getRef, specifier, node
|
|||||||
} else {
|
} else {
|
||||||
// export { foo };
|
// export { foo };
|
||||||
nodes.push(util.template("exports-assign", {
|
nodes.push(util.template("exports-assign", {
|
||||||
inherits: inherits,
|
//inherits: inherits,
|
||||||
|
|
||||||
VALUE: specifier.id,
|
VALUE: specifier.id,
|
||||||
KEY: variableName
|
KEY: variableName
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ IgnoreFormatter.prototype.importSpecifier = function () {
|
|||||||
|
|
||||||
IgnoreFormatter.prototype.export = function (node, nodes) {
|
IgnoreFormatter.prototype.export = function (node, nodes) {
|
||||||
var declar = t.toStatement(node.declaration, true);
|
var declar = t.toStatement(node.declaration, true);
|
||||||
if (declar) nodes.push(declar);
|
if (declar) nodes.push(t.inherits(declar, node));
|
||||||
};
|
};
|
||||||
|
|
||||||
IgnoreFormatter.prototype.exportSpecifier = function () {
|
IgnoreFormatter.prototype.exportSpecifier = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user