-
Notifications
You must be signed in to change notification settings - Fork 2k
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
TypeError: module.require is not a function
error when running with turbopack
#8004
Comments
I wanted to look into this, but when I checked out @MersadHabibi's linked repo and ran
I'd be happy to look in more detail given a full detailed reproduction that requires no creativity on my part. Though it does seem likely that this is just some overzealous optimization on "turbopack"'s part? |
That said, I see |
Apparently Next.JS "Turbopack" runs code in a weird semi-Node environment that doesn't have module.require. We don't want to call require directly because that makes other bundlers put in polyfills. So make Turbopack use sha.js instead of just throwing. Non-ideal but better than what we have today. For apollographql/apollo-server#8004
use |
Apparently Next.JS "Turbopack" runs code in a weird semi-Node environment that doesn't have module.require. We don't want to call require directly because that makes other bundlers put in polyfills. So make Turbopack use sha.js instead of just throwing. Non-ideal but better than what we have today. For apollographql/apollo-server#8004 Co-authored-by: Trevor Scheer <[email protected]>
Apparently Next.JS "Turbopack" runs code in a weird semi-Node environment that doesn't have module.require. We don't want to call require directly because that makes other bundlers put in polyfills. So make Turbopack use sha.js instead of just throwing. Non-ideal but better than what we have today. For apollographql/apollo-server#8004 Co-authored-by: Trevor Scheer <[email protected]>
#468) Apparently Next.JS "Turbopack" runs code in a weird semi-Node environment that doesn't have module.require. We don't want to call require directly because that makes other bundlers put in polyfills. So make Turbopack use sha.js instead of just throwing. Non-ideal but better than what we have today. For apollographql/apollo-server#8004 Co-authored-by: David Glasser <[email protected]>
For compatibility with Next.js Turbopack. Fixes #8004.
For compatibility with Next.js Turbopack. Fixes #8004.
For compatibility with Next.js Turbopack. Fixes #8004.
Hi, I hope that #8010 fixes this. Because there was no fully detailed reproduction requiring no creativity on my part, I haven't been able to test this. You should be able to test this out from the CodeSandbox prerelease with |
I've confirmed that this fixes the issue, thanks so much! |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @apollo/[email protected] ### Patch Changes - [#8010](#8010) [`f4228e8`](f4228e8) Thanks [@glasser](https://github.com/glasser)! - Compatibility with Next.js Turbopack. Fixes #8004. - Updated dependencies \[[`f4228e8`](f4228e8), [`70eecce`](70eecce)]: - @apollo/[email protected] ## @apollo/[email protected] ### Patch Changes - [#8010](#8010) [`f4228e8`](f4228e8) Thanks [@glasser](https://github.com/glasser)! - Compatibility with Next.js Turbopack. Fixes #8004. ## @apollo/[email protected] ### Patch Changes - [#8010](#8010) [`f4228e8`](f4228e8) Thanks [@glasser](https://github.com/glasser)! - Compatibility with Next.js Turbopack. Fixes #8004. - [#8005](#8005) [`70eecce`](70eecce) Thanks [@Meschreiber](https://github.com/Meschreiber)! - Remove Discord link from README.md and templates --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: David Glasser <[email protected]>
OK, then this should be fixed in |
Issue Description
Apologies if this should be an FR, or an issue on a different project. I'm finding it hard to work out if nextjs + turbopack + apollo server is supposed to be supported or not, and what's stopping it from working at the moment.
In any case, when trying to run
next dev --turbo
on a project with apollo server, I get a bunch ofTypeError: module.require is not a function
errors whenever the gql endpoint is hit, and no data is returned. Running without--turbo
(i.e. using webpack) works fine.Related issues:
apollo-server-integrations/apollo-server-integration-next#172
apollo-server-integrations/apollo-server-integration-next#232
vercel/next.js#72573
Thanks
Link to Reproduction
See vercel/next.js#72573
Reproduction Steps
See vercel/next.js#72573
The text was updated successfully, but these errors were encountered: