-
Notifications
You must be signed in to change notification settings - Fork 18
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 build reports "fs" browser compatibility issues #988
Comments
I think this message is triggered by the |
My code is above but I got this error and Angular app not build.
Is there any solutions? |
Maybe someone could create a small reproduction repo. I could try to find some workarounds until #992 is done and |
For Vite users, this is not really an issue as the {
// ...
rollupOptions: {
external: 'fs'
}
} @maxnowack Here's a minimal repro just in case: https://stackblitz.com/edit/signaldb-repro-fs-module. |
Thanks @ngryman! I think this is the configuration options I was looking for the whole time 😀 The error doesn't pop up in your repro. However, it seems very plausible that this configuration change solves the issues and I currently don't see any real downside. I've changed it in #1144 |
Fix released with |
Wow that was fast 😀 Unfortunately I still have the issue with From my understanding, in order to be tree-shaked, functions needs to be pure (ie. no side-effects). You can manually annotate pure function declarations with Another alternative is to mark the call sites of your functions with If only tooling was simpler 😅 |
Yeah, you're right tooling currently is a mess. Especially since the transition to ESM …
|
Yes it's not really critical for Vite, except for the bundle size that could be improved for client-side usage with tree-shaking. For other bundlers than Vite, it seems that it could produce an error, perhaps with Webpack? (cc @TheeMachine). |
tried using this? |
@maxpowernz Vite already marks Node.js dependencies as external by default, so no polyfill will end up in the final bundle. The problem may still be present for other bundlers though (eg. Webpack). I don't know if they behave the same way Vite does. |
When bundling for deployment I see the following warning in the console:
The text was updated successfully, but these errors were encountered: