add moduleId option for specifying a custom module id

This commit is contained in:
Sebastian McKenzie
2015-02-21 14:29:26 +11:00
parent 5bc78b0237
commit 9a2e56f003
9 changed files with 23 additions and 17 deletions

View File

@@ -89,7 +89,7 @@ File.validOptions = [
"compact",
"resolveModuleSource",
"getModuleName",
"moduleId",
// legacy
"format",
@@ -138,6 +138,10 @@ File.prototype.normalizeOptions = function (opts) {
opts.sourceRoot = slash(opts.sourceRoot);
}
if (opts.moduleId) {
opts.moduleIds = true;
}
opts.basename = path.basename(opts.filename, path.extname(opts.filename));
opts.blacklist = util.arrayify(opts.blacklist);

View File

@@ -146,7 +146,7 @@ DefaultFormatter.prototype.isLocalReference = function (node, scope) {
DefaultFormatter.prototype.getModuleName = function () {
var opts = this.file.opts;
if (opts.getModuleName) return opts.getModuleName(opts.filename);
if (opts.moduleId) return opts.moduleId;
var filenameRelative = opts.filenameRelative;
var moduleName = "";