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
- In reproduction template, update typescript to latest - 5.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>)
- 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
- fix(next-core): add Array.toReversed, toSpliced, toSorted polyfills Refs: #58242 — committed to MonstraG/next.js by MonstraG 8 months ago
- Fix Javascript error in Chrome 109: `TypeError: e.hostnames.toSorted is not a function` (#1927) We use [Array.toSorted](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objec... — committed to WATonomous/watcloud-website by ben-z 7 months ago
- fix(ui): add missing array polyfills for better browser compatibility - Fixes #653 - methods: .toReversed, .toSorted, .toSpliced - Fix until they are included in next-core: https://github.com/vercel/... — committed to langfuse/langfuse by marcklingen 6 months ago
- fix(ui): add missing array polyfills for better browser compatibility (#757) - Fixes #653 - methods: .toReversed, .toSorted, .toSpliced - Fix until they are included in next-core: https://github.co... — committed to langfuse/langfuse by marcklingen 6 months ago
- vercel 빌드에서 toSorted지원 안함(polyfills missing) https://github.com/vercel/next.js/issues/58242 — committed to woo3145/woo3145.com by woo3145 4 months ago
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.