Fix local-core Vite dev SSR for standalone starter apps · rangle/agent-native@809e96b · GitHub
Skip to content

Commit 809e96b

Browse files
committed
Fix local-core Vite dev SSR for standalone starter apps
Resolve file:@agent-native/core to monorepo source and dedupe react-router so FrameworkContext matches HydratedRouter in dev. Add Playwright dev smoke that scaffolds a standalone starter, auto-logs in, and fails on HydratedRouter or 'Unexpected Server Error' after login.
1 parent 1961774 commit 809e96b

6 files changed

Lines changed: 728 additions & 19 deletions

File tree

Lines changed: 5 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,13 @@ jobs:
187187
# cache hit); no separate `pnpm build` step needed.
188188
- run: pnpm install --frozen-lockfile
189189

190-
- name: Scaffold standalone app (starter) and verify pnpm install
191-
run: |
192-
cd "$(mktemp -d)"
193-
node "$GITHUB_WORKSPACE/packages/core/dist/cli/index.js" create test-standalone --template starter
194-
cd test-standalone
195-
# Fail fast if any workspace: or catalog: refs leaked
196-
if grep -r '"workspace:' package.json; then
197-
echo "::error::workspace:* ref found in standalone scaffold"
198-
exit 1
199-
fi
200-
if grep -r '"catalog:' package.json; then
201-
echo "::error::catalog: ref found in standalone scaffold"
202-
exit 1
203-
fi
204-
pnpm install
190+
- name: Install Playwright Chromium for dev smoke
191+
run: pnpm exec playwright install chromium
192+
193+
- name: Standalone starter dev smoke (auto-login + SSR render)
194+
# Catches Vite dev SSR failures (e.g. Meta outside HydratedRouter) that
195+
# production build alone does not surface. Also scaffolds + pnpm install.
196+
run: pnpm qa:standalone-starter-dev
205197

206198
- name: Scaffold workspace (starter + calendar + dispatch) and verify pnpm install + build
207199
# Dispatch is in the combo because it exercises the

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"test": "pnpm -r --workspace-concurrency=4 test",
2727
"test:brain-evals": "pnpm --filter brain eval:ci",
2828
"qa:cli": "tsx scripts/qa-cli-smoke.ts",
29+
"qa:standalone-starter-dev": "tsx scripts/qa-standalone-starter-dev-smoke.ts",
2930
"qa:composer-geometry": "tsx scripts/qa-composer-geometry-smoke.ts",
3031
"qa:dispatch-workspace-resources": "tsx scripts/qa-dispatch-workspace-resources-smoke.ts",
3132
"qa:template-routes": "tsx scripts/qa-template-route-matrix.ts",

‎packages/core/src/vite/client.spec.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import fs from "node:fs";
2+
import os from "node:os";
3+
import path from "node:path";
4+
import { pathToFileURL } from "node:url";
15
import { afterEach, describe, expect, it, vi } from "vitest";
26
import {
7+
_findCorePackageRoot,
8+
_getClientDedupe,
39
defineConfig,
410
isFrameworkDevPath,
511
stripMountedDevApiPath,
@@ -561,3 +567,38 @@ describe("Vite CSS build defaults", () => {
561567
});
562568
});
563569
});
570+
571+
describe("local-core dev aliases and router dedupe", () => {
572+
it("dedupes react-router when the app depends on react-router", () => {
573+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "an-vite-dedupe-"));
574+
fs.writeFileSync(
575+
path.join(tmpDir, "package.json"),
576+
JSON.stringify({
577+
dependencies: { "react-router": "^7.16.0" },
578+
}),
579+
);
580+
581+
const dedupe = _getClientDedupe(tmpDir);
582+
expect(dedupe).toContain("react-router");
583+
expect(dedupe).toContain("react-router/dom");
584+
585+
fs.rmSync(tmpDir, { recursive: true, force: true });
586+
});
587+
588+
it("resolves file:@agent-native/core to a package root with src/index.ts", () => {
589+
const coreRoot = path.resolve(import.meta.dirname, "../..");
590+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "an-vite-core-root-"));
591+
fs.writeFileSync(
592+
path.join(tmpDir, "package.json"),
593+
JSON.stringify({
594+
dependencies: {
595+
"@agent-native/core": pathToFileURL(coreRoot).href,
596+
},
597+
}),
598+
);
599+
600+
expect(_findCorePackageRoot(tmpDir)).toBe(coreRoot);
601+
602+
fs.rmSync(tmpDir, { recursive: true, force: true });
603+
});
604+
});

‎packages/core/src/vite/client.ts‎

Lines changed: 52 additions & 4 deletions

0 commit comments

Comments
 (0)