packages/mdx.macro/mdx.macro.js
function transform({ babel, filename, documentFilename }) {
  if (!filename) {
    throw new Error(
      `You must pass a filename to importMDX(). Please see the mdx.macro documentation`,
    )
  }
  let documentPath = path.join(filename, '..', documentFilename);
  let imports = `import React from 'react'\nimport { MDXTag } from '@mdx-js/tag'\n`

  // In development mode, we want to import the original document so that
  // changes will be picked up and cause a re-build.
  // Note: this relies on files with macros *not* being cached by babel.
  if (process.env.NODE_ENV === "development") {
    imports += `import '${documentPath}'\n`
  }

  let source = fs.readFileSync(documentPath, 'utf8');
  let transformedSource =
    babel.transformSync(
      imports+mdx.sync(source),
      {
        presets: [babelPresetReactApp],
        filename: documentPath,
      },
    ).code

  return writeTempFile(documentPath, transformedSource)
}
function transform({ babel, filename, documentFilename }) {
  if (!filename) {
    throw new Error(
      `You must pass a filename to importMDX(). Please see the mdx.macro documentation`,
    )
  }
  let documentPath = path.join(filename, '..', documentFilename);
  let imports = `import React from 'react'\nimport { MDXTag } from '@mdx-js/tag'\n`

  // In development mode, we want to import the original document so that
  // changes will be picked up and cause a re-build.
  // Note: this relies on files with macros *not* being cached by babel.
  if (process.env.NODE_ENV === "development") {
    imports += `import '${documentPath}'\n`
  }

  let source = fs.readFileSync(documentPath, 'utf8');
  let transformedSource =
    babel.transformSync(
      imports+mdx.sync(source),
      {
        presets: [babelPresetReactApp],
        filename: documentPath,
      },
    ).code

  return writeTempFile(documentPath, transformedSource)
}
function transform ( { babel , filename , documentFilename } ) { if ( ! filename ) { throw new Error ( ` ` , ) } let documentPath = path . join ( filename , '..' , documentFilename ) ; let imports = ` \n \n ` // In development mode, we want to import the original document so that // changes will be picked up and cause a re-build. // Note: this relies on files with macros *not* being cached by babel. if ( process . env . NODE_ENV === "development" ) { imports += ` ${ documentPath } \n ` } let source = fs . readFileSync ( documentPath , 'utf8' ) ; let transformedSource = babel . transformSync ( imports + mdx . sync ( source ) , { presets : [ babelPresetReactApp ] , filename : documentPath , } , ) . code return writeTempFile ( documentPath , transformedSource ) }
Find the import filename,
Find the import filename