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

[core] Prepare Next.js config for React 18 #32963

Merged
merged 1 commit into from
Jun 1, 2022

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented May 31, 2022

Next.js introduced another runtime when ran with React 18 (https://nextjs.org/docs/advanced-features/react-18/switchable-runtime). Even when the Edge runtime is not enabled, Next executes the config in the context of it, causing problems with our webpack externals check.

This PR adds a guard to run our checks only on Node runtime. It is backwards compatible with React 17.

@michaldudak michaldudak requested a review from a team May 31, 2022 15:22
@michaldudak michaldudak added the core Infrastructure work going on behind the scenes label May 31, 2022
@mui-bot
Copy link

mui-bot commented May 31, 2022

No bundle size changes

Generated by 🚫 dangerJS against 233977d

@siriwatknp
Copy link
Member

Out of curiosity, what happens if we don't do it?

@michaldudak
Copy link
Member Author

When the config is running in the Edge runtime context, the webpack externals are quite different from what we expect (they're in the shape of ['next', { ... }]). This causes the "There are other externals in the webpack config." error to be thrown.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @michaldudak

@michaldudak michaldudak merged commit a790e63 into mui:master Jun 1, 2022
@michaldudak michaldudak deleted the react-18-next-compatibility branch June 1, 2022 19:06
@michaldudak michaldudak changed the title [core] Prepare Next config for React 18 [core] Prepare Next.js config for React 18 Jun 1, 2022
@michaldudak michaldudak mentioned this pull request Jun 24, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants