Closed
Description
Verify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000
Binaries:
Node: 16.14.0
npm: 8.3.1
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.1.4
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
A version of useSubscription
interned/vendored into Next (#35746) because of its new peer-dep declaration. This version contains an arrow function which is not ES5-compatible.
Expected Behavior
Next currently states that it is ES5 compatible, so it should not contain this arrow function. #33227
I've also created #35913 to try to prevent these situations in the future.
To Reproduce
- Create a next app (e.g.
npx create-next-app@latest
) - Add a dynamic import (the code-path that contains internal
useSubscription
usage). For example, changepages/index.js
to dynamically import the Image component:
import Head from 'next/head';
import styles from '../styles/Home.module.css';
import dynamic from 'next/dynamic';
const Image = dynamic(() => import('next/image'));
- Run
next build
- Run
npx es-check es5 '.next/static/**/*.js'
Get error:
error: ES-Check: there were 1 ES version matching errors.
info:
ES-Check Error:
----
· erroring file: .next/static/chunks/pages/index-35bd0f2403564f83.js
· error: SyntaxError: Unexpected token (1:8374)
· see the printed err.stack below for context
----
SyntaxError: Unexpected token (1:8374)