1414 * limitations under the License.
1515 * =============================================================================
1616 */
17-
18- import resolve from '@rollup/plugin-node-resolve' ;
19- import typescript from '@rollup/plugin-typescript' ;
20- import { terser } from 'rollup-plugin-terser' ;
21- import commonjs from '@rollup/plugin-commonjs' ;
17+ import node from 'rollup-plugin-node-resolve' ;
18+ import typescript from 'rollup-plugin-typescript2' ;
19+ import uglify from 'rollup-plugin-uglify' ;
2220
2321const PREAMBLE = `/**
2422 * @license
@@ -37,45 +35,43 @@ const PREAMBLE = `/**
3735 * =============================================================================
3836 */` ;
3937
40- function config ( { plugins = [ ] , output = { } , tsCompilerOptions = { } } ) {
41- const defaultTsOptions = {
42- include : [ 'src/**/*.ts' ] ,
43- module : 'ES2015' ,
44- } ;
45- const tsoptions = Object . assign ( { } , defaultTsOptions , tsCompilerOptions ) ;
38+ function minify ( ) {
39+ return uglify ( { output : { preamble : PREAMBLE } } ) ;
40+ }
4641
42+ function config ( { plugins = [ ] , output = { } } ) {
4743 return {
4844 input : 'src/index.ts' ,
4945 plugins : [
50- typescript ( tsoptions ) ,
51- resolve ( ) ,
52- commonjs ( {
53- ignore : [ 'crypto' , 'node-fetch' , 'util' ] ,
54- include : 'node_modules/**' ,
55- namedExports : {
56- './node_modules/seedrandom/index.js' : [ 'alea' ] ,
57- } ,
58- } ) ,
59- ...plugins
46+ typescript ( { tsconfigOverride : { compilerOptions : { module : 'ES2015' } } } ) ,
47+ node ( ) , ...plugins
6048 ] ,
6149 output : {
62- sourcemap : true ,
63- globals : { '@tensorflow/tfjs' : 'tf' } ,
64- ...output ,
50+ banner : PREAMBLE ,
51+ globals : {
52+ '@tensorflow/tfjs-core' : 'tf' ,
53+ '@tensorflow/tfjs-layers' : 'tf' ,
54+ '@tensorflow/tfjs-data' : 'tf' ,
55+ } ,
56+ ...output
6557 } ,
66- external : [ '@tensorflow/tfjs' ]
58+ external : [
59+ '@tensorflow/tfjs-core' ,
60+ '@tensorflow/tfjs-layers' ,
61+ '@tensorflow/tfjs-data' ,
62+ ]
6763 } ;
6864}
6965
7066const packageName = 'speechCommands' ;
7167export default [
7268 config ( { output : { format : 'umd' , name : packageName , file : 'dist/speech-commands.js' } } ) ,
7369 config ( {
74- plugins : [ terser ( { output : { preamble : PREAMBLE , comments : false } } ) ] ,
70+ plugins : [ minify ( ) ] ,
7571 output : { format : 'umd' , name : packageName , file : 'dist/speech-commands.min.js' }
7672 } ) ,
7773 config ( {
78- plugins : [ terser ( { output : { preamble : PREAMBLE , comments : false } } ) ] ,
74+ plugins : [ minify ( ) ] ,
7975 output : { format : 'es' , file : 'dist/speech-commands.esm.js' }
8076 } )
8177] ;
0 commit comments