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'
77
88const builds = {
99 'cjs-dev' : {
@@ -31,14 +31,20 @@ const builds = {
3131 format : 'es' ,
3232 mode : 'development' ,
3333 } ,
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+ }
3541
3642function getAllBuilds ( ) {
37- return Object . keys ( builds ) . map ( ( key ) => genConfig ( builds [ key ] ) ) ;
43+ return Object . keys ( builds ) . map ( ( key ) => genConfig ( builds [ key ] ) )
3844}
3945
4046function genConfig ( { outFile, format, mode } ) {
41- const isProd = mode === 'production' ;
47+ const isProd = mode === 'production'
4248 return {
4349 input : './src/index.ts' ,
4450 output : {
@@ -51,18 +57,21 @@ function genConfig({ outFile, format, mode }) {
5157 name : format === 'umd' ? 'vueCompositionApi' : undefined ,
5258 } ,
5359 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,
5961 plugins : [
6062 typescript ( {
61- typescript : require ( 'typescript' ) ,
63+ tsconfigOverride : {
64+ declaration : false ,
65+ declarationDir : null ,
66+ emitDeclarationOnly : false ,
67+ } ,
68+ useTsconfigDeclarationDir : true ,
6269 } ) ,
6370 resolve ( ) ,
6471 replace ( {
65- 'process.env.NODE_ENV' : JSON . stringify ( isProd ? 'production' : 'development' ) ,
72+ 'process.env.NODE_ENV' : JSON . stringify (
73+ isProd ? 'production' : 'development'
74+ ) ,
6675 __DEV__ :
6776 format === 'es'
6877 ? // preserve to be handled by bundlers
@@ -72,15 +81,26 @@ function genConfig({ outFile, format, mode }) {
7281 } ) ,
7382 isProd && terser ( ) ,
7483 ] . filter ( Boolean ) ,
75- } ;
84+ }
7685}
7786
78- let buildConfig ;
87+ let buildConfig
7988
8089if ( process . env . TARGET ) {
81- buildConfig = genConfig ( builds [ process . env . TARGET ] ) ;
90+ buildConfig = genConfig ( builds [ process . env . TARGET ] )
8291} else {
83- buildConfig = getAllBuilds ( ) ;
92+ buildConfig = getAllBuilds ( )
8493}
8594
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