vercel/next.js

Next.js+ React 19 incompatible with the code that was precompiled using react compiler

faradaytrs opened this issue · 1 comments

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/frosty-bird-xx8pz9

To Reproduce

Import components from packages precompiled using the babel-plugin-react-compiler targeting React 19.
Build and run a Next.js project using the app directory and the precompiled dependencies.

Screenshot 2024-12-20 at 16 54 52

Current vs. Expected behavior

The Next.js project builds and runs without errors during prerendering or runtime.
• Precompiled packages function correctly with React 19 and the updated React Compiler.
• Build errors during prerendering in the Next.js project.
• Runtime errors in react-compiler-runtime.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:26 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8122
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 23.3.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.15.0
Relevant Packages:
  next: 15.1.2
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

I believe it's because nextjs isn't really using stable react build.

This setup worked fine till we upgraded to react 19

Screenshot 2024-12-20 at 16 57 26

We precompile UI libraries and don't rely on bundler in the nextjs project, it's recommended setup by react team.

At this point we are not ready to use nextjs reactCompiler experimental feature, we just want to use precompiled libraries in our NextJS project