Skip to content
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

Build error with serverComponentsExternalPackages on Nextjs #1788

Closed
char-ptr opened this issue Jun 12, 2024 · 3 comments
Closed

Build error with serverComponentsExternalPackages on Nextjs #1788

char-ptr opened this issue Jun 12, 2024 · 3 comments
Assignees

Comments

@char-ptr
Copy link

char-ptr commented Jun 12, 2024

Summary

I face a build a error when i use serverComponentsExternalPackages which is suggested in the readme. (i use it to prevent a error at dev complication time using turborepo.)
The issue with this approach is that it breaks standard building in NextJS 15(rc) - it works fine in Nextjs 14.


Error in question
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but go
t: undefined.
    at nk (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:56806)
    at nk (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:56729)
    at nC (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:59773)
    at nE (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:62787)
    at nk (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:53732)
    at nC (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:59773)
    at nE (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:62787)
    at nk (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:53732)
    at nC (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:59773)
    at nE (/home/-----/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:20:62787) {
  digest: '3315014112'
}
Error occurred prerendering page "/dash". Read more: https://nextjs.org/docs/messages/prerender-error

I'm not sure whether this bug originates in Nextjs or if it's something they've changed in the RC version. (seems to be the component AblyProvider which causes the error)

Thanks!

┆Issue is synchronized with this Jira Task by Unito

@VeskeR
Copy link
Contributor

VeskeR commented Jun 13, 2024

Hi @char-ptr !

Unfortunately I wasn't able to reproduce that error locally.
I've setup quick nextjs 15 RC example project with ably-js 2.1.0, you can find it here: https://github.com/VeskeR/ably-js-nextjs-15-example. It's using next@15.0.0-rc.0, App Router and works with both turbopack and without.

I've used npx create-next-app@rc for that one, and had to install ably package with --legacy-peer-deps flag enabled (there is a pretty old known issue with npm and peerDependencies where it doesn't automatically pick prerelease versions like rc releases).
If you would like to check that repo locally, you would need to install deps as npm install --legacy-peer-deps too. After that npm run dev for regular dev build and npm run dev:turbo for turbopack.

Could you please take a look at the sample app and see if you have any different configuration for your project?

@VeskeR VeskeR self-assigned this Jun 13, 2024
@char-ptr
Copy link
Author

Thanks for getting back to me!

I think i may understand why you were unable to reproduce locally. I wasn't importing my ably provider wrapper via next/dynamic (only figured it out from viewing your example repo). After switching that import over it seems to work perfectly fine.

Thanks for the guidance 😃

@VeskeR
Copy link
Contributor

VeskeR commented Jun 13, 2024

Awesome, I'm glad you were able to resolve the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants