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

The entry point "react" cannot be marked as external #16

Closed
beeequeue opened this issue Sep 16, 2023 · 21 comments
Closed

The entry point "react" cannot be marked as external #16

beeequeue opened this issue Sep 16, 2023 · 21 comments

Comments

@beeequeue
Copy link

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
@Steelrover
Copy link

@beeequeue Hi! I've got the same problem. Did you manage to solve it?

@gioboa
Copy link
Collaborator

gioboa commented Sep 26, 2023

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

@seravifer
Copy link

Moving to devDeps seems to work but now when the remote loads, React throws errors:
TypeError: Cannot read properties of null (reading 'useEffect'

@gioboa
Copy link
Collaborator

gioboa commented Oct 30, 2023

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?

@cristiano-belloni
Copy link

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?

These versions give me a peer dependency failure. Why the solution to this is downgrading?

@hans-ts
Copy link

hans-ts commented Mar 13, 2024

This is also an issue in the React example linked from the README for this project.

@pedrocandidozup
Copy link

I have the same problem, any solutions for this?

@sedx
Copy link

sedx commented Apr 23, 2024

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

@cristiano-belloni
Copy link

Can we please mention in the README that this plugin is broken and doesn't work with with react? It will save a lot of time to all the developers who try to use it and find out it is, in fact, broken.

@gioboa
Copy link
Collaborator

gioboa commented Apr 23, 2024

@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.

@gioboa
Copy link
Collaborator

gioboa commented Apr 25, 2024

I moved all the dependencies inside devDependencies object and we have no errors.
To avoid React duplication errors I read the React library from window.React in the Remote App
I updated this project here https://github.com/gioboa/react-microfrontend-demo
The famous error comes from this code https://github.com/evanw/esbuild/blob/70893e4d89bab1dbf2d512593f9e4d5bcb1f76bf/internal/bundler/bundler.go#L1813

@pedrocandidozup
Copy link

@gioboa can you look this issue? Because I said this, I put all this dependencies in "devDependencies" and the errors is gone, but I don't think this is correct.

@cristiano-belloni
Copy link

cristiano-belloni commented Apr 25, 2024

To avoid React duplication errors I read the React library from window.React

Are you saying that to make this work you can't really use singleton, but you have to save your React copy in the window object? This sounds everything but Module Federation 🤨

Wouldn't it be easter to say "this plugin is broken if you use it with React" in the README? Surely, especially if the plugin lives in this organisation, users need to know.

@gioboa
Copy link
Collaborator

gioboa commented Apr 25, 2024

@cristiano-belloni thanks for your feedback. Your suggestion could be a solution. In the newest versions of esbuild the internal implementation is changed, we are struggling with it. I would like to solve the problem because this package can help other developers. You can help as well with PRs if you want.

@cristiano-belloni
Copy link

@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.

@gioboa
Copy link
Collaborator

gioboa commented Apr 25, 2024

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

@OscarLijoBusto
Copy link

+1

@gioboa
Copy link
Collaborator

gioboa commented May 26, 2024

We are working on a new version that will definitely solves this. @ScriptedAlchemy did a big step forward, he did the official esbuild adapter and the runtime loaders too.

@T-Klug
Copy link

T-Klug commented May 28, 2024

+1 on a solution - removing the react plugin isn't an option for us, and downgrading feels incorrect. Looking forward to a new adapter and runtime loaders.

@JamesMHenderson
Copy link

@gioboa are there any timelines for the new version?

@gioboa gioboa mentioned this issue Aug 1, 2024
@gioboa
Copy link
Collaborator

gioboa commented Aug 16, 2024

We are working on a new version of this package in this PR
I'm closing this issue, if you want, you can try the new version and give us feedback. Thanks.

@gioboa gioboa closed this as completed Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests