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

@@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 4.4.2
* **New Feature**
* Add `moduleId` option for specifying a custom module id.
## 4.4.0
* **New Feature**

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 = "";

View File

@@ -1,5 +0,0 @@
exports.getModuleName = function () {
return "my custom module name";
};
exports.moduleIds = true;

View File

@@ -0,0 +1,4 @@
{
"moduleIds": true,
"moduleId": "my custom module name"
}

View File

@@ -1,5 +0,0 @@
exports.getModuleName = function () {
return "my custom module name";
};
exports.moduleIds = true;

View File

@@ -0,0 +1,4 @@
{
"moduleIds": true,
"moduleId": "my custom module name"
}

View File

@@ -1,5 +0,0 @@
exports.getModuleName = function () {
return "my custom module name";
};
exports.moduleIds = true;

View File

@@ -0,0 +1,4 @@
{
"moduleIds": true,
"moduleId": "my custom module name"
}