Skip to content

Commit

Permalink
build: Support ESM type declarations & remove test files in dist (#21)
Browse files Browse the repository at this point in the history
* fix(*): migrate rollup to tsup, support esm correctly, remove *.spec.* for dist

* chore: update

* postbuild

* Update .scripts/postbuild.sh

* Update package.json

Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>

---------

Co-authored-by: raon0211 <raon0211@toss.im>
  • Loading branch information
manudeli and raon0211 authored Jun 4, 2024
1 parent 34d4356 commit 9bde10a
Show file tree
Hide file tree
Showing 5 changed files with 861 additions and 242 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
node_modules
coverage
dist
esm
.junit
out
*.d.ts
Expand Down
88 changes: 61 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,84 @@
"./package.json": "./package.json"
},
"files": [
"dist/**/*",
"esm/**/*",
"dist",
"*.d.ts"
],
"publishConfig": {
"access": "public",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./esm/index.mjs",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./array": {
"types": "./dist/array/index.d.ts",
"import": "./esm/array/index.mjs",
"require": "./dist/array/index.js"
"import": {
"types": "./dist/array/index.d.mts",
"default": "./dist/array/index.mjs"
},
"require": {
"types": "./dist/array/index.d.ts",
"default": "./dist/array/index.js"
}
},
"./function": {
"types": "./dist/function/index.d.ts",
"import": "./esm/function/index.mjs",
"require": "./dist/function/index.js"
"import": {
"types": "./dist/function/index.d.mts",
"default": "./dist/function/index.mjs"
},
"require": {
"types": "./dist/function/index.d.ts",
"default": "./dist/function/index.js"
}
},
"./math": {
"types": "./dist/math/index.d.ts",
"import": "./esm/math/index.mjs",
"require": "./dist/math/index.js"
"import": {
"types": "./dist/math/index.d.mts",
"default": "./dist/math/index.mjs"
},
"require": {
"types": "./dist/math/index.d.ts",
"default": "./dist/math/index.js"
}
},
"./object": {
"types": "./dist/object/index.d.ts",
"import": "./esm/object/index.mjs",
"require": "./dist/object/index.js"
"import": {
"types": "./dist/object/index.d.mts",
"default": "./dist/object/index.mjs"
},
"require": {
"types": "./dist/object/index.d.ts",
"default": "./dist/object/index.js"
}
},
"./predicate": {
"types": "./dist/predicate/index.d.ts",
"import": "./esm/predicate/index.mjs",
"require": "./dist/predicate/index.js"
"import": {
"types": "./dist/predicate/index.d.mts",
"default": "./dist/predicate/index.mjs"
},
"require": {
"types": "./dist/predicate/index.d.ts",
"default": "./dist/predicate/index.js"
}
},
"./promise": {
"types": "./dist/promise/index.d.ts",
"import": "./esm/promise/index.mjs",
"require": "./dist/promise/index.js"
"import": {
"types": "./dist/promise/index.d.mts",
"default": "./dist/promise/index.mjs"
},
"require": {
"types": "./dist/promise/index.d.ts",
"default": "./dist/promise/index.js"
}
},
"./package.json": "./package.json"
}
Expand All @@ -70,7 +105,6 @@
"@babel/preset-typescript": "^7.24.1",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@toss/rollup-config": "0.2.0-canary.0",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"@types/broken-link-checker": "^0",
Expand All @@ -84,14 +118,14 @@
"eslint-config-prettier": "^8.5.0",
"lodash": "^4.17.21",
"prettier": "^3.2.5",
"rollup": "^2.78.0",
"tsup": "^8.1.0",
"typescript": "^5.4.5",
"vitest": "^1.5.2"
},
"sideEffects": false,
"scripts": {
"prepack": "yarn build",
"build": "rm -rf dist esm && tsc -p tsconfig.json --declaration --emitDeclarationOnly --declarationDir dist && rollup -c rollup.config.js && ./.scripts/postbuild.sh",
"build": "tsup && ./.scripts/postbuild.sh",
"test": "vitest run --coverage --typecheck"
}
}
}
5 changes: 0 additions & 5 deletions rollup.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'tsup'

export default defineConfig({
format: ['cjs', 'esm'],
entry: ['src/*.ts', 'src/*/*.ts', '!**/*.{spec,test,test-d}.*'],
sourcemap: true,
dts: true,
clean: true,
})
Loading

0 comments on commit 9bde10a

Please sign in to comment.