diff --git a/packages/babel-core/src/transformation/normalize-opts.js b/packages/babel-core/src/transformation/normalize-opts.js index 6cd0f32447f1..16690f01d544 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 101a184089c9..4bb3d0f4058e 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -393,6 +393,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,