Skip to content

Commit

Permalink
fix: specify sourceFileName when generating inline sourcemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Dec 3, 2019
1 parent 5440ae1 commit 4b1f2fa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/babel-standalone/src/transformScriptTags.js
Expand Up @@ -26,25 +26,24 @@ 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",
"proposal-object-rest-spread",
"transform-flow-strip-types",
],
sourceMaps: "inline",
sourceFileName: filename,
};
}

Expand Down

0 comments on commit 4b1f2fa

Please sign in to comment.