storybookjs/storybook
View on GitHub[Bug]: Docs addon jest mdx transformer needs `process` method
Open
#23,053 opened on Jun 13, 2023
addon: docsbugcompatibility with other toolshelp wantedmdx
Repository metrics
- Stars
- (89,909 stars)
- PR merge metrics
- (Avg merge 7d 22h) (184 merged PRs in 30d)
Description
Describe the bug
When configuring Jest to transform .mdx stories and testing with Storyshots, I get the following error:
Error: ● Invalid synchronous transformer module:
"/Users/btepe/Documents/camunda/projects/camunda-composite-components/node_modules/@storybook/addon-docs/jest-transform-mdx.js" specified in the "transform" object of Jest configuration
must export a `process` function.
Code Transformation Documentation:
https://jestjs.io/docs/code-transformation
According to the Jest docs, this is due to the transformer in jest-transform-mdx.js using require and therefore not using the ESM syntax:
If your codebase is ESM only, implementing the async variants are sufficient. Otherwise, if any code is loaded through require (including createRequire from within ESM), then you need to implement the synchronous process variant.
The transformer provided by the docs addon either needs to use import instead of require or define a process method.
To Reproduce
No response
System
System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M2 Pro
Binaries:
Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
Browsers:
Chrome: 114.0.5735.106
Edge: 114.0.1823.37
Firefox: 112.0.1
Safari: 16.4
npmPackages:
@storybook/addon-a11y: 7.0.20 => 7.0.20
@storybook/addon-actions: 7.0.20 => 7.0.20
@storybook/addon-docs: 7.0.20 => 7.0.20
@storybook/addon-essentials: 7.0.20 => 7.0.20
@storybook/addon-interactions: 7.0.20 => 7.0.20
@storybook/addon-links: 7.0.20 => 7.0.20
@storybook/addon-mdx-gfm: 7.0.20 => 7.0.20
@storybook/addon-storyshots: 7.0.20 => 7.0.20
@storybook/preset-scss: 1.0.3 => 1.0.3
@storybook/react: 7.0.20 => 7.0.20
@storybook/react-webpack5: 7.0.20 => 7.0.20
@storybook/test-runner: 0.10.0 => 0.10.0
@storybook/testing-library: 0.1.0 => 0.1.0
Additional context
No response