Revert "expose moduleName option - closes #158"
This reverts commit fdd1451d530e7d907b0092815adaffef4232e66a.
This commit is contained in:
parent
0eb3cda2d4
commit
32ddd638ba
@ -113,13 +113,7 @@ to5.transformFile("filename.js", options, function (err, result) {
|
|||||||
// Optionally replace all 6to5 helper declarations with a referenece to this
|
// Optionally replace all 6to5 helper declarations with a referenece to this
|
||||||
// variable. If set to `true` then the default namespace is used "to5Runtime".
|
// variable. If set to `true` then the default namespace is used "to5Runtime".
|
||||||
// Default: false
|
// Default: false
|
||||||
runtime: true,
|
runtime: true
|
||||||
|
|
||||||
// Optionally declare a function that all import filenames will be piped
|
|
||||||
// through
|
|
||||||
moduleName: function (name) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -15,13 +15,12 @@ util.inherits(AMDFormatter, CommonJSFormatter);
|
|||||||
AMDFormatter.prototype.transform = function (ast) {
|
AMDFormatter.prototype.transform = function (ast) {
|
||||||
var program = ast.program;
|
var program = ast.program;
|
||||||
var body = program.body;
|
var body = program.body;
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// build an array of module names
|
// build an array of module names
|
||||||
|
|
||||||
var names = [t.literal("exports")];
|
var names = [t.literal("exports")];
|
||||||
_.each(this.ids, function (id, name) {
|
_.each(this.ids, function (id, name) {
|
||||||
names.push(t.literal(self._moduleName(name)));
|
names.push(t.literal(name));
|
||||||
});
|
});
|
||||||
names = t.arrayExpression(names);
|
names = t.arrayExpression(names);
|
||||||
|
|
||||||
|
|||||||
@ -7,21 +7,12 @@ function CommonJSFormatter(file) {
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommonJSFormatter.prototype._moduleName = function (name) {
|
|
||||||
var fn = this.file.opts.moduleName;
|
|
||||||
if (fn) {
|
|
||||||
return fn(name);
|
|
||||||
} else {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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: this._moduleName(node.source.raw)
|
MODULE_NAME: node.source.raw
|
||||||
}, true));
|
}, true));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,7 +33,7 @@ CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes)
|
|||||||
//inherits: node.specifiers.length === 1 && node,
|
//inherits: node.specifiers.length === 1 && node,
|
||||||
|
|
||||||
VARIABLE_NAME: variableName,
|
VARIABLE_NAME: variableName,
|
||||||
MODULE_NAME: this._moduleName(node.source.raw),
|
MODULE_NAME: node.source.raw,
|
||||||
KEY: specifier.id
|
KEY: specifier.id
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,13 +15,12 @@ util.inherits(UMDFormatter, AMDFormatter);
|
|||||||
UMDFormatter.prototype.transform = function (ast) {
|
UMDFormatter.prototype.transform = function (ast) {
|
||||||
var program = ast.program;
|
var program = ast.program;
|
||||||
var body = program.body;
|
var body = program.body;
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// build an array of module names
|
// build an array of module names
|
||||||
|
|
||||||
var names = [];
|
var names = [];
|
||||||
_.each(this.ids, function (id, name) {
|
_.each(this.ids, function (id, name) {
|
||||||
names.push(t.literal(self._moduleName(name)));
|
names.push(t.literal(name));
|
||||||
});
|
});
|
||||||
|
|
||||||
// factory
|
// factory
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user