File tree 3 files changed +34
-1
lines changed
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
2
const esbuild = require ( 'esbuild' ) ;
3
+ const { createMinifier } = require ( 'dts-minify' ) ;
4
+ const ts = require ( 'typescript' ) ;
5
+ const path = require ( 'path' ) ;
6
+ const fs = require ( 'fs' ) ;
3
7
4
8
// Build for ESM
5
9
esbuild
@@ -30,3 +34,19 @@ esbuild
30
34
format : 'cjs' ,
31
35
} )
32
36
. catch ( ( ) => process . exit ( 1 ) ) ;
37
+
38
+ // Minify types files
39
+ const minifier = createMinifier ( ts ) ;
40
+
41
+ // load .d.ts files from /dist/types
42
+ const files = fs . readdirSync ( path . resolve ( __dirname , 'dist/types' ) ) ;
43
+
44
+ files . forEach ( ( file ) => {
45
+ const filePath = path . resolve ( __dirname , 'dist/types' , file ) ;
46
+ const fileContent = fs . readFileSync ( filePath , 'utf-8' ) ;
47
+
48
+ const minified = minifier . minify ( fileContent , { keepJsDocs : true } ) ;
49
+
50
+ // write minified content to the same file
51
+ fs . writeFileSync ( filePath , minified ) ;
52
+ } ) ;
Original file line number Diff line number Diff line change 61
61
"@typescript-eslint/eslint-plugin" : " ^5.37.0" ,
62
62
"@typescript-eslint/parser" : " ^5.37.0" ,
63
63
"cz-conventional-changelog" : " ^3.3.0" ,
64
+ "dts-minify" : " ^0.3.0" ,
64
65
"esbuild" : " ^0.15.13" ,
65
66
"eslint" : " ^8.23.1" ,
66
67
"eslint-config-prettier" : " ^8.5.0" ,
Original file line number Diff line number Diff line change @@ -1578,6 +1578,13 @@ dot-prop@^5.1.0:
1578
1578
dependencies :
1579
1579
is-obj "^2.0.0"
1580
1580
1581
+ dts-minify@^0.3.0 :
1582
+ version "0.3.0"
1583
+ resolved "https://registry.yarnpkg.com/dts-minify/-/dts-minify-0.3.0.tgz#fbad948b1ce1ebb65759d393e43b56f30dbf29a7"
1584
+ integrity sha512-785XUyfWCH4e2wJAGwaltdN6xMHsE06HDk3I203WaoOl4kxz6gQrHITDPMkWz6lu0goyTjNdzmG1aMr2ukKi3g==
1585
+ dependencies :
1586
+ tslib "2.3.1"
1587
+
1581
1588
duplexer2@~0.1.0 :
1582
1589
version "0.1.4"
1583
1590
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
@@ -4619,6 +4626,11 @@ ts-node@^10.8.1:
4619
4626
v8-compile-cache-lib "^3.0.1"
4620
4627
yn "3.1.1"
4621
4628
4629
+
4630
+ version "2.3.1"
4631
+ resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
4632
+ integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
4633
+
4622
4634
tslib@^1.8.1 :
4623
4635
version "1.14.1"
4624
4636
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
You can’t perform that action at this time.
0 commit comments