From 7331892ca1488898762133dca1dd80c80d9058a7 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 12 Dec 2023 11:02:19 -0500 Subject: [PATCH] wip --- .github/workflows/main.yml | 22 +++++++++---------- .github/workflows/prepare-release.yml | 4 +++- package.json | 1 + packages/@headlessui-tailwindcss/package.json | 5 ++++- .../scripts/fix-types.js | 7 +++--- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2c719b6e49..4ba7b3bb90 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: env: CI: true - check-types: + test: runs-on: ubuntu-latest needs: [install] @@ -59,12 +59,13 @@ jobs: with: path: '**/node_modules' key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Check Types - run: yarn attw -P + - name: Test + run: | + yarn test || yarn test || yarn test || exit 1 env: CI: true - test: + build: runs-on: ubuntu-latest needs: [install] @@ -75,15 +76,14 @@ jobs: with: path: '**/node_modules' key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Test - run: | - yarn test || yarn test || yarn test || exit 1 + - name: Build + run: yarn build env: CI: true - build: + check-types: runs-on: ubuntu-latest - needs: [install] + needs: [build] steps: - name: Begin CI... @@ -92,7 +92,7 @@ jobs: with: path: '**/node_modules' key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Build - run: yarn build + - name: Check Types + run: yarn lint-types env: CI: true diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 35b39dc30c..76cd560352 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -27,7 +27,9 @@ jobs: - uses: actions/checkout@v3 - name: Check Types - run: yarn attw -P + run: | + yarn build + yarn lint-types env: CI: true diff --git a/package.json b/package.json index 6861f31466..dfd70e3458 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "test": "./scripts/test.sh", "lint": "./scripts/lint.sh", "lint-check": "CI=true ./scripts/lint.sh", + "lint-types": "CI=true yarn workspaces run attw -P", "release-channel": "node ./scripts/release-channel.js", "release-notes": "node ./scripts/release-notes.js", "package-path": "node ./scripts/package-path.js" diff --git a/packages/@headlessui-tailwindcss/package.json b/packages/@headlessui-tailwindcss/package.json index 02f8a9c47b..76883f8626 100644 --- a/packages/@headlessui-tailwindcss/package.json +++ b/packages/@headlessui-tailwindcss/package.json @@ -11,7 +11,10 @@ "dist" ], "exports": { - "types": "./dist/index.d.ts", + "types": { + "import": "./dist/index.d.ts", + "require": "./dist/index.d.cts" + }, "import": "./dist/headlessui.esm.js", "require": "./dist/index.cjs" }, diff --git a/packages/@headlessui-tailwindcss/scripts/fix-types.js b/packages/@headlessui-tailwindcss/scripts/fix-types.js index 9bd2f8bc1c..a1a0ec2b88 100644 --- a/packages/@headlessui-tailwindcss/scripts/fix-types.js +++ b/packages/@headlessui-tailwindcss/scripts/fix-types.js @@ -12,12 +12,13 @@ let path = require('path') * CommonJs environment. **/ -let types = path.resolve(__dirname, '..', 'dist', 'index.d.ts') +let esmTypes = path.resolve(__dirname, '..', 'dist', 'index.d.ts') +let cjsTypes = path.resolve(__dirname, '..', 'dist', 'index.d.cts') async function run() { - let contents = await fs.readFile(types, 'utf8') + let contents = await fs.readFile(esmTypes, 'utf8') contents = contents.replace('export default', 'export =') - await fs.writeFile(types, contents, 'utf8') + await fs.writeFile(cjsTypes, contents, 'utf8') } run()