14
14
* limitations under the License.
15
15
* =============================================================================
16
16
*/
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' ;
22
20
23
21
const PREAMBLE = `/**
24
22
* @license
@@ -37,45 +35,43 @@ const PREAMBLE = `/**
37
35
* =============================================================================
38
36
*/` ;
39
37
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
+ }
46
41
42
+ function config ( { plugins = [ ] , output = { } } ) {
47
43
return {
48
44
input : 'src/index.ts' ,
49
45
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
60
48
] ,
61
49
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
65
57
} ,
66
- external : [ '@tensorflow/tfjs' ]
58
+ external : [
59
+ '@tensorflow/tfjs-core' ,
60
+ '@tensorflow/tfjs-layers' ,
61
+ '@tensorflow/tfjs-data' ,
62
+ ]
67
63
} ;
68
64
}
69
65
70
66
const packageName = 'speechCommands' ;
71
67
export default [
72
68
config ( { output : { format : 'umd' , name : packageName , file : 'dist/speech-commands.js' } } ) ,
73
69
config ( {
74
- plugins : [ terser ( { output : { preamble : PREAMBLE , comments : false } } ) ] ,
70
+ plugins : [ minify ( ) ] ,
75
71
output : { format : 'umd' , name : packageName , file : 'dist/speech-commands.min.js' }
76
72
} ) ,
77
73
config ( {
78
- plugins : [ terser ( { output : { preamble : PREAMBLE , comments : false } } ) ] ,
74
+ plugins : [ minify ( ) ] ,
79
75
output : { format : 'es' , file : 'dist/speech-commands.esm.js' }
80
76
} )
81
77
] ;
0 commit comments