vite: fail fast with a setup hint when the renderer SDK is missing

Today if you clone Nitro-V3 without cloning Nitro_Render_V3 next to it,
yarn start / yarn build fail deep inside Rolldown with:

    Failed to resolve import "@nitrots/nitro-renderer"
    from "/path/to/Nitro-V3/src/App.tsx"

which doesn't tell you what to do. Move the check up to
vite.config.mjs: when neither ../Nitro_Render_V3 nor ../renderer
exists, throw with the explicit clone-and-install steps and a pointer
to CLAUDE.md.

Also update CLAUDE.md "Commands" section:
- Add `yarn preview` (production build server, http://localhost:4173).
- Add a 4-step "Setup walkthrough" covering: clone the renderer
  sibling, yarn install on both, copy public/configuration/*.example
  to *.json, then run.

Net effect: a fresh checkout of this branch shows you exactly which
prerequisite is missing instead of a Rolldown stack trace.
This commit is contained in:
simoleo89
2026-05-12 08:48:11 +00:00
parent 8e0bcce7b9
commit 35b8493696
2 changed files with 48 additions and 0 deletions
+31
View File
@@ -21,11 +21,42 @@ read that before starting anything non-trivial.
|---|---|
| Dev server | `yarn start` |
| Production build | `yarn build` |
| Serve production build | `yarn preview` (defaults to http://localhost:4173) |
| Lint | `yarn eslint` |
| Type-check (TS 7 native, fast) | `yarn typecheck` |
| Test (Vitest, once) | `yarn test` |
| Test (watch) | `yarn test:watch` |
## Setup walkthrough
1. **Clone the renderer SDK as a sibling of this repo.**
`vite.config.mjs` resolves the `@nitrots/*` aliases against
`../Nitro_Render_V3` (preferred) or `../renderer` (legacy). If neither
exists, the dev server and build now fail fast with a message
pointing here.
```sh
cd .. # parent of Nitro-V3
git clone <renderer-repo> Nitro_Render_V3
cd Nitro_Render_V3 && yarn install
```
2. **Install client deps.**
```sh
cd ../Nitro-V3
yarn install
```
3. **Materialize the runtime configuration.** `public/configuration/`
ships `.example` files. Copy the ones you need without the `.example`
suffix and point them at your game server (websocket URL, asset
base URL, UI texts, etc.). The dev server doesn't fail if these are
missing but the client renders a blank/error screen at runtime.
4. **Run.**
- Dev: `yarn start` (Vite, HMR, includes the renderer source).
- Production preview: `yarn build && yarn preview`.
The renderer SDK (`@nitrots/nitro-renderer`) is consumed via a filesystem
link to a sibling working tree — `../Nitro_Render_V3` (preferred) or
`../renderer` (legacy). Without it, `yarn typecheck` reports TS2307 across
+17
View File
@@ -7,6 +7,23 @@ const legacyRendererRoot = resolve(__dirname, '..', 'renderer');
const currentRendererRoot = resolve(__dirname, '..', 'Nitro_Render_V3');
const rendererRoot = existsSync(currentRendererRoot) ? currentRendererRoot : legacyRendererRoot;
if(!existsSync(rendererRoot))
{
// Fail fast with a useful message instead of waiting for Rolldown to
// report "Failed to resolve import @nitrots/nitro-renderer" deep
// inside the bundle pass.
throw new Error(
'\n Nitro renderer SDK not found.\n\n' +
' vite.config.mjs expects one of these directories to exist as a sibling of this repo:\n' +
` - ${ currentRendererRoot } (preferred)\n` +
` - ${ legacyRendererRoot } (legacy)\n\n` +
' Clone the Nitro_Render_V3 repo next to Nitro-V3 and rerun:\n' +
' git clone <renderer-repo> ../Nitro_Render_V3\n' +
' cd ../Nitro_Render_V3 && yarn install\n\n' +
' (See CLAUDE.md "Commands" section for the full setup walkthrough.)\n'
);
}
const ReactCompilerConfig = {
target: '19'
};