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
Users sometimes import server specific code from wasp/server/* on the client and it's hard to debug. It's not obvious to new users that this is not something they shouldn't do since their IDE recommended the import.
Possible solution
We should tell the users "Hey you imported something from the server" in their browser.
It can be solved with a simple Vite plugin:
{name: "detect-server-imports-on-client",transform(code,id){constisInDotWaspFolder=id.includes(".wasp");if(isInDotWaspFolder){// Skip checking files in .wasp folder.return;}constcodeContainsServerImport=code.includes("wasp/server");if(codeContainsServerImport){thrownewError(`File ${id} contains a server import. This is not allowed in the client code.`);}},}
The user got bit by process variable only available in Node.js. We could maybe also write a heuristic for that e.g. if process.env is detected in some client code - let the users know either via a warning or an error that it's not allowed.
Users sometimes import server specific code from
wasp/server/*
on the client and it's hard to debug. It's not obvious to new users that this is not something they shouldn't do since their IDE recommended the import.Possible solution
We should tell the users "Hey you imported something from the server" in their browser.
It can be solved with a simple Vite plugin:
Recent Discord thread: https://ptb.discord.com/channels/686873244791210014/1244030234274168944/1244625849135665244
The text was updated successfully, but these errors were encountered: