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

SyntaxError with Middle Dot (U+30FB) as Object Key in Older iOS Safari Versions #69854

Open
bubble0601 opened this issue Sep 9, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js. SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js.

Comments

@bubble0601
Copy link

bubble0601 commented Sep 9, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/tender-sun-8ygrks

To Reproduce

  1. Create a Next.js project using version 14.2.5 or newer.
  2. Use an object with the middle dot character (・, U+30FB) as a key in your JavaScript code.
  3. Build your project and serve it.
  4. Access the site using an older version of iOS Safari (e.g., Safari 17.1).
  5. Observe that you encounter a SyntaxError: Invalid character '\u30fb' and the script fails to load.

Current vs. Expected behavior

Current Behavior: In iOS Safari 17.1 and older, you encounter a SyntaxError due to the middle dot character not being properly quoted in the minified JavaScript output. This error occurs because the middle dot is now identified as a new identifier character in Unicode, which older browsers may not handle correctly.

Expected Behavior: Next.js is expected to support Safari 12 and newer. Therefore, the JavaScript output should correctly handle the middle dot character by quoting it, ensuring compatibility with Safari 12 and above.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:16:46 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 20.16.0
  npm: 10.8.1
  Yarn: 1.22.22
  pnpm: 7.29.3
Relevant Packages:
  next: 14.2.5 // There is a newer version (14.2.8) available, upgrade recommended! 
  eslint-config-next: 13.4.9
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.6
Next.js Config:
  output: export

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

SWC, Webpack

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

Other (Deployed)

Additional context

  • The issue does not occur when swcMinify is set to false in next.config.js. However, this option will be removed in Next.js 15, so a more permanent solution is needed.
  • The problem is specific to older versions of iOS Safari and does not appear in latest versions.
  • The issue does not seem to occur in other browsers or environments.
  • This issue does not reproduce in local development environments, but only in the production build served on older iOS Safari versions.
  • The problem was not present in Next.js version 13.4.9 but occurs in version 14.2.5
@bubble0601 bubble0601 added the bug Issue was opened via the bug report template. label Sep 9, 2024
@github-actions github-actions bot added Runtime Related to Node.js or Edge Runtime with Next.js. SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js. labels Sep 9, 2024
@polamjag
Copy link

polamjag commented Oct 8, 2024

Maybe duplicate of #65237?

According to this, the vercel/turborepo@a562144 and #65450 appear to fix this issue, and these versions include this fix:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js. SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants