diff --git a/addons/docs/jest-transform-mdx.js b/addons/docs/jest-transform-mdx.js index 9ce7e098d8b1..88aa08a2716d 100644 --- a/addons/docs/jest-transform-mdx.js +++ b/addons/docs/jest-transform-mdx.js @@ -7,20 +7,6 @@ const createCompiler = require('./mdx-compiler-plugin'); const compilers = [createCompiler({})]; -const getNextTransformer = (filename, config) => { - const extension = path.extname(filename); - const jsFileName = `${filename.slice(0, -extension.length)}.js`; - const self = config.transform.find(([pattern]) => new RegExp(pattern).test(filename)); - const jsTransforms = config.transform.filter(([pattern]) => new RegExp(pattern).test(jsFileName)); - return new ScriptTransformer({ - ...config, - transform: [ - ...config.transform.filter(entry => entry !== self), - ...jsTransforms.map(([pattern, ...rest]) => [self[0], ...rest]), - ], - }); -}; - module.exports = { process(src, filename, config, { instrument }) { const result = dedent` @@ -29,6 +15,10 @@ module.exports = { import { mdx } from '@mdx-js/react' ${mdx.sync(src, { compilers, filepath: filename })} `; - return getNextTransformer(filename, config).transformSource(filename, result, instrument); + + const extension = path.extname(filename); + const jsFileName = `${filename.slice(0, -extension.length)}.js`; + + return new ScriptTransformer(config).transformSource(jsFileName, result, instrument); }, };