diff --git a/docs/start/framework/react/guide/import-protection.md b/docs/start/framework/react/guide/import-protection.md index 5646f4ecbd..f070a72e99 100644 --- a/docs/start/framework/react/guide/import-protection.md +++ b/docs/start/framework/react/guide/import-protection.md @@ -287,7 +287,7 @@ The compiler reads your code statically, which limits this guarantee: - `import()`, `require()` and `import.meta.glob` of a builder are not followed, and nothing reports them. Attach server code to a builder you imported statically. - Modules other plugins generate or rewrite (virtual modules, auto-imports, `ProvidePlugin`) are not followed either. - Imports other plugins add to your modules (auto-imports, `ProvidePlugin`) are not judged by import protection: such an import of `@tanstack/react-start/server` ships to the client. A `.server` file one of them imports is still replaced by its mock, as a file no import the compiler read brought in. -- A builder method the types don't allow, called through `as any` or plain JavaScript, isn't followed. For example, a second `.server()` on a middleware that already has one: its code can ship to the client. +- A builder method the types don't allow, called through `as any` or plain JavaScript, isn't followed. For example, a second `.server()` on a middleware that already has one, or a second `.handler()` (or `.validator()`) on a server function that is already finished: its code can ship to the client. - A `.server` file behind a neutral module outside the protected scope (`srcDirectory`, `include`) isn't caught: the scope is about importers. - Only the route factory call bound to a file's `Route` export has its `server`, `ssr` and `headers` removed. Another call with them written in its options fails the build, including one through another name (`const f = createFileRoute`); another call with options the compiler can't read warns. Code-based `createRoute` isn't supported by Start, and nothing removes its `server`. - Route options the compiler can't read build with a warning: a spread (`{ ...shared, component }`), options from a call or an import (`createFileRoute('/x')(makeOptions())`) or written to after their declaration, and a computed key. What they hold isn't code-split or removed, so any server code in them ships to the client. Write `server`, `ssr` and `headers` as properties of the options object in the route file, outside the spread. No warning: a spread of a local object literal only that spread reads, naming none of them, and a computed key naming a local string const (it stays unsplit). An edit of a route with options from a call or an import reloads the page.