next.js: next/font bug when code is instrumented
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000
Binaries:
Node: 18.12.1
npm: 8.19.2
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.1.1
eslint-config-next: 13.1.1
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Font optimization (@next/font), SWC transpilation
Link to the code that reproduces this issue
https://github.com/frattaro/next-font-repro
To Reproduce
Clone the repo
Run npm i
Run npm run dev
Describe the Bug
When swc-plugin-coverage-instrument
swc plugin is used this error from @next/font
is triggered:
Expected Behavior
SWC is expected to be able to build without issue.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 20 (4 by maintainers)
My colleague (@jch2617) pointed out that setting
forceSwcTransforms: true
fixes the issue.EDIT: did not fix in CI
This is neither next.js’s problem or plugin’s, it’s a conflict requirement between 2 features.
next/font requires to have specific scope to call, but coverage wraps calls into paren scope to inject coverage counter. There’s no easy way to detect those 2 conflict detect each other.
Disabling coverage to specific offending line allows to skip coverage attempts to change unexpected scopes to the next/font.
No change with latest package updates