-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Vite: server build errors when importing from *.client.ts with re-exports #8427
Comments
Related #7972? |
Thanks for providing a concise repro. Indeed #7972 is related and fixed by #8200, however re-exports by I was somewhat aware of this issue but I haven't explicitly mentioned this since the limitation of I think supporting this use case might be technically difficult, but maybe Remix team has a different idea. Not sure if this workaround is acceptable for your use case, but https://stackblitz.com/edit/github-lnx7sg?file=app%2Ffoo.client.ts //// in foo.client.ts
// export * from './stuff/foo';
export { foo } from './stuff/foo'; On a related note, Vite ecosystem in general is against "re-export barrel file" https://vitejs.dev/guide/performance.html#avoid-barrel-files, so maybe it's better to avoid re-exports anyway... (at least for new code) |
Thank you for the detailed explanation, I'll try the workaround. |
The workaround is enough for me (thanks again for the quick reply), and I don't need Remix to support this particular use case, so I guess this issue can be closed as far I'm concerned. Or maybe these limitations should be mentioned in the documentation. |
Additionally, you can use vite-env-only to mark expressions as client-only with |
Reproduction
Repo with reproduction: https://github.com/jakubmazanec/remix-server-build-bug
npm install
npm run build
System Info
Used Package Manager
npm
Expected Behavior
Builds without an error.
Actual Behavior
Build fails with error:
"foo" is not exported by "app/foo.client.ts", imported by "app/routes/_index.tsx".
If I remove the re-export from
app/foo.client.ts
and putfoo
directly into this filethen the build is ok.
The text was updated successfully, but these errors were encountered: