1
- import * as path from 'path' ;
2
- // import filesize from 'rollup-plugin-filesize';
3
- import typescript from 'rollup- plugin-typescript2' ;
4
- import resolve from '@ rollup/ plugin-node-resolve' ;
5
- import { terser } from 'rollup- plugin-terser' ;
6
- import replace from '@ rollup/ plugin-replace' ;
1
+ import * as path from 'path'
2
+ import typescript from 'rollup-plugin-typescript2'
3
+ import resolve from '@ rollup/ plugin-node-resolve'
4
+ import { terser } from 'rollup- plugin-terser'
5
+ import replace from '@ rollup/ plugin-replace'
6
+ import dts from 'rollup- plugin-dts'
7
7
8
8
const builds = {
9
9
'cjs-dev' : {
@@ -31,14 +31,20 @@ const builds = {
31
31
format : 'es' ,
32
32
mode : 'development' ,
33
33
} ,
34
- } ;
34
+ }
35
+
36
+ function onwarn ( msg , warn ) {
37
+ if ( ! / C i r c u l a r / . test ( msg ) ) {
38
+ warn ( msg )
39
+ }
40
+ }
35
41
36
42
function getAllBuilds ( ) {
37
- return Object . keys ( builds ) . map ( ( key ) => genConfig ( builds [ key ] ) ) ;
43
+ return Object . keys ( builds ) . map ( ( key ) => genConfig ( builds [ key ] ) )
38
44
}
39
45
40
46
function genConfig ( { outFile, format, mode } ) {
41
- const isProd = mode === 'production' ;
47
+ const isProd = mode === 'production'
42
48
return {
43
49
input : './src/index.ts' ,
44
50
output : {
@@ -51,18 +57,21 @@ function genConfig({ outFile, format, mode }) {
51
57
name : format === 'umd' ? 'vueCompositionApi' : undefined ,
52
58
} ,
53
59
external : [ 'vue' ] ,
54
- onwarn : ( msg , warn ) => {
55
- if ( ! / C i r c u l a r / . test ( msg ) ) {
56
- warn ( msg ) ;
57
- }
58
- } ,
60
+ onwarn,
59
61
plugins : [
60
62
typescript ( {
61
- typescript : require ( 'typescript' ) ,
63
+ tsconfigOverride : {
64
+ declaration : false ,
65
+ declarationDir : null ,
66
+ emitDeclarationOnly : false ,
67
+ } ,
68
+ useTsconfigDeclarationDir : true ,
62
69
} ) ,
63
70
resolve ( ) ,
64
71
replace ( {
65
- 'process.env.NODE_ENV' : JSON . stringify ( isProd ? 'production' : 'development' ) ,
72
+ 'process.env.NODE_ENV' : JSON . stringify (
73
+ isProd ? 'production' : 'development'
74
+ ) ,
66
75
__DEV__ :
67
76
format === 'es'
68
77
? // preserve to be handled by bundlers
@@ -72,15 +81,26 @@ function genConfig({ outFile, format, mode }) {
72
81
} ) ,
73
82
isProd && terser ( ) ,
74
83
] . filter ( Boolean ) ,
75
- } ;
84
+ }
76
85
}
77
86
78
- let buildConfig ;
87
+ let buildConfig
79
88
80
89
if ( process . env . TARGET ) {
81
- buildConfig = genConfig ( builds [ process . env . TARGET ] ) ;
90
+ buildConfig = genConfig ( builds [ process . env . TARGET ] )
82
91
} else {
83
- buildConfig = getAllBuilds ( ) ;
92
+ buildConfig = getAllBuilds ( )
84
93
}
85
94
86
- export default buildConfig ;
95
+ // bundle typings
96
+ buildConfig . push ( {
97
+ input : 'typings/index.d.ts' ,
98
+ output : {
99
+ file : 'dist/index.d.ts' ,
100
+ format : 'es' ,
101
+ } ,
102
+ onwarn,
103
+ plugins : [ dts ( ) ] ,
104
+ } )
105
+
106
+ export default buildConfig
0 commit comments