make system module formatter modules anonymous by default - fixes #347
This commit is contained in:
@@ -35,6 +35,7 @@ File.normaliseOptions = function (opts) {
|
||||
experimental: false,
|
||||
playground: false,
|
||||
whitespace: true,
|
||||
moduleIds: opts.amdModuleIds || false,
|
||||
blacklist: [],
|
||||
whitelist: [],
|
||||
sourceMap: false,
|
||||
|
||||
@@ -55,7 +55,7 @@ AMDFormatter.prototype.transform = function (ast) {
|
||||
*/
|
||||
|
||||
AMDFormatter.prototype.getModuleName = function () {
|
||||
if (this.file.opts.amdModuleIds) {
|
||||
if (this.file.opts.moduleIds) {
|
||||
return DefaultFormatter.prototype.getModuleName.apply(this, arguments);
|
||||
} else {
|
||||
return null;
|
||||
|
||||
@@ -12,14 +12,10 @@ function SystemFormatter(file) {
|
||||
this.noInteropRequire = true;
|
||||
|
||||
AMDFormatter.apply(this, arguments);
|
||||
|
||||
this.moduleNameLiteral = t.literal(this.getModuleName());
|
||||
}
|
||||
|
||||
util.inherits(SystemFormatter, AMDFormatter);
|
||||
|
||||
SystemFormatter.prototype.getModuleName = DefaultFormatter.prototype.getModuleName;
|
||||
|
||||
SystemFormatter.prototype._exportsWildcard = function (objectIdentifier) {
|
||||
var leftIdentifier = t.identifier("i");
|
||||
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
|
||||
@@ -67,8 +63,11 @@ SystemFormatter.prototype.buildRunnerSetters = function () {
|
||||
SystemFormatter.prototype.transform = function (ast) {
|
||||
var program = ast.program;
|
||||
|
||||
var moduleName = this.getModuleName();
|
||||
var moduleNameLiteral = t.literal(moduleName);
|
||||
|
||||
var runner = util.template("system", {
|
||||
MODULE_NAME: this.moduleNameLiteral,
|
||||
MODULE_NAME: moduleNameLiteral,
|
||||
MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
|
||||
EXPORT_IDENTIFIER: this.exportIdentifier,
|
||||
SETTERS: this.buildRunnerSetters(),
|
||||
@@ -76,6 +75,8 @@ SystemFormatter.prototype.transform = function (ast) {
|
||||
}, true);
|
||||
|
||||
var handlerBody = runner.expression.arguments[2].body.body;
|
||||
if (!moduleName) runner.expression.arguments.shift();
|
||||
|
||||
var returnStatement = handlerBody.pop();
|
||||
|
||||
// hoist up function declarations for circular references
|
||||
|
||||
Reference in New Issue
Block a user