fix: specify sourceFileName when generating inline sourcemaps (#10797)

This commit is contained in:
Huáng Jùnliàng 2020-02-08 06:42:18 +09:00 committed by GitHub
parent 0b3dea8f54
commit 1599e9025d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,18 +26,16 @@ function transformCode(transformFn, script) {
}
}
return transformFn(script.content, {
filename: source,
...buildBabelOptions(script),
}).code;
return transformFn(script.content, buildBabelOptions(script, source)).code;
}
/**
* Builds the Babel options for transforming the specified script, using some
* sensible default presets and plugins if none were explicitly provided.
*/
function buildBabelOptions(script) {
function buildBabelOptions(script, filename) {
return {
filename,
presets: script.presets || ["react", "es2015"],
plugins: script.plugins || [
"proposal-class-properties",
@ -45,6 +43,7 @@ function buildBabelOptions(script) {
"transform-flow-strip-types",
],
sourceMaps: "inline",
sourceFileName: filename,
};
}