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..1fd9ff3a 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 --dts", + "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