next.js: Array.toSorted, toSliced, toReversed polyfills missing

Link to the code that reproduces this issue

https://github.com/MonstraG/toSorted-polyfill-missing-nextjs

To Reproduce

  1. In reproduction template, update typescript to latest - 5.2.2
  2. Put following in the Home file:
return [3,1,2,4].toSorted().toSpliced(1, 2).toReversed().map(x => <div key={x}>{x}</div>)
  1. run app and open it in Safari 15.6

Current vs. Expected behavior

Expected:

4
1

on the screen

Actual: Exception: .toSorted is not a function

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Wed Oct 25 13:06:34 UTC 2023
Binaries:
  Node: 20.9.0
  npm: 10.2.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.0.2-canary.25
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

Not sure

Additional context

See also https://github.com/vercel/next.js/discussions/44148. Without this, claim of supporting safari 12 is invalid. There may be additional polyfills missing.

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 14
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@timneutkens the polyfills would be super helpful for our projects and I would love to see them merged

In the meantime, you can view the pr and add the same imports in your projects manually.

The same. browserlist in a package.json or target in a tsconfig file changes give nothing.

Edit: Same bug exists on the 109 ver. of Chrome.