Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tsup to build project compatible with CJS and ESM, and validate in CI #258

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"devDependencies": [
"./src/demo/**",
"./src/**/__tests__/**",
"vite.config.mts"
"vite.config.mts",
"tsup.config.ts"
],
"includeTypes": true
}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ jobs:
# Run the tests and print out the coverage information. In the future,
# we could integrate with Codecov or something.
run: pnpm run test:coverage

- name: Validate the build's packaging CJS and ESM compatibility
run: npx @arethetypeswrong/cli@0.15.4 --pack
29 changes: 21 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,30 @@
"files": [
"dist"
],
"type": "commonjs",
"types": "./dist/index.d.ts",
"main": "dist/index.js",
"module": "dist/esm/index.js",
"module": "dist/index.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/esm/index.js"
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
}
},
"./icons": {
"types": "./dist/icons/index.d.ts",
"require": "./dist/icons/index.js",
"import": "./dist/esm/icons/index.js"
"require": {
"types": "./dist/icons/index.d.ts",
"default": "./dist/icons/index.js"
},
"import": {
"types": "./dist/icons/index.d.mts",
"default": "./dist/icons/index.mjs"
}
}
},
"typesVersions": {
Expand All @@ -56,7 +67,7 @@
},
"sideEffects": false,
"scripts": {
"build": "pnpm clean && tsc --project tsconfig.build.json && tsc --project tsconfig.build-esm.json",
"build": "tsup",
"clean": "rimraf dist coverage",
"example": "pnpm build && rimraf ./example/node_modules && pnpm --dir ./example install && pnpm --dir ./example run dev",
"dev": "vite",
Expand All @@ -76,6 +87,7 @@
"dependencies": {
"encodeurl": "^1.0.2",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"react-colorful": "^5.6.1",
"tss-react": "^4.8.3",
"type-fest": "^3.12.0"
Expand Down Expand Up @@ -175,6 +187,7 @@
"react-dom": "^18.2.0",
"rimraf": "^5.0.0",
"tippy.js": "^6.3.7",
"tsup": "^8.2.4",
"typescript": "^5.1.6",
"vite": "^5.3.1",
"vitest": "^1.6.0",
Expand Down
Loading
Loading