Skip to content

Commit

Permalink
[fixes #30] don’t explode when moduleId: true
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Jun 4, 2015
1 parent 27eeb6b commit 8aadde9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions fixtures/true-module-fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const foo = 5;
const bar = 6;

export { foo, bar };
9 changes: 9 additions & 0 deletions fixtures/true-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
define("true-module-fixture", ["exports"], function (exports) {
"use strict";

var foo = 5;
var bar = 6;

exports.foo = foo;
exports.bar = bar;
});
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Babel.prototype.transform = function(string, options) {
Babel.prototype.processString = function (string, relativePath) {
var options = this.copyOptions();

options.filename = options.sourceMapName = options.sourceFileName = relativePath;

if (options.moduleId === true) {
options.moduleId = replaceExtensions(this.extensionsRegex, options.filename);
}

options.filename = options.sourceMapName = options.sourceFileName = relativePath;

return this.transform(string, options).code;
};

Expand Down
17 changes: 17 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,21 @@ describe('filters files to transform', function() {
expect(output).to.eql(input);
});
});


it('moduleId === true', function() {
return build(inputPath, {
inputSourceMap: false,
sourceMap: false,
moduleId: true,
modules: 'amdStrict'
}).then(function(results) {
var outputPath = results.directory;

var output = fs.readFileSync(path.join(outputPath, 'true-module-fixture.js')).toString();
var input = fs.readFileSync(path.join(inputPath, 'true-module.js')).toString();

expect(output).to.eql(input);
});
});
});

0 comments on commit 8aadde9

Please sign in to comment.