remove commonStrict module formatter
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
module.exports = CommonJSStrictFormatter;
|
||||
|
||||
var DefaultFormatter = require("./_default");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
|
||||
function CommonJSStrictFormatter() {
|
||||
DefaultFormatter.apply(this, arguments);
|
||||
}
|
||||
|
||||
util.inherits(CommonJSStrictFormatter, DefaultFormatter);
|
||||
|
||||
CommonJSStrictFormatter.prototype.import = function (node, nodes) {
|
||||
// import "foo";
|
||||
nodes.push(util.template("require", {
|
||||
//inherits: node,
|
||||
|
||||
MODULE_NAME: node.source.raw
|
||||
}, true));
|
||||
};
|
||||
|
||||
CommonJSStrictFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
|
||||
var variableName = t.getSpecifierName(specifier);
|
||||
|
||||
// import foo from "foo";
|
||||
if (specifier.default) {
|
||||
specifier.id = t.identifier("default");
|
||||
}
|
||||
|
||||
var templateName = "require-assign";
|
||||
|
||||
// import * as bar from "foo";
|
||||
if (specifier.type !== "ImportBatchSpecifier") templateName += "-key";
|
||||
|
||||
nodes.push(util.template(templateName, {
|
||||
VARIABLE_NAME: variableName,
|
||||
MODULE_NAME: node.source.raw,
|
||||
KEY: specifier.id
|
||||
}));
|
||||
};
|
||||
|
||||
CommonJSStrictFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||
this._exportSpecifier(function () {
|
||||
return t.callExpression(t.identifier("require"), [node.source]);
|
||||
}, specifier, node, nodes);
|
||||
};
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = CommonJSFormatter;
|
||||
|
||||
var CommonJSStrictFormatter = require("./common-strict");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
var DefaultFormatter = require("./_default");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
function CommonJSFormatter(file) {
|
||||
CommonJSStrictFormatter.apply(this, arguments);
|
||||
DefaultFormatter.apply(this, arguments);
|
||||
|
||||
var hasNonDefaultExports = false;
|
||||
_.each(file.ast.program.body, function (node) {
|
||||
@@ -15,13 +15,13 @@ function CommonJSFormatter(file) {
|
||||
this.hasNonDefaultExports = hasNonDefaultExports;
|
||||
}
|
||||
|
||||
util.inherits(CommonJSFormatter, CommonJSStrictFormatter);
|
||||
util.inherits(CommonJSFormatter, DefaultFormatter);
|
||||
|
||||
CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
|
||||
var variableName = t.getSpecifierName(specifier);
|
||||
|
||||
// import foo from "foo";
|
||||
if (t.isIdentifier(specifier.id) && specifier.id.name === "default") {
|
||||
if (t.isSpecifierDefault(specifier)) {
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(variableName,
|
||||
t.callExpression(this.file.addDeclaration("interop-require"), [util.template("require", {
|
||||
@@ -30,10 +30,33 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes)
|
||||
)
|
||||
]));
|
||||
} else {
|
||||
CommonJSStrictFormatter.prototype.importSpecifier.apply(this, arguments);
|
||||
// import foo from "foo";
|
||||
if (specifier.default) {
|
||||
specifier.id = t.identifier("default");
|
||||
}
|
||||
|
||||
var templateName = "require-assign";
|
||||
|
||||
// import * as bar from "foo";
|
||||
if (specifier.type !== "ImportBatchSpecifier") templateName += "-key";
|
||||
|
||||
nodes.push(util.template(templateName, {
|
||||
VARIABLE_NAME: variableName,
|
||||
MODULE_NAME: node.source.raw,
|
||||
KEY: specifier.id
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.import = function (node, nodes) {
|
||||
// import "foo";
|
||||
nodes.push(util.template("require", {
|
||||
//inherits: node,
|
||||
|
||||
MODULE_NAME: node.source.raw
|
||||
}, true));
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.export = function (node, nodes) {
|
||||
if (node.default) {
|
||||
var declar = node.declaration;
|
||||
@@ -51,10 +74,12 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
|
||||
// hoist to the top if this default is a function
|
||||
nodes.push(this._hoistExport(declar, assign));
|
||||
} else {
|
||||
CommonJSStrictFormatter.prototype.export.apply(this, arguments);
|
||||
DefaultFormatter.prototype.export.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
CommonJSFormatter.prototype.exportSpecifier = function () {
|
||||
CommonJSStrictFormatter.prototype.exportSpecifier.apply(this, arguments);
|
||||
CommonJSFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||
this._exportSpecifier(function () {
|
||||
return t.callExpression(t.identifier("require"), [node.source]);
|
||||
}, specifier, node, nodes);
|
||||
};
|
||||
|
||||
@@ -30,12 +30,11 @@ transform._ensureTransformerNames = function (type, keys) {
|
||||
transform.transformers = {};
|
||||
|
||||
transform.moduleFormatters = {
|
||||
commonStrict: require("./modules/common-strict"),
|
||||
common: require("./modules/common"),
|
||||
system: require("./modules/system"),
|
||||
ignore: require("./modules/ignore"),
|
||||
amd: require("./modules/amd"),
|
||||
umd: require("./modules/umd")
|
||||
common: require("./modules/common"),
|
||||
system: require("./modules/system"),
|
||||
ignore: require("./modules/ignore"),
|
||||
amd: require("./modules/amd"),
|
||||
umd: require("./modules/umd")
|
||||
};
|
||||
|
||||
_.each({
|
||||
|
||||
Reference in New Issue
Block a user