mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-16 21:08:38 +08:00
## Summary - Adds the generated `@stackframe/tanstack-start` workspace package registration. - Adds TanStack Start platform macros/dependencies to the SDK template and generator. - Adds TanStack Start cookie/token-store support plus the handler SSR guard needed by Start. ## Scope This intentionally excludes Dashboard V2 routes, hooks, components, app shell logic, and dashboard API type additions. Those stay in the existing dashboard PR/branch. ## Validation - `pnpm install --lockfile-only --ignore-scripts` - `pnpm install --ignore-scripts` - `pnpm -C packages/template lint src/components-page/stack-handler-client.tsx src/lib/cookie.ts src/lib/stack-app/apps/implementations/client-app-impl.ts` Package typecheck was attempted with `pnpm -C packages/template typecheck`, but the clean worktree lacks generated package declaration outputs for workspace dependencies such as `@stackframe/stack-shared` and `@stackframe/stack-ui`. Per repo instructions, package builds/codegen are not run by agents. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * TanStack Start integration: published SDK package, example demo app, dashboard onboarding flow, framework-aware CTAs/docs, and a TanStack-specific provider for client-only auth routes. * Improved client/server auth: safer runtime guards and consistent cookie/token-store behavior across SSR and client. * **Documentation** * New Integrations guide and expanded getting-started/setup docs with TanStack Start examples and env/key guidance. * **Chores** * Template, build, tooling, and demo config updates to support the new platform. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import fs from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { defineConfig, mergeConfig } from 'vitest/config'
|
|
import sharedConfig from '../../vitest.shared'
|
|
|
|
const tanstackStartServerContextStub = fileURLToPath(new URL('./src/tanstack-start-server-context.default.ts', import.meta.url)) // THIS_LINE_PLATFORM template
|
|
|
|
const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/;
|
|
const CLIENT_VERSION_SENTINEL = "STACK_COMPILE_TIME_CLIENT_PACKAGE_VERSION_SENTINEL";
|
|
const ENFORCE_PRE: "pre" = "pre";
|
|
|
|
function getPackageVersionLabel() {
|
|
const packageJson: unknown = JSON.parse(fs.readFileSync(fileURLToPath(new URL("./package.json", import.meta.url)), "utf-8"));
|
|
if (
|
|
typeof packageJson !== "object"
|
|
|| packageJson === null
|
|
|| !("name" in packageJson)
|
|
|| typeof packageJson.name !== "string"
|
|
|| !("version" in packageJson)
|
|
|| typeof packageJson.version !== "string"
|
|
) {
|
|
throw new Error("Expected package.json to include string name and version fields.");
|
|
}
|
|
|
|
return `js ${packageJson.name}@${packageJson.version}`;
|
|
}
|
|
|
|
const replaceCompileTimeClientVersion = () => {
|
|
const packageVersionLabel = getPackageVersionLabel();
|
|
return {
|
|
name: 'stackframe vitest client version replacement',
|
|
enforce: ENFORCE_PRE,
|
|
transform(code: string, id: string) {
|
|
const filePath = id.split(/[?#]/, 1)[0];
|
|
if (!SOURCE_FILE_PATTERN.test(filePath) || !code.includes(CLIENT_VERSION_SENTINEL)) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
code: code.replaceAll(CLIENT_VERSION_SENTINEL, packageVersionLabel),
|
|
map: null,
|
|
};
|
|
},
|
|
};
|
|
};
|
|
|
|
export default mergeConfig(
|
|
sharedConfig,
|
|
defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
"@stackframe/tanstack-start/tanstack-start-server-context": tanstackStartServerContextStub, // THIS_LINE_PLATFORM template
|
|
},
|
|
},
|
|
plugins: [replaceCompileTimeClientVersion()],
|
|
}),
|
|
)
|