#Cannot get onClick event to fire
1 messages · Page 1 of 1 (latest)
I noticed that I can't see entry.client code in devtools source navigator, despite it being called in the script.
all of the other files that get referenced appear in the navigation tree on the left. Not sure why entry.client does not.
ok, testing another page in incognito works - I see that I am getting an error Uncaught ReferenceError: process is not defined at loadProxy (gaxios.ts:65:9) at node_modules/gaxios/build/src/gaxios.js
not sure why it is trying to load that client side
Ok, looks like you have to segregate server only code in a mycode.server.ts
the build process is not smart enough to know that if you only reference a library in a loader / action, not to put it in the browser bundle
It is smart enough as long as the library doesn't perform any work when it is imported. If it only exports then tree-shaking works. Any calls to functions at the module scope causes it to not be tree-shakeable and need to be imported only from a .server.ts file.
This is similar to how route modules cannot perform any work outside of the loader, action and component definitions otherwise the code will get included in both bundles.
https://remix.run/docs/en/v1/pages/gotchas#server-code-in-client-bundles
The docs have a good explanation of this here and https://remix.run/docs/en/v1/guides/constraints