Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect runtime value of preset-react provided to Babel #18553

Closed
kripod opened this issue Oct 30, 2020 · 1 comment · Fixed by #19136
Closed

Respect runtime value of preset-react provided to Babel #18553

kripod opened this issue Oct 30, 2020 · 1 comment · Fixed by #19136
Assignees
Milestone

Comments

@kripod
Copy link
Contributor

kripod commented Oct 30, 2020

Feature request

Is your feature request related to a problem? Please describe.

Currently, the new JSX transform is activated automatically for React >=17. Unfortunately, the ecosystem may not be ready for that change yet: for instance, SVG inlining may break when using the new Babel transform.

Describe the solution you'd like

According to the docs of Next, the React Babel preset's options could be overridden like below:

{
  "presets": [
    [
      "next/babel",
      { "preset-react": { "runtime": "classic" } }
    ]
  ]
}

The hasJsxRuntime variable should respect this override and use the classic runtime when desired:

...(hasJsxRuntime ? { runtime: 'automatic' } : { pragma: '__jsx' }),
...options['preset-react'],
},
],
[
require('@babel/preset-typescript'),
{ allowNamespaces: true, ...options['preset-typescript'] },
],
],
plugins: [
!hasJsxRuntime && [
require('./plugins/jsx-pragma'),
{
// This produces the following injected import for modules containing JSX:
// import React from 'react';
// var __jsx = React.createElement;
module: 'react',
importAs: 'React',
pragma: '__jsx',
property: 'createElement',
},
],

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants