Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default sourceFileName. #7764

Merged
merged 6 commits into from Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/babel-core/src/transformation/normalize-opts.js
Expand Up @@ -6,7 +6,10 @@ import type { ResolvedConfig } from "../config";
export default function normalizeOptions(config: ResolvedConfig): {} {
const {
filename,
filenameRelative = filename || "unknown",
cwd,
filenameRelative = typeof filename === "string"
? path.relative(cwd, filename)
: "unknown",
sourceType = "module",
inputSourceMap,
sourceMaps = !!inputSourceMap,
Expand All @@ -24,7 +27,6 @@ export default function normalizeOptions(config: ResolvedConfig): {} {

const options = {
...opts,

parserOpts: {
sourceType:
path.extname(filenameRelative) === ".mjs" ? "module" : sourceType,
Expand Down
11 changes: 11 additions & 0 deletions packages/babel-core/test/api.js
Expand Up @@ -394,6 +394,17 @@ describe("api", function() {
});
});

it("default source map filename", function() {
return transformAsync("var a = 10;", {
cwd: "/some/absolute",
filename: "/some/absolute/file/path.js",
sourceMaps: true,
}).then(function(result) {
expect(result.map.sources).toEqual(["file/path.js"]);
expect(result.map.file).toEqual("file/path.js");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this needs to be removed since you reverted that change.

});
});

it("code option false", function() {
return transformAsync("foo('bar');", { code: false }).then(function(
result,
Expand Down