From a7061ca332cca367f40c78d65af8b44974d7b0e7 Mon Sep 17 00:00:00 2001 From: Cameron Pak Date: Fri, 27 Mar 2026 11:53:20 -0500 Subject: [PATCH 1/2] build(hooks): switch from tsc to tsup for CJS/ESM bundling Use tsup to produce proper index.js (ESM) and index.cjs (CJS) bundles instead of loose tsc output. Fixes imports in strict ESM runtimes like Deno that don't support Node-specific module resolution --- .changeset/fair-parks-notice.md | 7 +++++++ packages/hooks/package.json | 11 +++++++---- packages/hooks/tsconfig.build.json | 5 ++++- pnpm-lock.yaml | 14 +++++++++++--- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 .changeset/fair-parks-notice.md diff --git a/.changeset/fair-parks-notice.md b/.changeset/fair-parks-notice.md new file mode 100644 index 00000000..52ef1c82 --- /dev/null +++ b/.changeset/fair-parks-notice.md @@ -0,0 +1,7 @@ +--- +'@youversion/platform-react-hooks': patch +'@youversion/platform-core': patch +'@youversion/platform-react-ui': patch +--- + +Fixed hooks package bundling to produce proper CJS and ESM outputs, resolving import failures in strict ESM runtimes like Deno. diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 5de57880..0543111b 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -11,19 +11,21 @@ "url": "https://github.com/youversion/platform-sdk-react", "directory": "packages/hooks" }, - "main": "./dist/index.js", + "main": "./dist/index.cjs", "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", - "require": "./dist/index.js" + "require": "./dist/index.cjs" } }, "scripts": { - "dev": "tsc --watch", - "build": "tsc -p tsconfig.build.json", + "dev": "tsup src/index.ts --format cjs,esm --watch", + "build:js": "tsup src/index.ts --format cjs,esm", + "build:types": "tsc -p tsconfig.build.json", + "build": "pnpm build:js && pnpm build:types", "lint": "eslint . --max-warnings 0", "typecheck": "tsc --noEmit", "test": "vitest run", @@ -46,6 +48,7 @@ "@vitest/coverage-v8": "4.0.4", "eslint": "9.38.0", "jsdom": "27.0.1", + "tsup": "8.5.0", "typescript": "5.9.3", "vitest": "4.0.4" } diff --git a/packages/hooks/tsconfig.build.json b/packages/hooks/tsconfig.build.json index 5abbf5e0..9aeb6607 100644 --- a/packages/hooks/tsconfig.build.json +++ b/packages/hooks/tsconfig.build.json @@ -1,7 +1,10 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "rootDir": "src" + "rootDir": "src", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true }, "include": ["src"], "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d14d74ae..12e9f078 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -210,6 +210,9 @@ importers: jsdom: specifier: 27.0.1 version: 27.0.1(postcss@8.5.6) + tsup: + specifier: 8.5.0 + version: 8.5.0(@microsoft/api-extractor@7.53.1(@types/node@24.11.0))(@swc/core@1.13.5(@swc/helpers@0.5.17))(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1) typescript: specifier: 5.9.3 version: 5.9.3 @@ -9773,6 +9776,11 @@ snapshots: dependencies: run-applescript: 7.1.0 + bundle-require@5.1.0(esbuild@0.25.11): + dependencies: + esbuild: 0.25.11 + load-tsconfig: 0.2.5 + bundle-require@5.1.0(esbuild@0.25.9): dependencies: esbuild: 0.25.9 @@ -12863,12 +12871,12 @@ snapshots: tsup@8.5.0(@microsoft/api-extractor@7.53.1(@types/node@24.9.1))(@swc/core@1.13.5(@swc/helpers@0.5.17))(jiti@2.6.1)(postcss@8.5.6)(typescript@5.9.3)(yaml@2.8.1): dependencies: - bundle-require: 5.1.0(esbuild@0.25.9) + bundle-require: 5.1.0(esbuild@0.25.11) cac: 6.7.14 chokidar: 4.0.3 consola: 3.4.2 - debug: 4.4.1 - esbuild: 0.25.9 + debug: 4.4.3 + esbuild: 0.25.11 fix-dts-default-cjs-exports: 1.0.1 joycon: 3.1.1 picocolors: 1.1.1 From b19f943ed56c624162b46a2866c002954c6b8ea8 Mon Sep 17 00:00:00 2001 From: Cameron Pak Date: Fri, 27 Mar 2026 12:00:30 -0500 Subject: [PATCH 2/2] fix(hooks): emit type declarations during dev watch mode Add --dts flag to tsup watch command so consuming workspace packages get live type updates during local development. Amp-Thread-ID: https://ampcode.com/threads/T-019d303c-619e-76fe-870a-8df84da40419 Co-authored-by: Amp --- packages/hooks/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 0543111b..1fd9ff3a 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -22,7 +22,7 @@ } }, "scripts": { - "dev": "tsup src/index.ts --format cjs,esm --watch", + "dev": "tsup src/index.ts --format cjs,esm --watch --dts", "build:js": "tsup src/index.ts --format cjs,esm", "build:types": "tsc -p tsconfig.build.json", "build": "pnpm build:js && pnpm build:types",