Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit 9a95384

Browse files
mesqueebrocwang
andauthored
fix: type generation without vite-dts (#166)
Co-authored-by: Roc Wong <[email protected]>
1 parent 03c830b commit 9a95384

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@
1616
},
1717
"homepage": "https://grid.kiwiberry.nz/",
1818
"files": [
19-
"dist",
20-
"src/*.*"
19+
"dist"
2120
],
22-
"main": "./dist/vue-virtual-scroll-grid.umd.js",
23-
"module": "./dist/vue-virtual-scroll-grid.es.js",
21+
"module": "./dist/index.es.js",
22+
"main": "./dist/index.umd.js",
23+
"types": "./dist/index.d.ts",
2424
"exports": {
2525
".": {
26-
"import": "./dist/vue-virtual-scroll-grid.es.js",
27-
"require": "./dist/vue-virtual-scroll-grid.umd.js"
26+
"import": "./dist/index.es.js",
27+
"require": "./dist/index.umd.js",
28+
"types": "./dist/index.d.ts"
2829
}
2930
},
3031
"license": "MIT",
3132
"scripts": {
33+
"gen:types": "vue-tsc --declaration --emitDeclarationOnly",
3234
"serve": "vite preview",
33-
"build": "vite build",
35+
"build": "vite build && npm run gen:types",
3436
"build:demo": "vite build --mode demo",
3537
"dev": "vite",
3638
"lint": "vue-tsc --noEmit --skipLibCheck",
@@ -61,7 +63,6 @@
6163
"ts-jest": "^27.0.7",
6264
"typescript": "^4.5.2",
6365
"vite": "^2.6.13",
64-
"vite-dts": "^1.0.3",
6566
"vue": "^3.2.23",
6667
"vue-tsc": ">=0.29.8"
6768
},

src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Grid from './Grid.vue'
2+
3+
export default Grid

tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"compilerOptions": {
3-
"declaration": true,
3+
"declaration": false,
4+
"baseUrl": ".",
5+
"outDir": "dist",
46
"target": "esnext",
57
"module": "esnext",
68
"moduleResolution": "node",
@@ -12,5 +14,5 @@
1214
"lib": ["esnext", "dom"],
1315
"types": ["vite/client", "jest"],
1416
},
15-
"include": ["src/*.ts", "src/*.d.ts", "src/*.tsx", "src/*.vue"]
17+
"include": ["src/*.ts", "src/*.tsx", "src/*.vue"]
1618
}

vite.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import vue from "@vitejs/plugin-vue";
33
import { homedir } from "os";
44
import { existsSync, readFileSync } from "fs";
55
import { resolve } from "path";
6-
import dts from "vite-dts";
76

87
export default ({ mode }: ConfigEnv): UserConfig => {
98
return {
10-
plugins: [vue(), dts()],
9+
plugins: [vue()],
1110
server: {
1211
open: true,
1312
https: existsSync(`${homedir()}/.localhost_ssl/server.key`)
@@ -23,8 +22,9 @@ export default ({ mode }: ConfigEnv): UserConfig => {
2322
? {}
2423
: {
2524
lib: {
26-
entry: resolve(__dirname, "src/Grid.vue"),
25+
entry: resolve(__dirname, "src/index.ts"),
2726
name: "VirtualScrollGrid",
27+
fileName: (format) => `index.${format}.js`,
2828
},
2929
rollupOptions: {
3030
// Make sure to externalize deps that shouldn't be bundled

0 commit comments

Comments
 (0)