Skip to content

rollup-plugin-external-globals -@vitejs/plugin-react -@rollup/plugin-commonjs have strange behavior when used together #475

@electroluxcode

Description

@electroluxcode

Describe the bug

The dev environment can run normally, but starting with 'live server' after build will result in an error

Uncaught Error: Calling `require` for "react" in an environment that doesn't expose the `require` function.
at app-DNqTmYk5.js:1:727
at app-DNqTmYk5.js:1:2472
at app-DNqTmYk5.js:1:183
at app-DNqTmYk5.js:1:3122
at app-DNqTmYk5.js:1:183
at app-DNqTmYk5.js:1:3128

and run normally in "vite": "7.1"

Reproduction

https://github.com/electroluxcode/template-vite-build/tree/fix/rolldown-vite-reproduction

Steps to reproduce

pnpm install
pnpm run build
and open index.html in live server

System Info

mac

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions