Skip to content

Commit bb9b2e0

Browse files
Azzerty23claude
andcommitted
fix(build): prevent node:async_hooks from leaking into client bundles
Add a browser export condition to @zenstackhq/orm so that browser bundlers (Turbopack, webpack) use an empty stub instead of dist/index.mjs, which imports node:async_hooks via internal-context.ts. Also include the Node.js version in the CI pnpm cache key to prevent native module (better-sqlite3) ABI mismatches after a Node.js upgrade. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 367b1b4 commit bb9b2e0

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ jobs:
8080
uses: actions/cache@v4
8181
with:
8282
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
83-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
83+
key: ${{ runner.os }}-node-${{ matrix.node-version }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
8484
restore-keys: |
85-
${{ runner.os }}-pnpm-store-
85+
${{ runner.os }}-node-${{ matrix.node-version }}-pnpm-store-
8686
8787
- name: Install dependencies
8888
run: pnpm install --frozen-lockfile

packages/orm/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
],
2727
"exports": {
2828
".": {
29+
"browser": "./dist/browser.mjs",
2930
"import": {
3031
"types": "./dist/index.d.mts",
3132
"default": "./dist/index.mjs"

packages/orm/src/browser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @zenstackhq/orm is a server-only package.
2+
// This stub is used by browser bundlers (e.g. Turbopack, webpack) to prevent
3+
// Node.js-specific modules (node:async_hooks, etc.) from entering client bundles.
4+
// Types are still resolved from the main entry via the "types" export condition.
5+
export {};

packages/orm/tsdown.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createConfig } from '@zenstackhq/tsdown-config';
33
export default createConfig({
44
entry: {
55
index: 'src/index.ts',
6+
browser: 'src/browser.ts',
67
schema: 'src/schema.ts',
78
helpers: 'src/helpers.ts',
89
'common-types': 'src/common-types.ts',

0 commit comments

Comments
 (0)