-
Notifications
You must be signed in to change notification settings - Fork 3
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
Not compatible (?) with Next.js projects using turbopack #8
Comments
It looks like Turbopack currently does not support the ability to arbitrarily define variables (in Webpack this is done using |
I was not familiar with Turbopack, but looked into it, and I don't think this will be possible for Turbopack to detect the environment until Turbopack is further along in development. It appears that Turbopack is currently in beta, and still lacks some fairly basic features/behaviors present in other build systems. Namely, there does not appear to be any mechanism for having the code detect that it's being built for browser (outside of Turbopack-specific environment variables).
|
Thanks for in-deph explanation, I really appreciate this. Tried using both nextjs 15rc and canary builds, but it's all the same. But when I moved from turbopack back to webpack I got another problem. Build fails with this message:
While running dev server I get this (same for cloned sample repo but it doesn't prevent build there of course):
I used the config you suggested in sample repo:
I also use TS, so here's my tsconfig (assume this might cause trouble, but no idea how exactly):
|
@chuguystyr Please provide a minimal example repo that produces this error while being as close to the Next.js example code as possible. Your message above seems to indicate you're using the same Next.js config file as the working example code but getting an error only in your project, so that's not enough to go off of. |
Of course, here's the repo. |
@chuguystyr Thanks. It looks like this can be resolved by removing the The reason why this repo differs from the working example repo I posted appears to be because it's using server components due to the I'm going to update the Next.js example to remove this condition to avoid future confusion. Thinking about this more, I don't think there is ever a reason for the Node.js code to be used within a Next.js build. Even if you wanted to implement OCR server-side, I don't think executing within a React Server Component would ever be how you would implement that. |
When trying to use the library inside server component in next js 14 project using turbopack like this:
I get errors like these:
It seems the error happens here when lib isn't able to get fonts:
Is there a way to fix this ?
The text was updated successfully, but these errors were encountered: