diff --git a/.changeset/fix-adapter-type-declarations.md b/.changeset/fix-adapter-type-declarations.md new file mode 100644 index 0000000..e02ec6d --- /dev/null +++ b/.changeset/fix-adapter-type-declarations.md @@ -0,0 +1,6 @@ +--- +"@payloadcms-vectorize/pg": patch +"@payloadcms-vectorize/cf": patch +--- + +Fix missing TypeScript declarations in `@payloadcms-vectorize/pg` and `@payloadcms-vectorize/cf`. The build now runs `tsc` before SWC so `dist/index.d.ts` is actually emitted, and both adapters expose modern conditional `exports` with a types-first condition. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84532f8..7057f71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -206,14 +206,41 @@ jobs: IVFFLATLISTS: 1 TEST_ENV: 1 + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Build all packages + run: pnpm build + + - name: Verify type declarations emitted + run: | + test -f dist/index.d.ts + test -f adapters/pg/dist/index.d.ts + test -f adapters/cf/dist/index.d.ts + test: runs-on: ubuntu-latest - needs: [typecheck, test_int, test_adapters_pg, test_adapters_cf, test_e2e] + needs: [typecheck, build, test_int, test_adapters_pg, test_adapters_cf, test_e2e] if: always() steps: - name: Check required jobs run: | if [ "${{ needs.typecheck.result }}" != "success" ] || \ + [ "${{ needs.build.result }}" != "success" ] || \ [ "${{ needs.test_int.result }}" != "success" ] || \ [ "${{ needs.test_adapters_pg.result }}" != "success" ] || \ [ "${{ needs.test_adapters_cf.result }}" != "success" ] || \ diff --git a/adapters/cf/package.json b/adapters/cf/package.json index b492188..8031caa 100644 --- a/adapters/cf/package.json +++ b/adapters/cf/package.json @@ -9,6 +9,13 @@ ], "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } + }, "peerDependencies": { "payload": ">=3.0.0 <4.0.0", "payloadcms-vectorize": ">=0.7.0" @@ -21,6 +28,13 @@ "pnpm": "^9 || ^10" }, "publishConfig": { + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } + }, "main": "./dist/index.js", "types": "./dist/index.d.ts" } diff --git a/adapters/cf/tsconfig.build.json b/adapters/cf/tsconfig.build.json new file mode 100644 index 0000000..3a56da8 --- /dev/null +++ b/adapters/cf/tsconfig.build.json @@ -0,0 +1,3 @@ +{ + "extends": "../tsconfig.adapter.json" +} diff --git a/adapters/pg/package.json b/adapters/pg/package.json index 62aefbb..7e6c27a 100644 --- a/adapters/pg/package.json +++ b/adapters/pg/package.json @@ -9,6 +9,13 @@ ], "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } + }, "peerDependencies": { "payload": ">=3.0.0 <4.0.0", "payloadcms-vectorize": ">=0.7.0", @@ -26,6 +33,13 @@ "pnpm": "^9 || ^10" }, "publishConfig": { + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } + }, "main": "./dist/index.js", "types": "./dist/index.d.ts" } diff --git a/adapters/pg/tsconfig.build.json b/adapters/pg/tsconfig.build.json new file mode 100644 index 0000000..3a56da8 --- /dev/null +++ b/adapters/pg/tsconfig.build.json @@ -0,0 +1,3 @@ +{ + "extends": "../tsconfig.adapter.json" +} diff --git a/adapters/tsconfig.adapter.json b/adapters/tsconfig.adapter.json new file mode 100644 index 0000000..c03cbd5 --- /dev/null +++ b/adapters/tsconfig.adapter.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "${configDir}/src", + "outDir": "${configDir}/dist" + }, + "include": ["${configDir}/src/**/*.ts"] +} diff --git a/package.json b/package.json index 626e4df..42fcf19 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,11 @@ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:adapters", "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths", "build:adapters": "pnpm build:adapters:pg && pnpm build:adapters:cf", - "build:adapters:pg": "cd ./adapters/pg && swc ./src -d ./dist --config-file ../../.swcrc --strip-leading-paths", - "build:adapters:cf": "cd ./adapters/cf && swc ./src -d ./dist --config-file ../../.swcrc --strip-leading-paths", + "build:adapters:pg": "cd ./adapters/pg && tsc -p tsconfig.build.json && swc ./src -d ./dist --config-file ../../.swcrc --strip-leading-paths", + "build:adapters:cf": "cd ./adapters/cf && tsc -p tsconfig.build.json && swc ./src -d ./dist --config-file ../../.swcrc --strip-leading-paths", "build:types": "tsc -p tsconfig.build.json --outDir dist --rootDir ./src", "build:types:all": "pnpm build:types && tsc --noEmit", - "clean": "rimraf {dist,*.tsbuildinfo,adapters/pg/dist,adapters/cf/dist}", + "clean": "rimraf {dist,*.tsbuildinfo,adapters/*/dist,adapters/*/*.tsbuildinfo}", "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/", "dev": "cross-env DOTENV_CONFIG_PATH=dev/.env.development NODE_OPTIONS=--require=dotenv/config next dev dev --turbo", "dev:generate-importmap": "pnpm dev:payload generate:importmap",