react/scripts
Sebastian Markbåge ef9f6e77b8
Enable passing Server References from Server to Client (#26124)
This is the first of a series of PRs, that let you pass functions, by
reference, to the client and back. E.g. through Server Context. It's
like client references but they're opaque on the client and resolved on
the server.

To do this, for security, you must opt-in to exposing these functions to
the client using the `"use server"` directive. The `"use client"`
directive lets you enter the client from the server. The `"use server"`
directive lets you enter the server from the client.

This works by tagging those functions as Server References. We could
potentially expand this to other non-serializable or stateful objects
too like classes.

This only implements server->server CJS imports and server->server ESM
imports. We really should add a loader to the webpack plug-in for
client->server imports too. I'll leave closures as an exercise for
integrators.

You can't "call" a client reference on the server, however, you can
"call" a server reference on the client. This invokes a callback on the
Flight client options called `callServer`. This lets a router implement
calling back to the server. Effectively creating an RPC. This is using
JSON for serializing those arguments but more utils coming from
client->server serialization.
2023-02-09 19:45:05 -05:00
..
babel Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
bench Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
circleci Add snapshot testing on e2e test failure (#24672) 2022-06-06 10:36:58 -07:00
devtools [DevTools][BE] Read username using gh in release script (#25270) 2022-09-15 18:12:46 -07:00
error-codes Enable passing Server References from Server to Client (#26124) 2023-02-09 19:45:05 -05:00
eslint [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
eslint-rules Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
flow Enable passing Server References from Server to Client (#26124) 2023-02-09 19:45:05 -05:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Enable passing Server References from Server to Client (#26124) 2023-02-09 19:45:05 -05:00
perf-counters [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
prettier Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
print-warnings Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
release publish-prereleases: Exit if CircleCI request fails (#26100) 2023-02-02 19:20:34 -05:00
rollup Enable passing Server References from Server to Client (#26124) 2023-02-09 19:45:05 -05:00
shared Add Edge Server Builds for workerd / edge-light (#26116) 2023-02-07 15:10:01 -05:00
tasks Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
yarn chore: upgrade to jest 24 (#15778) 2019-10-03 22:44:18 +05:30
authors AUTHORS 2013-09-09 23:42:54 -07:00