[Experiment] Precompile an empty native RSC renderer
Scaffolding for an experiment: the native RSC runtime, a highly
experimental runtime for rendering React Server Components on the
server. None of it is usable yet.
Pages on the native RSC runtime will import their renderer as
precompiled bundles, one per combination of internal axes, with every
variation resolved ahead of time. Next.js's build writes the generated
route entry, so it imports the right bundle by path: there's no
`module.compiled.js`-style chain of `process.env` checks at runtime,
and tracing picks up only the bundles a page uses.
This sets up that pipeline, with entries that are empty on purpose:
renderer code arrives in later steps, so this one is only the build
setup and can be reviewed on its own. The renderer's source lives in
`src/native-rsc-runtime` and is built by a `taskr` task with Rspack,
like `next`'s other runtime pre-bundles, but with a config of its own:
the existing one selects bundles with `DefinePlugin` and
`process.env`, which renderer code never reads. The config declares
the bundles, as RSC and SSR entries built per bundle type, and the
reviewed list of externals. For now the only bundle type is Node in
production.
Every variation point is an import, never a global. Engine-specific
code goes through `#engine-config`, a fork set in the sense of React's
host config, which the precompile resolves to one fork per bundle
type. This deliberately departs from Next's `module.compiled.js` and
`process.env` convention, borrowing React's instead: the renderer is
meant to run on more than one JS engine, and a fork set keeps each
engine's code out of the other engines' bundles. Outside the forks, a
lint rule keeps renderer code free of Node imports and globals. The
seam lands before any renderer code, so all renderer code starts
behind it. React and the Flight packages stay external and are
resolved by the app's build, so there's one copy per app.
Left for later steps on purpose: `dev` bundles, so `next dev` is a
build error for now, and checks on what each bundle contains.