Open versecafe opened 6 months ago
This is not unreasonable. The way it works how it currently works is this: when compiling the frontend in islands node, the compiler actually compiles the whole application, then does dead code elimination to remove anything that's not used in the body of an island.
This is because #[component]
does not mean "guaranteed to run on the server"; an island can use a component in its body and that will be included in the WASM binary. We don't have server components guaranteed only to be on the server; we have islands guaranteed to be on the client, and shared components.
A straightforward workaround is to cfg-flag whatever server-only code you want to call in a component, and #[cfg(not(feature= "ssr"))] let foo = unreachable!();
if you are sure you don't use it in an island.
Is your feature request related to a problem? Please describe. It's a bit annoying to need to worry about the security implications of exposing every server function when some functions should be server accessible only with no exposure for components rendered only on the server, same behaviour as server side code with RSCs not needing to be exposed to clients
Describe the solution you'd like inside of a
#[component]
macro whenexperimental-islands
enabled allow allssr
dependenciesDescribe alternatives you've considered Just always making a server action even if it's never used on the client and handling the security for all of them as if they were exposed endpoints rather than internal functions.
Additional context Async RSC example as a reference over from the JS/TS world