Skip to content

Commit 730cce7

Browse files
committed
chore(#57): add type files
1 parent 4125eae commit 730cce7

File tree

5 files changed

+99
-28
lines changed

5 files changed

+99
-28
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 20.13.1
1+
nodejs 20.19.0

package-lock.json

Lines changed: 43 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,17 @@
3636
"type": "module",
3737
"main": "dist/index.cjs",
3838
"module": "dist/index.js",
39+
"types": "dist/index.d.ts",
3940
"exports": {
4041
".": {
41-
"require": "./dist/index.cjs",
42-
"import": "./dist/index.js"
42+
"require": {
43+
"types": "./dist/index.d.cts",
44+
"default": "./dist/index.cjs"
45+
},
46+
"import": {
47+
"types": "./dist/index.d.ts",
48+
"default": "./dist/index.js"
49+
}
4350
}
4451
},
4552
"files": [
@@ -74,7 +81,9 @@
7481
"husky": "^9.1.7",
7582
"mocha": "^10.8.2",
7683
"prettier": "^3.3.3",
77-
"rollup": "^4.27.4"
84+
"rollup": "^4.27.4",
85+
"rollup-plugin-dts": "^6.2.1",
86+
"typescript": "^5.8.3"
7887
},
7988
"engines": {
8089
"node": ">=18"

rollup.config.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,44 @@
44
*/
55

66
import terser from '@rollup/plugin-terser';
7+
import dts from 'rollup-plugin-dts';
78

8-
export default {
9-
input: 'lib/index.js',
10-
output: [
11-
{
12-
format: 'cjs',
13-
file: 'dist/index.cjs',
14-
banner:
15-
'/*! @author Huan Luo <dukeluo@outlook.com> (https://shaiwang.life) */',
16-
},
17-
{
18-
format: 'es',
19-
file: 'dist/index.js',
20-
banner:
21-
'/*! @author Huan Luo <dukeluo@outlook.com> (https://shaiwang.life) */',
22-
},
23-
],
24-
plugins: [terser()],
25-
external: ['is-glob', 'micromatch', 'path'],
26-
};
9+
export default [
10+
{
11+
input: 'lib/index.js',
12+
output: [
13+
{
14+
format: 'cjs',
15+
file: 'dist/index.cjs',
16+
banner:
17+
'/*! @author Huan Luo <dukeluo@outlook.com> (https://shaiwang.life) */',
18+
},
19+
{
20+
format: 'es',
21+
file: 'dist/index.js',
22+
banner:
23+
'/*! @author Huan Luo <dukeluo@outlook.com> (https://shaiwang.life) */',
24+
},
25+
],
26+
plugins: [terser()],
27+
external: ['is-glob', 'micromatch', 'path'],
28+
},
29+
{
30+
input: 'lib/index.js',
31+
output: [
32+
{
33+
format: 'cjs',
34+
file: 'dist/index.d.cts',
35+
banner:
36+
'/*! @author Huan Luo <dukeluo@outlook.com> (https://shaiwang.life) */',
37+
},
38+
{
39+
format: 'es',
40+
file: 'dist/index.d.ts',
41+
banner:
42+
'/*! @author Huan Luo <dukeluo@outlook.com> (https://shaiwang.life) */',
43+
},
44+
],
45+
plugins: [dts()],
46+
},
47+
];

jsconfig.json renamed to tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"compilerOptions": {
3+
"allowJs": true,
34
"checkJs": true,
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
47
"target": "es2022",
58
"module": "nodenext"
69
},

0 commit comments

Comments
 (0)