react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Gatsby does not use new JSX transform by default

Open jwoo0122 opened this issue 4 years ago • 7 comments

https://github.com/gatsbyjs/gatsby/pull/27615

They reverted the official support because ecosystem is not ready for that feature. If you need to use this new JSX transform feature in lastest Gatsby (in this time 2.28.2) you should manually setup babel. 스크린샷 2020-12-13 오전 4 07 49 So this section should be removed, or at least we need to add some notice.

jwoo0122 avatar Dec 12 '20 19:12 jwoo0122

As far as I can tell they just changed the default. They still support it but it's now opt-in:

Disable automatic react runtime option by default.

eps1lon avatar Dec 12 '20 19:12 eps1lon

I think the original description maybe confused since it's not enough to use new JSX transform in gatsby by only updating to [email protected] or later but it said gatsby 'uses' the new transform, not 'supports'. If it's not a big problem I can accept it.

jwoo0122 avatar Dec 12 '20 19:12 jwoo0122

I agree that the documentation should be updated to reflect the recent change. But you said they removed the support entirely which is not evident from the PR you linked. That PR only said they changed the default. It sounds like it's still supported but opt-in. Is this interpretation correct?

eps1lon avatar Dec 12 '20 19:12 eps1lon

Yes, I misundertood the change on Gatsby. You're right. Thank you for your correction! :) So gatsby 'supports' the transform, but not uses it by 'default' (opt in).

jwoo0122 avatar Dec 13 '20 05:12 jwoo0122

For anyone planning on turning on the new JSX Transform on Gatsby anyway, just add this to your gatsby-node.js and you should be fine

exports.onCreateBabelConfig = ({ actions }) => {
  actions.setBabelPlugin({
    name: '@babel/plugin-transform-react-jsx',
    options: {
      runtime: 'automatic',
    },
  });
};

Bartmr avatar Dec 16 '20 13:12 Bartmr

Update for Gatsby 4. To enable, in gatsby-config.js:

module.exports = {
  jsxRuntime: "automatic"
};

https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/#jsxruntime

igneosaur avatar Jan 07 '22 15:01 igneosaur

@igneosaur doesn't work for me :(

SylvainGibert avatar Jun 30 '22 14:06 SylvainGibert