vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.37k stars 27.02k forks source link

Production Build Failure after v14.0.2-canary.19 #58870

Open phibr0 opened 1 year ago

phibr0 commented 1 year ago

Link to the code that reproduces this issue

https://github.com/phibr0/next14-prod-build-failure

To Reproduce

See Readme or:

  1. gh repo clone phibr0/next14-prod-build-failure
  2. cd next14-prod-build-failure
  3. pnpm compare

Current vs. Expected behavior

TypeError: Cannot read properties of undefined (reading 'api')
    at 3290 (/xxx/.next/server/app/api/route.js:35:50001)
    at t (/xxx/.next/server/webpack-runtime.js:1:128)

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103
Binaries:
  Node: 18.17.1
  npm: 9.6.7
  Yarn: 1.22.21
  pnpm: 8.10.5
Relevant Packages:
  next: 14.0.4-canary.14
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.2
Next.js Config:
  output: N/A

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

Not sure, SWC transpilation

Additional context

CSV containing build results against all recent releases: https://github.com/phibr0/next14-prod-build-failure/blob/main/results.csv

phibr0 commented 11 months ago

To sum up:

sodiray commented 11 months ago

I'm also running into this. Can't use temporal in Next JS actions with the latest version of Next (14.0.2).

As a workaround, I manually downgraded to v14.0.1 to get the build to work.

kdy1 commented 10 months ago

The range of swc_core: v0.86.10 ~ v0.86.40.

https://github.com/swc-project/swc/compare/b806f925f1b27387c66b6695151bac0010b9b919...09b3003e589409e1fffe32cf5e3328d946bd270e

phibr0 commented 10 months ago

I updated the results.csv file with the build results of different versions and configurations.

I tested:

I just recently discovered that you can still use babel instead of SWC, and the results show that SWC might not actually be the root cause here. In fact, the results are pretty much the same no matter if SWC or babel was used.

Interestingly, there were a few versions where the default webpack config works, but once minifying or babel is used it fails again. Turbopack works on all versions.

gabrielalmeida commented 10 months ago

Related to https://github.com/vercel/next.js/pull/58573