From 1b71fc325936f197a26662f747e1496831b0fdd2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 28 Apr 2023 13:55:32 +0200 Subject: [PATCH 1/2] migrate to tsup similar to https://github.com/storybookjs/jest/pull/26 --- .github/workflows/linear-export.yml | 27 --------------------------- .github/workflows/release.yml | 4 ++-- package.json | 14 ++++++-------- tsconfig.base.json | 13 ------------- tsconfig.cjs.json | 7 ------- tsconfig.esm.json | 9 --------- tsconfig.json | 9 +++++++++ tsup.config.ts | 24 ++++++++++++++++++++++++ 8 files changed, 41 insertions(+), 66 deletions(-) delete mode 100644 .github/workflows/linear-export.yml delete mode 100644 tsconfig.base.json delete mode 100644 tsconfig.cjs.json delete mode 100644 tsconfig.esm.json create mode 100644 tsconfig.json create mode 100644 tsup.config.ts diff --git a/.github/workflows/linear-export.yml b/.github/workflows/linear-export.yml deleted file mode 100644 index 10225f5..0000000 --- a/.github/workflows/linear-export.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Export to linear - -on: - issues: - types: [labeled] - pull_request: - types: [labeled] - -jobs: - trigger: - if: github.event.label.name == 'linear' - name: Export to linear - runs-on: ubuntu-latest - steps: - # - uses: hmarr/debug-action@v2 - - name: Linear action - uses: shilman/linear-action@v1 - with: - ghIssueNumber: ${{ github.event.number || github.event.issue.number }} - ghRepoOwner: ${{ github.event.repository.owner.login }} - ghRepoName: ${{ github.event.repository.name }} - ghToken: ${{ secrets.LINEAR_GH_TOKEN }} - linearIssuePrefix: Testing-Library - linearLabel: Storybook - linearPRLabel: PR - linearTeam: SB - linearApiKey: ${{ secrets.LINEAR_API_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd8a6d3..979ea42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,10 +12,10 @@ jobs: - name: Prepare repository run: git fetch --unshallow --tags - - name: Use Node.js 14.x + - name: Use Node.js 16.x uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x - name: Install dependencies run: yarn diff --git a/package.json b/package.json index 10fccf0..2ca3ec9 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,7 @@ "module": "dist/esm/index.js", "license": "MIT", "scripts": { - "prebuild": "rimraf dist", - "build": "yarn build:esm && yarn build:cjs", - "build:esm": "tsc --project tsconfig.esm.json", - "build:cjs": "tsc --project tsconfig.cjs.json", + "build": "tsup", "prepack": "yarn build", "prerelease": "yarn build", "release": "auto shipit" @@ -27,20 +24,21 @@ "access": "public" }, "dependencies": { - "@storybook/client-logger": "^7.0.0-beta.0 || ^7.0.0-rc.0 || ^7.0.0", - "@storybook/instrumenter": "^7.0.0-beta.0 || ^7.0.0-rc.0 || ^7.0.0", "@testing-library/dom": "^8.3.0", "@testing-library/user-event": "^13.2.1", "ts-dedent": "^2.2.0" }, "devDependencies": { + "@storybook/client-logger": "future", + "@storybook/instrumenter": "future", "@auto-it/first-time-contributor": "^10.37.6", "@auto-it/released": "^10.37.6", "@storybook/linter-config": "^3.1.2", "@types/react": "*", "auto": "^10.37.6", - "rimraf": "^3.0.2", - "typescript": "^4.4.3" + "util": "^0.12.5", + "tsup": "^6.7.0", + "typescript": "^5.0.4" }, "auto": { "prereleaseBranches": [ diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index 36b853f..0000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "noImplicitAny": true, - "target": "es5", - "allowJs": true, - "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - "declaration": true, - "declarationDir": "./dist/types" - }, - "include": ["src/*.ts"], - "exclude": ["node_modules"] -} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index 6196628..0000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/cjs", - "module": "CommonJS", - }, -} diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index 3e2451c..0000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,9 +0,0 @@ - -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/esm", - "module": "ES6", - "target": "ES5", - }, -} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c38207b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es2020", + "moduleResolution": "nodenext", + "allowSyntheticDefaultImports": true + }, + "include": ["src/*.ts"] +} diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..86b4621 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig( + { + clean: true, + entry: ['./src/index.ts'], + format: ['cjs', 'esm'], + esbuildOptions(options, context) { + Object.assign(options, { + platform: 'browser', + logLevel: 'error', + legalComments: 'none', + minifyWhitespace: false, + minifyIdentifiers: false, + minifySyntax: true, + }) + }, + shims: false, + dts: { + entry: ['./src/index.ts'], + resolve: true, + }, + } +); From a6ec2acfe2ca998298d2a392c6ab046930cb11fd Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 28 Apr 2023 14:11:44 +0200 Subject: [PATCH 2/2] fix export paths --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 093db6d..0ab5fd1 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "type": "git", "url": "https://github.com/storybookjs/testing-library.git" }, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", + "main": "dist/index.js", + "module": "dist/index.mjs", "license": "MIT", "scripts": { "build": "tsup", @@ -19,7 +19,7 @@ "files": [ "dist/**/*" ], - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "publishConfig": { "access": "public" },