add optional to keep module id extensions - fixes #420

This commit is contained in:
Sebastian McKenzie 2015-01-13 01:12:14 +11:00
parent 831b420df3
commit df9fa32b82
3 changed files with 36 additions and 31 deletions

View File

@ -26,6 +26,7 @@ commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", fals
commander.option("-m, --module-ids", "Insert module id in modules", false); commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code"); commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
commander.option("-E, --include-regenerator", "Include the regenerator runtime if necessary", false); commander.option("-E, --include-regenerator", "Include the regenerator runtime if necessary", false);
commander.option("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.on("--help", function(){ commander.on("--help", function(){
var outKeys = function (title, obj) { var outKeys = function (title, obj) {
@ -101,6 +102,7 @@ if (errors.length) {
// //
exports.opts = { exports.opts = {
keepModuleIdExtensions: commander.keepModuleIdExtensions,
includeRegenerator: commander.includeRegenerator, includeRegenerator: commander.includeRegenerator,
sourceMapName: commander.outFile, sourceMapName: commander.outFile,
experimental: commander.experimental, experimental: commander.experimental,

View File

@ -48,6 +48,7 @@ File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {}); opts = _.cloneDeep(opts || {});
_.defaults(opts, { _.defaults(opts, {
keepModuleIdExtensions: false,
includeRegenerator: false, includeRegenerator: false,
experimental: false, experimental: false,
reactCompat: false, reactCompat: false,

View File

@ -156,8 +156,10 @@ DefaultFormatter.prototype.getModuleName = function () {
filenameRelative = filenameRelative.replace(sourceRootRegEx, ""); filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
} }
if (!opts.keepModuleIdExtensions) {
// remove extension // remove extension
filenameRelative = filenameRelative.replace(/\.(.*?)$/, ""); filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
}
moduleName += filenameRelative; moduleName += filenameRelative;