Skip to content
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

Qwik: Vite is trying to externalize packages used in formAction$ #182

Open
stejs-code opened this issue Feb 17, 2024 · 3 comments
Open

Qwik: Vite is trying to externalize packages used in formAction$ #182

stejs-code opened this issue Feb 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@stejs-code
Copy link

When I try to build a production application, vite tries to externalize the "fs" package for the browser, but it shouldn't because "fs" is only used in the server-side function "formAction$". When I tried to do it in the native "routeAction$" function, everything worked as expected. This also occurs when using other node packages such as crypto, redis, etc.

npm run build
...
[plugin:vite:resolve] Module "fs" has been externalized for browser compatibility, imported by "/Users/tomstejskal/Work/qwik-modular-forms-bug/src/routes/index.tsx". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
src/s_gw0o54lztzw.js (9:19) "read" is not exported by "__vite-browser-external", imported by "src/s_gw0o54lztzw.js".
...

Stackblitz project

@fabian-hiller
Copy link
Owner

This is related to a missing feature or implementation in Qwik. I will link the related issue for you later. Also, I plan to add this feature to Qwik next month.

@fabian-hiller fabian-hiller self-assigned this Feb 17, 2024
@fabian-hiller
Copy link
Owner

Here is the issue: QwikDev/qwik#5160

@fabian-hiller fabian-hiller added the bug Something isn't working label Feb 18, 2024
@fabian-hiller
Copy link
Owner

You can try to wrap your code in if (isServer) {...}. This way the Qwik optimizer should be able to remove it from the client bundle. I will try investigate this issue this month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants