11import fs from 'fs' ;
2- import { resolve , relative , dirname , basename } from 'path' ;
2+ import { resolve , relative , dirname , basename , extname } from 'path' ;
33import chalk from 'chalk' ;
44import { map , series } from 'asyncro' ;
55import promisify from 'es6-promisify' ;
@@ -17,6 +17,7 @@ import gzipSize from 'gzip-size';
1717import prettyBytes from 'pretty-bytes' ;
1818import shebangPlugin from 'rollup-plugin-preserve-shebang' ;
1919import flow from 'rollup-plugin-flow' ;
20+ import typescript from 'rollup-plugin-typescript' ;
2021import camelCase from 'camelcase' ;
2122
2223const interopRequire = m => m . default || m ;
@@ -186,6 +187,8 @@ function createConfig(options, entry, format, writeMeta) {
186187 catch ( e ) { }
187188 }
188189
190+ const useTypescript = extname ( entry ) === '.ts' ;
191+
189192 let config = {
190193 inputOptions : {
191194 input : exportType ? resolve ( __dirname , '../src/lib/__entry__.js' ) : entry ,
@@ -202,7 +205,8 @@ function createConfig(options, entry, format, writeMeta) {
202205 inject : false ,
203206 extract : ! ! writeMeta
204207 } ) ,
205- flow ( { all : true } ) ,
208+ useTypescript && typescript ( ) ,
209+ ! useTypescript && flow ( { all : true } ) ,
206210 nodent ( {
207211 exclude : 'node_modules/**' ,
208212 noRuntime : true ,
@@ -216,7 +220,7 @@ function createConfig(options, entry, format, writeMeta) {
216220 }
217221 }
218222 } ) ,
219- buble ( {
223+ ! useTypescript && buble ( {
220224 exclude : 'node_modules/**' ,
221225 jsx : options . jsx || 'h' ,
222226 objectAssign : options . assign || 'Object.assign' ,
0 commit comments