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
feat(server): split .server.ts source-protection from 'use server' RPC marker
The two markers are now complementary instead of interchangeable:
.server.{js,ts} path-level boundary: file router refuses to
serve the source to the browser.
'use server' semantic opt-in: file exports register as
RPC-callable from client code.
Concrete behaviours:
- .server.ts WITH 'use server' server action: source-protected
+ browser-side imports rewritten
to RPC stubs that POST to
/__webjs/action/<hash>/<fn>.
- .server.ts WITHOUT 'use server' server-only utility: source-
protected + browser-side imports
get a throw-at-load stub that
errors with a clear message.
- 'use server' WITHOUT .server.ts ignored (a separate lint rule
flags it). File serves to the
browser as plain TS source.
Implementation surface:
actions.js isServerFile() becomes a synchronous path-only check.
Add hasUseServerDirective() + isServerAction(). Add
serveServerOnlyStub() for the throw-at-load case.
buildActionIndex only registers RPC routes when both
markers are present.
dev.js File-serving handler dispatches between RPC stub and
server-only stub based on hasUseServerDirective().
Source protection still triggers on .server.ts alone.
Test updates assert the new behaviour: server-file guardrail tests
cover all four combinations of extension/directive presence; action
tests' fixtures now include 'use server' where they expect RPC
behaviour.
0 commit comments