mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 03:32:58 +03:00
build: Support ESM type declarations & remove test files in dist (#21)
* 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>
This commit is contained in:
parent
34d4356a82
commit
9bde10a537
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,7 +13,6 @@
|
||||
node_modules
|
||||
coverage
|
||||
dist
|
||||
esm
|
||||
.junit
|
||||
out
|
||||
*.d.ts
|
||||
|
88
package.json
88
package.json
@ -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"
|
||||
}
|
||||
@ -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",
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
const { generateRollupConfig } = require('@toss/rollup-config');
|
||||
|
||||
module.exports = generateRollupConfig({
|
||||
packageDir: __dirname,
|
||||
});
|
9
tsup.config.ts
Normal file
9
tsup.config.ts
Normal file
@ -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…
Reference in New Issue
Block a user