-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: call installBindings for Next.js 16.0.3+ compatibility #33072
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
base: develop
Are you sure you want to change the base?
fix: call installBindings for Next.js 16.0.3+ compatibility #33072
Conversation
Fixes cypress-io#32968 Starting with Next.js 16.0.3, the Turbopack bundler requires tools to proactively call installBindings() to ensure SWC bindings are loaded before webpack loaders attempt to use them. This change adds a call to installBindings() in the Next.js handler before loading the webpack configuration. The call is wrapped in a try-catch to maintain backward compatibility with Next.js versions prior to 16.0.3 where this API does not exist. Changes: - Add installBindings() call in getNextJsPackages() - Make getNextJsPackages() async to properly await installBindings() - Add test coverage for the installBindings logic - Add debug logging for troubleshooting See: vercel/next.js#85787
|
|
@FelixK-Witt thank you for opening a PR to fix this! Changes look good to me, but we need a way to test them in CI/CD. Since there really isn't a great way to unit test this currently, I am going to update the |
… JS coverage on next 16.0.3
AtofStryker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source changes look good to me. @jennifer-shehane i updated nextjs-configured and nextjs-unconfigured to next 16 to get test coverage here. Are you able to review those changes as well as the change entry?
Close #32968
User facing changelog
Fixes Next.js 16.0.3+ component testing compatibility by proactively calling the
installBindings()API.Additional details
Starting with Next.js 16.0.3, the Turbopack bundler requires tools to proactively call
installBindings()to ensure SWC bindings are loaded before webpack loaders (likenext-swc-loader) attempt to use them. Without this call, users encounter the error:Error: bindings not loaded yet. Either callloadBindingsto wait for them to be available or ensure thatinstallBindingshas already been called..This PR adds the required
installBindings()call in the Next.js webpack dev server handler, wrapped in a try-catch block to maintain backward compatibility with Next.js versions prior to 16.0.3 where this API doesn't exist.Steps to test
next.config.jsexists (notnext.config.ts)cypress open --componentAlso here's an example repo with the patch applied: https://github.com/FelixK-Witt/cypress-next-16-component-testing
How has the user experience changed?
Users on Next.js 16.0.3+ can now successfully run component tests without encountering SWC binding errors.
See: vercel/next.js#85787