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