Skip to content

Commit

Permalink
Pass filename to Babel transform for better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
silvenon committed Jul 1, 2020
1 parent b3b751a commit bea1340
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/mdx/mdx-hast-to-jsx.js
Expand Up @@ -121,6 +121,7 @@ MDXContent.isMDXComponent = true`
// Check JSX nodes against imports
const babelPluginExtractImportNamesInstance = new BabelPluginExtractImportNames()
transformSync(importStatements, {
filename: options.file.path,
configFile: false,
babelrc: false,
plugins: [
Expand All @@ -135,6 +136,7 @@ MDXContent.isMDXComponent = true`
const babelPluginApplyMdxPropToExportsInstance = new BabelPluginApplyMdxProp()

const fnPostMdxTypeProp = transformSync(fn, {
filename: options.file.path,
configFile: false,
babelrc: false,
plugins: [
Expand All @@ -145,6 +147,7 @@ MDXContent.isMDXComponent = true`
}).code

const exportStatementsPostMdxTypeProps = transformSync(exportStatements, {
filename: options.file.path,
configFile: false,
babelrc: false,
plugins: [
Expand Down Expand Up @@ -250,8 +253,8 @@ export default ${fnPostMdxTypeProp}`
}

function compile(options = {}) {
this.Compiler = function (tree) {
return toJSX(tree, {}, options)
this.Compiler = function (tree, file) {
return toJSX(tree, {}, { file, ...options })
}
}

Expand Down

0 comments on commit bea1340

Please sign in to comment.