vercel / next.js

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

next build fails on an object with a key contains U+30FB #65237

Closed mythosil closed 44 minutes ago

mythosil commented 2 weeks ago

Link to the code that reproduces this issue

https://github.com/mythosil/nextjs-issue-20240501/blob/master/pages/index.js

To Reproduce

  1. npm install
  2. npm run build

Current vs. Expected behavior

When I build the project for reproduction with Node v20.11.0, I get:

> Build error occurred
Error: Failed to collect page data for /

When I build the project with Node v20.12.2, I don't get any errors, but browsers throw Uncaught SyntaxError: Invalid or unexpected token when I access the app.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:23 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: N/A
Next.js Config:
  output: N/A

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

SWC

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

next build (local)

Additional context

It seems that minification removes quotes unexpectedly. swcMinify: false makes the build work properly.

This problem happens when an object has a key with "・" (U+30FB KATAKANA MIDDLEDOT), like { 'a・': '' } . Similar issue here: https://github.com/evanw/esbuild/issues/1599

kdy1 commented 1 day ago

It looks like https://github.com/swc-project/swc/issues/8940, and it will be fixed by the next swc_core update