Skip to content

Commit f5c7fef

Browse files
committed
Fix issues with relative paths and double extensions.
Fixes #13.
1 parent 3c14806 commit f5c7fef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

es6.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ define([
3737

3838
babel.registerPlugin('module-resolver', moduleResolver);
3939

40-
function resolvePath (sourcePath) {
40+
function resolvePath (sourcePath, currentFile) {
4141
if (sourcePath.indexOf('!') < 0) {
42-
return 'es6!' + sourcePath;
42+
// If sourcePath is relative (ex: "./foo"), it's relative to currentFile.
43+
var absSourcePath = /^\.?\.\//.test(sourcePath) ? currentFile.replace(/[^/]*$/, "") + sourcePath :
44+
sourcePath;
45+
return 'es6!' + absSourcePath;
4346
}
4447
}
4548
var excludedOptions = ['extraPlugins', 'resolveModuleSource'];
@@ -66,7 +69,7 @@ define([
6669
return {
6770
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
6871
load: function (name, req, onload, config) {
69-
var sourceFileName = name + fileExtension;
72+
var sourceFileName = /\./.test(name) ? name : name + fileExtension;
7073
var url = req.toUrl(sourceFileName);
7174

7275
if (url.indexOf('empty:') === 0) {
@@ -92,7 +95,7 @@ return {
9295
_buildMap[name] = code;
9396
}
9497

95-
onload.fromText(code);
98+
onload.fromText(code);
9699
});
97100
},
98101

0 commit comments

Comments
 (0)