mirror of
https://github.com/TanStack/router.git
synced 2026-11-16 19:38:07 +00:00
test(start-plugin-core): build and dev tests run Start's real runtime
User ruling 2026-10-18 (test infrastructure must not re-implement other
tools or packages). The build harness no longer writes a hand-written
`@tanstack/react-start` into the app: `node_modules/@tanstack/react-start`
links the built workspace package (`startRuntimeLinks`), and its
dependencies (start-client-core, start-server-core, start-storage-context,
router-core, ...) resolve from its real path. The `test:unit` target now
depends on `@tanstack/react-start:build` (task-level dependsOn, no project
dependency, so no cycle). The Vite and Rsbuild dev harnesses link it too.
Stand-ins kept, only where the test process cannot run the real piece,
each checked against the real runtime:
- request context: SSR scripts and in-process server calls run in a
`StartStorageContext` (typed against the real one) of a request to `/`
(`inRequestContext`, `runInRequestContext`); contract test
build-harness.test.ts "SSR scripts run in a request context that Start's
runtime reads".
- the network: a client call's requests are observed through the call's
public `fetch` option (`requestsOf`); contract test "a server fn is
Start's RPC on the client ...".
- the server-fn HTTP handler: by-id calls resolve, call with
`{ data, method }` and unwrap `{ result }`/`{ error }` like
`handleServerAction` (`callByIdPrelude`, `callServerFnById`).
- Vite dev client evaluation loads start-client-core through Node
(`servedStartRuntime`): the root entry imports React (CommonJS), which only
Vite's dependency optimizer (off in the harness) serves to a browser.
- Rsbuild compiler-only dev server defines `TSS_SERVER_FN_BASE` like
Start's plugin; its VM gets the WinterTC web APIs a browser has.
- hydrate-build keeps its own `@tanstack/react-start` (Hydrate rendered by
a string JSX runtime); new contract test: its names are the real
package's.
Harness realism: Vite builds run in the app's directory, as `vite build`
does (Start's plugin crawls the working directory's package.json for Start
libraries to bundle in SSR); the build harness records Rsbuild's
`output.module` for the dangling-name check.
Status changes, each investigated:
- Tests that relied on the fake (`functionId`, client RPCs throwing
"client RPC <id>", `getServerFnById(id)({})` returning the bare result,
middleware `.server()` stubs, uncompiled `handler(rpc)` returning `rpc`):
rewritten to Start's real API (`serverFnMeta.id`, `url`, requests the call
sends, `{ result }` unwrapping). The library-server-fn tests passed
vacuously on Vite: the library stayed external and uncompiled in SSR,
and the stand-in's uncompiled `handler(fn)` returned `fn`. The apps now
depend on their library, as installed ones.
- Route-tree type test: the `@tanstack/react-start` d.ts stand-in is
replaced by the real package's types.
- Pins re-verified red for the same reason (with `.fails` removed, failure
messages compared to baseline 5d35383f02): 123 pin rows across the build,
dev and import-protection files are unchanged. Import-protection dev pins
load only the app's modules (Start's server package imports Start's
entries, which only Start's whole plugin provides). Library-function
pin (D13): SSR now also shows the uncompiled server fn (`undefined`
instead of the stand-in's handler result).
- NEW pin (Vite): a build run from another directory leaves a Start
library external and uncompiled in SSR (src/vite/plugin.ts:143 crawls
`process.cwd()`, not Vite's root); verified red: the SSR call returns
undefined. Rsbuild row passes.
Cheap stand-ins replaced as well: createMiddleware.test.ts
`middlewareFactoryStub`, known-bugs-start-compiler `middlewareStub` and the
string stubs of its dev servers, start-compiler-factories' middleware stub
now use Start's real builder (keeping a `.server()` trap where the test
needs one).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ed455004fd
commit
953b24f622
18 changed files with 716 additions and 349 deletions
Loading…
Add table
Add a link
Reference in a new issue