diff --git a/packages/babel-core/src/transformation/normalize-opts.js b/packages/babel-core/src/transformation/normalize-opts.js index 0b5dedffb2d7..71b44653b712 100644 --- a/packages/babel-core/src/transformation/normalize-opts.js +++ b/packages/babel-core/src/transformation/normalize-opts.js @@ -14,7 +14,7 @@ export default function normalizeOptions(config: ResolvedConfig): {} { moduleRoot, sourceRoot = moduleRoot, - sourceFileName = filenameRelative, + sourceFileName = path.basename(filenameRelative), comments = true, compact = "auto", diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index 0977bad100c8..f34b1bc0076c 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -394,6 +394,15 @@ describe("api", function() { }); }); + it("default source map filename", function() { + return transformAsync("var a = 10;", { + filename: "/some/absolute/file/path.js", + sourceMaps: true, + }).then(function(result) { + expect(result.map.sources).toEqual(["path.js"]); + }); + }); + it("code option false", function() { return transformAsync("foo('bar');", { code: false }).then(function( result,