modular-forms icon indicating copy to clipboard operation
modular-forms copied to clipboard

Form action triggers drizzle polyfill issues.

Open anxhirr opened this issue 9 months ago • 2 comments

For the last 24 hours I have been unable to build my project. It was giving me this error

5: import { performance } from 'perf_hooks'
            ^
6:
7: import { stringify, handleValue, arrayParser, arraySerializer } from './types.js'
error during build:
RollupError: "performance" is not exported by "__vite-browser-external", imported by "node_modules/postgres/src/connection.js".

So, apperently drizzle uses perf_hooks(and many other node libs) internally which vite is unable to polyfill outside of server. I managed to polyfill them, but each time a new error was appearing and a new lib required polyfill etc which made me realize polyfilling is not the way to go. Afaik drizzle is supposed to only run on the server and therefore inside formAction it is supposed to be on the server. After some testing I made I found out that removing drizzle from formAction solved the issue and build was successful. It works perfectly on routeAction$, globalAction$ and routeLoader$. Iirc, formAction builds on top on globalAction and therefore this was supposed to not be a problem. I must be missing something.

I will attach a sanbox or repo link below

anxhirr avatar Apr 29 '24 18:04 anxhirr

This is a known problem, see https://github.com/QwikDev/qwik/issues/5160. I will try to fix it in the next 3 months. A workaround could be to wrap you code into if (isServer) inside of formAction$.

fabian-hiller avatar Apr 29 '24 18:04 fabian-hiller

oh okay, thanks for the quick reply. Will take a look later.

anxhirr avatar Apr 29 '24 19:04 anxhirr