Storybook: MDX error: Support for the experimental syntax 'jsx' isn't currently enabled

Created on 7 Jul 2020  路  3Comments  路  Source: storybookjs/storybook

A recent change in babel has broken Storybook's MDX configuration in CRA, with the error: Support for the experimental syntax 'jsx' isn't currently enabled.

More info here: https://github.com/storybookjs/storybook/pull/11422#issuecomment-653939846

This is reproducible in a fresh CRA install, and the problem is present on both next and latest branches, unrelated to any code changes on our side.

cc @tooppaaa @ndelangen

docs bug has workaround mdx

Most helpful comment

There are two workarounds for this issue. For React projects (e.g. CRA) that have the following line in their main.js:

module.exports = {
  addons: [
    '@storybook/addon-docs'
  ]
};

Update to:

module.exports = {
  addons: [
    {
       name: '@storybook/addon-docs',
       options: { configureJSX: true }
    }
  ]
};

If you use <>blah</> style fragments in your MDX, this will unlock a second bug (presumably from the same underlying source): transform-react-jsx: pragma has been set but pragmaFrag has not been set.

For now, the workaround is to rewrite those fragments as <React.Fragment>blah</React.Fragment>.

We're working on:

  1. A better workaround for the fragment issue
  2. A proper fix to both issues

All 3 comments

There are two workarounds for this issue. For React projects (e.g. CRA) that have the following line in their main.js:

module.exports = {
  addons: [
    '@storybook/addon-docs'
  ]
};

Update to:

module.exports = {
  addons: [
    {
       name: '@storybook/addon-docs',
       options: { configureJSX: true }
    }
  ]
};

If you use <>blah</> style fragments in your MDX, this will unlock a second bug (presumably from the same underlying source): transform-react-jsx: pragma has been set but pragmaFrag has not been set.

For now, the workaround is to rewrite those fragments as <React.Fragment>blah</React.Fragment>.

We're working on:

  1. A better workaround for the fragment issue
  2. A proper fix to both issues

Ol茅!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.45 containing PR #11448 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

Yay!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.20 containing PR #11448 that references this issue. Upgrade today to try it out!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChucKN0risK picture ChucKN0risK  路  74Comments

joeruello picture joeruello  路  79Comments

ilyaulyanov picture ilyaulyanov  路  100Comments

maraisr picture maraisr  路  119Comments

moimikey picture moimikey  路  67Comments