vite: The entry point "react" cannot be marked as external

I’m trying to set up a minimal setup to test using this for work, but something seems wrong, as the dev server just crashes immediately as you load the site in the browser with the error The entry point "react" cannot be marked as external

Repro: https://github.com/BeeeQueue/repro-vite-mf-react

  1. Install deps pnpm i
  2. Run shell’s dev server mfs/shell: pnpm dev
  3. See error in console
  4. Open dev server in browser and crash dev server

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Reactions: 7
  • Comments: 16

Most upvoted comments

Yup, that makes sense to me. I think we can remove the react from the README and from the official examples.

@gioboa precisely - mark it as broken with React until it’s fixed and link this issue. This way it will be immediately clear to developers. Trying to make it work with hacks like storing the React object in the global namespace makes things worse.

@sedx Thanks for you suggestion without the react plugin is working fine with all the latest deps (Vite 5, React 18.2.0 etc. etc.) image

I’ll look how to reintroduce the plugin and get rid of the error.

Hi all! Just remove react plugin usage from vite config. It’s solve error, but disable features of this plugin (such as HMR)

I downgrade these versions:

"@module-federation/vite": "0.2.6",
"@softarc/native-federation": "1.1.2",
"@softarc/native-federation-esbuild": "1.1.1",

and it’s working good. I will release a new version of @module-federation/vite with these dependencies. @Steelrover is this workaround working for your project?

The workaround is change your package.json and move react and react-dom in the devDeps esBuild is throwing this error, I need to investigate