Skip to content

Commit

Permalink
build: exports types
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish committed Sep 24, 2024
1 parent 7d06fce commit 2e10e63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
"browser": "./dist/index.umd.cjs",
"exports": {
".": {
"types": {
"import": "./dist/index.d.ts",
"require": "./dist/index.cjs"
},
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
"browser": "./dist/index.umd.cjs"
}
},
"files": [
Expand Down
14 changes: 13 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { copyFile } from 'fs/promises'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
Expand Down Expand Up @@ -25,5 +26,16 @@ export default defineConfig({
// @link https://github.com/vitejs/vite/issues/9186
'process.env.NODE_ENV': '"production"',
},
plugins: [dts()],
plugins: [
dts(),
{
name: 'cts',
closeBundle() {
copyFile(
resolve(import.meta.dirname, 'dist/index.d.ts'),
resolve(import.meta.dirname, 'dist/index.d.cts')
)
},
},
],
})

0 comments on commit 2e10e63

Please sign in to comment.