Skip to content

[FEATURE] Newer Babel JSX Transform #2279

@loren138

Description

@loren138

React released a new babel JSX transform in 2020 so you don't have to import React in every component but pwa-kit is not using it.

Describe the solution you'd like

Use the new transform in: https://github.com/SalesforceCommerceCloud/pwa-kit/blob/develop/packages/pwa-kit-dev/src/configs/babel/babel-config.js#L20 (and line 48 for tests)

You'd change:

require('@babel/preset-react')

to

[
    require('@babel/preset-react'),
   {  "runtime": "automatic" }
]

PR would probably be larger if it goes through and removes the now unnecessary imports of React from the template app.
Note: There is a codemod in the blog post linked below that can help with this

Describe alternatives you've considered

Adjusting my own babel.config.js file to override the default one

Additional context

Blog announcing the release: https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions