-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
ssr build / bundling wrong export from packages.json #448
Comments
Previous discussion: #421 (comment) Current status: I don't think there's a good way to solve it as of now. So, we would like to look for a workaround. |
So, can adding Does anyone have any other workaround ideas? |
This is not a specific case - I have tried some other Libraries which are all optimized for RSC and work with NextJS. They provide alternative code for RSC and SSR in their package.json export definition. All of them fail because the current build pipeline will alway prefer the browser modules for SSR and RSC. I did choose this component as an example as it is a really simple one. |
My bad. It's not about vite, but the runtime. So, it doesn't work. |
Yeah, all of them would fail. Can you list all libraries you tried in this PR description? Let's tackle this after v0.20.0. I really wish Vite will support two and more module graphs. (Another issue is that the "build" in Waku is quite slow.) |
I wonder if #90 is related, because it's close to Next.js. |
I know this is not a specific case. |
On second thought, Vite won't be supporting it anytime soon. So, let's target this for v0.19.3. |
maybe the new experimental Vite 5.1 beta Runtime API can help |
#421 (comment) I just realized it again that this is PRD only issue, as the PR titles says. I'm curious why DEV works without the error. 🤔 |
Looks promising. Also for #113. |
Okay, I think it's going to be a fairly easy fix for now. Will work on it. |
@aheissenberger Can you try #457 and see if it works as expected? |
@dai-shi 👏 - great work 💯 |
Example:
react-textarea-autosize
topackage.json
- this is a package optimized for react ssr with 2.5 Mio downloads and 1.279 dependents!pnpm waku build --with-ssr
Error:
ReferenceError: document is not defined
The reason is that Waku bundles the wrong module
node_modules/react-textarea-autosize/dist/react-textarea-autosize.browser.esm.js
intorsc2-fcfef706c.js
which is optimized for the browser and fails in nodejs when accessing the globaldocument
.The correct file would be
node_modules/react-textarea-autosize/dist/react-textarea-autosize.esm.js
based on the"exports"
section if thepackage.json
.Output:
Status:
pnpm waku dev --with-ssr
- no Errors or Problems with the resulting websitepnpm waku build && pnpm waku start
- no Errors or Problems with the resulting websiteThe text was updated successfully, but these errors were encountered: