You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am planning on refactoring my monolithic SvelteKit app into various various smaller apps (not quite microservices). I have a monorepo and these modules will be used exclusively by my app. One of the modules I am planning on creating will hold database access logic.
So far I have been relying on the Svelte+Vite's ability to flag code that mistakenly references server-side code in a client context. As I move this database access logic code to its own module, I am loosing this crucial safety check. I have explored different approaches:
altering the database-access module's package.json to treat the code as server-only:
adding my database access module to the ssr.noExternal and optimezeDeps.exclude elements of vite.config.ts.
Even when applying the above configuration changes, I can still add references to this database access module within my custom Svelte components and not cause any build failures.
Should my changes from above have worked but I missed something subtle? Short of creating my own build plugin to identify uses of this server side-only module in client code, is there anything else I can try?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am planning on refactoring my monolithic SvelteKit app into various various smaller apps (not quite microservices). I have a monorepo and these modules will be used exclusively by my app. One of the modules I am planning on creating will hold database access logic.
So far I have been relying on the Svelte+Vite's ability to flag code that mistakenly references server-side code in a client context. As I move this database access logic code to its own module, I am loosing this crucial safety check. I have explored different approaches:
package.json
to treat the code as server-only:ssr.noExternal
andoptimezeDeps.exclude
elements ofvite.config.ts
.Even when applying the above configuration changes, I can still add references to this database access module within my custom Svelte components and not cause any build failures.
Should my changes from above have worked but I missed something subtle? Short of creating my own build plugin to identify uses of this server side-only module in client code, is there anything else I can try?
Any and all help appreciated.
Beta Was this translation helpful? Give feedback.
All reactions