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

Vite not importing jsx runtime correctly in development build #8888

Closed
7 tasks done
fuma-nama opened this issue Jul 2, 2022 · 2 comments
Closed
7 tasks done

Vite not importing jsx runtime correctly in development build #8888

fuma-nama opened this issue Jul 2, 2022 · 2 comments

Comments

@fuma-nama
Copy link

Describe the bug

A few days ago I face the #130 react error, I wanted to use development build to find the cause.
However, it throws Uncaught TypeError: jsxDevRuntime.exports.jsxDEV is not a function in the browser after build.

I found those lines in index.js

...
client.createRoot(document.getElementById("root")).render(/* @__PURE__ */ React$6.createElement(React$6.StrictMode, {
  __self: globalThis,
  __source: {
    fileName: _jsxFileName,
    lineNumber: 9,
    columnNumber: 3
  }
}, /* @__PURE__ */ React$6.createElement(App, {
  __self: globalThis,
  __source: {
    fileName: _jsxFileName,
    lineNumber: 10,
    columnNumber: 5
  }
})));

It seems that the dev runtime is not correctly imported

Reproduction

https://github.com/SonMooSans/money-blog

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 5.39 GB / 15.94 GB
  Binaries:
    Node: 16.6.2 - D:\app file\nodejs\node.EXE
    npm: 7.20.3 - D:\app file\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.62)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @vitejs/plugin-react: ^1.3.0 => 1.3.2
    vite: ^2.9.9 => 2.9.13

Used Package Manager

npm

Logs

No response

Validations

@seivan
Copy link

seivan commented Jul 6, 2022

I recall I had the same issue and

  legacy: {
    buildRollupPluginCommonjs: true
  },

made it work.
My tsconfig is

"jsx": "preserve",
"jsxImportSource": "react",
    ```

@bluwy
Copy link
Member

bluwy commented Jul 8, 2022

I think this is fixed in #8546 with plugin-react beta. Previously it's always forcing the prod version for dev build, causing this error.

@bluwy bluwy closed this as completed Jul 8, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants