Skip to content

Cannot run React MUI - TypeError: can't access property "jsx", H is undefined #64562

Open
@wahabmirjan

Description

Description

When I use the latest version of @wordpress/scripts, I receive a runtime error when trying to use React MUI. However, previous versions of @wordpress/scripts work just fine without causing a runtime error.

The details about the error and how to produce it are listed in the Step-by-step reproduction instructions section.

IMPORTANT NOTE:
After further testing, I noticed that the error appears when I install any @wordpress/scripts that is version 28 (i.e., at the time of writing this bug, versions 28.0.0, 28.0.1, 28.0.2, 28.1.0, 28.2.0, 28.3.0, 28.4.0, and 28.5.0 did not work).

However, there is no run time error and the script runs without any problem, when installing either of the following versions: 26.12.0 and 27.9.0 (I only tested those versions).

Step-by-step reproduction instructions

  1. Install WordPress

  2. Install @wordpress/scripts

  3. Install react-mui accoring to thie instrauctions here https://mui.com/material-ui/getting-started/installation/ (note I only installed the default installation and Roboto font

    • npm install @mui/material @emotion/react @emotion/styled
    • npm install @fontsource/roboto
  4. Create a component as follows:

import React from 'react'
import { Typography } from '@mui/material'


const MyComponent = () => {

    return (
        <div>
            <Typography>Hi</Typography>
        </div>
    )

}

export default MyComponent
  1. Run the code above, and I receive the following error:
    TypeError: Cannot read properties of undefined (reading 'jsx')

Screenshots, screen recording, code snippet

This is the error I receive:

Screenshot from 2024-08-14 10-57-27

Environment info

  • WordPress Version 6.6,1
  • OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
  • Browsers: Chrome and Firefox

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Metadata

Assignees

No one assigned

    Labels

    [Tool] WP Scripts/packages/scripts[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions