Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/node-build-target.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion e2e/starter-auth/04-node-build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }`
Expand Down
2 changes: 1 addition & 1 deletion examples/starter-auth/opensaas.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/starter-auth/scripts/node-build-create-user.mjs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<opensaasDir>/dist/` so a live module (e.g. better-auth's adapter)
// can be imported in a bundler-less runtime. Purely additive — the default
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/generator/node-build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/generator/node-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<opensaasDir>/dist/` alongside the default
* `.ts` bundler form (ADR-0008).
*
Expand Down Expand Up @@ -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 `<opensaasDir>`, outside the compile
* root. To keep the compiled entry at `<opensaasDir>/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
Expand Down Expand Up @@ -202,7 +202,7 @@ function nodeBuildCompilerOptions(rootDir: string, outDir: string): ts.CompilerO

/**
* Compile the Generated bundle to a plain-Node-loadable ESM build under
* `<opensaasDir>/dist/` (ADR-0010). Additive: the caller only invokes this when
* `<opensaasDir>/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
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ export interface OutputConfig {
* with a `{"type":"module"}` marker). The compiled entry is
* `<opensaasDir>/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
Expand Down
Loading