diff --git a/.changeset/node-build-target.md b/.changeset/node-build-target.md index adde78b5..d5c62a74 100644 --- a/.changeset/node-build-target.md +++ b/.changeset/node-build-target.md @@ -3,7 +3,7 @@ '@opensaas/stack-core': minor --- -Add an opt-in **Node build** of the generated `.opensaas/` bundle (ADR-0010, #579). +Add an opt-in **Node build** of the generated `.opensaas/` bundle (ADR-0011, #579). Setting `output: { buildTarget: 'node' }` in `opensaas.config.ts` makes `opensaas generate` additionally compile the bundle to a plain-Node-loadable ESM form under `.opensaas/dist/` — `.js` + `.d.ts` with a `{"type":"module"}` marker — alongside the default `.ts` bundler form. The compiled entry is `.opensaas/dist/context.js`, with the Prisma client subtree at `.opensaas/dist/prisma-client/**` and the project config compiled in as a sibling, so a live module (e.g. better-auth's Prisma adapter) can be imported in a bundler-less runtime — plain Node, a Playwright e2e helper, or a build-time script — that the default `.ts` form cannot execute. diff --git a/docs/adr/0010-node-build-makes-the-bundle-loadable-without-a-bundler.md b/docs/adr/0011-node-build-makes-the-bundle-loadable-without-a-bundler.md similarity index 100% rename from docs/adr/0010-node-build-makes-the-bundle-loadable-without-a-bundler.md rename to docs/adr/0011-node-build-makes-the-bundle-loadable-without-a-bundler.md diff --git a/e2e/starter-auth/04-node-build.spec.ts b/e2e/starter-auth/04-node-build.spec.ts index 78098a72..66b972be 100644 --- a/e2e/starter-auth/04-node-build.spec.ts +++ b/e2e/starter-auth/04-node-build.spec.ts @@ -4,7 +4,7 @@ import * as path from 'path' import * as fs from 'fs' /** - * Node build verification (ADR-0010 / #579). + * Node build verification (ADR-0011 / #579). * * The Node build is the opt-in compiled form of the generated `.opensaas/` * bundle, emitted to `.opensaas/dist/` when `output: { buildTarget: 'node' }` diff --git a/examples/starter-auth/opensaas.config.ts b/examples/starter-auth/opensaas.config.ts index 716b6a08..2117d796 100644 --- a/examples/starter-auth/opensaas.config.ts +++ b/examples/starter-auth/opensaas.config.ts @@ -26,7 +26,7 @@ const isAuthor: AccessControl = ({ session }) => { * OpenSaas Configuration with Better-Auth */ export default config({ - // Emit a Node build (ADR-0010): a compiled, plain-Node-loadable form of the + // Emit a Node build (ADR-0011): a compiled, plain-Node-loadable form of the // generated bundle under `.opensaas/dist/`, in addition to the default `.ts` // bundler form. This lets the e2e `node-build.test.ts` import the compiled // context under plain Node (no bundler, no tsx) and create a user through diff --git a/examples/starter-auth/scripts/node-build-create-user.mjs b/examples/starter-auth/scripts/node-build-create-user.mjs index c38f0d94..f5a50603 100644 --- a/examples/starter-auth/scripts/node-build-create-user.mjs +++ b/examples/starter-auth/scripts/node-build-create-user.mjs @@ -1,4 +1,4 @@ -// Plain-Node verification consumer for the Node build (ADR-0010 / #579). +// Plain-Node verification consumer for the Node build (ADR-0011 / #579). // // This script is the in-repo consumer that anchors the Node build: it imports // the COMPILED bundle (`.opensaas/dist/context.js`) under plain Node — NO diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index e0a5cd61..9cceaf1f 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -236,7 +236,7 @@ export async function generateCommand() { process.exit(1) } - // Optional Node build (ADR-0010): when `output.buildTarget === 'node'`, + // Optional Node build (ADR-0011): when `output.buildTarget === 'node'`, // additionally compile the `.ts` bundle to a plain-Node-loadable ESM form // under `/dist/` so a live module (e.g. better-auth's adapter) // can be imported in a bundler-less runtime. Purely additive — the default diff --git a/packages/cli/src/generator/node-build.test.ts b/packages/cli/src/generator/node-build.test.ts index 53969537..d858475a 100644 --- a/packages/cli/src/generator/node-build.test.ts +++ b/packages/cli/src/generator/node-build.test.ts @@ -5,7 +5,7 @@ import * as os from 'os' import { buildNodeBundle, rewriteConfigImport, findEscapingConfigImport } from './node-build.js' /** - * Unit tests for the Node build emit (ADR-0010 / #579). + * Unit tests for the Node build emit (ADR-0011 / #579). * * These exercise the generator's compile-and-emit contract against a minimal, * self-contained on-disk bundle fixture (no `@opensaas/*` runtime needed): the diff --git a/packages/cli/src/generator/node-build.ts b/packages/cli/src/generator/node-build.ts index f04b9ef1..990982c8 100644 --- a/packages/cli/src/generator/node-build.ts +++ b/packages/cli/src/generator/node-build.ts @@ -3,7 +3,7 @@ import * as fs from 'fs' import ts from 'typescript' /** - * The **Node build** (ADR-0010): an opt-in, plain-Node-loadable form of the + * The **Node build** (ADR-0011): an opt-in, plain-Node-loadable form of the * Generated bundle, compiled to `/dist/` alongside the default * `.ts` bundler form (ADR-0008). * @@ -35,7 +35,7 @@ import ts from 'typescript' * The on-disk `context.ts`/`prisma-extensions.ts` import the project config via * `../opensaas.config.ts` — one level ABOVE ``, outside the compile * root. To keep the compiled entry at `/dist/context.js` (per - * ADR-0010) with a config import that resolves inside `dist/`, we stage the + * ADR-0011) with a config import that resolves inside `dist/`, we stage the * bundle plus a copy of `opensaas.config.ts` into a hidden source directory * inside the bundle, rewrite the bundle's relative `opensaas.config` imports * (of any `../` depth) to the sibling `./opensaas.config.ts`, and compile that @@ -202,7 +202,7 @@ function nodeBuildCompilerOptions(rootDir: string, outDir: string): ts.CompilerO /** * Compile the Generated bundle to a plain-Node-loadable ESM build under - * `/dist/` (ADR-0010). Additive: the caller only invokes this when + * `/dist/` (ADR-0011). Additive: the caller only invokes this when * `output.buildTarget === 'node'`, and it never touches the default `.ts` form. * * Assumes the `.ts` bundle and the Prisma client subtree diff --git a/packages/core/src/config/types.ts b/packages/core/src/config/types.ts index 12efda42..49188adc 100644 --- a/packages/core/src/config/types.ts +++ b/packages/core/src/config/types.ts @@ -2505,7 +2505,7 @@ export interface OutputConfig { * with a `{"type":"module"}` marker). The compiled entry is * `/dist/context.js`; a portable module imports it directly so * the bundler traces it AND plain Node executes it (one specifier, both - * runtimes — see ADR-0010). The default `.ts` form is unchanged and still + * runtimes — see ADR-0011). The default `.ts` form is unchanged and still * emitted; the Node build is purely additive. * * `'node'` is the only target today. The field is a string-literal union so