@@ -36,7 +36,7 @@ const PREAMBLE = `/**
36
36
* =============================================================================
37
37
*/` ;
38
38
39
- function config ( { plugins = [ ] , output = { } , tsCompilerOptions = { } } ) {
39
+ function config ( { plugins = [ ] , output = { } , tsCompilerOptions = { } } ) {
40
40
const defaultTsOptions = {
41
41
include : [ 'src/**/*.ts' ] ,
42
42
module : 'ES2015' ,
@@ -45,36 +45,40 @@ function config({ plugins = [], output = {}, tsCompilerOptions = {} }) {
45
45
46
46
return {
47
47
input : 'src/index.ts' ,
48
- plugins : [
49
- typescript ( tsoptions ) ,
50
- resolve ( ) , ...plugins
51
- ] ,
48
+ plugins : [ typescript ( tsoptions ) , resolve ( ) , ...plugins ] ,
52
49
output : {
53
50
banner : PREAMBLE ,
54
51
globals : {
55
52
'@tensorflow/tfjs-core' : 'tf' ,
56
53
'@tensorflow/tfjs-converter' : 'tf' ,
57
- '@mediapipe/selfie_segmentation' : 'SelfieSegmentation'
54
+ // Package is obfuscated so class is directly attached to globalThis.
55
+ '@mediapipe/selfie_segmentation' : 'globalThis'
58
56
} ,
59
57
...output ,
60
58
} ,
61
59
external : [
62
- '@tensorflow/tfjs-core' ,
63
- '@tensorflow/tfjs-converter' ,
60
+ '@tensorflow/tfjs-core' , '@tensorflow/tfjs-converter' ,
64
61
'@mediapipe/selfie_segmentation'
65
62
]
66
63
} ;
67
64
}
68
65
69
66
const packageName = 'bodySegmentation' ;
70
67
export default [
71
- config ( { output : { format : 'umd' , name : packageName , file : 'dist/body-segmentation.js' } } ) ,
68
+ config ( {
69
+ output :
70
+ { format : 'umd' , name : packageName , file : 'dist/body-segmentation.js' }
71
+ } ) ,
72
72
config ( {
73
73
plugins : [ terser ( { output : { preamble : PREAMBLE , comments : false } } ) ] ,
74
- output : { format : 'umd' , name : packageName , file : 'dist/body-segmentation.min.js' }
74
+ output : {
75
+ format : 'umd' ,
76
+ name : packageName ,
77
+ file : 'dist/body-segmentation.min.js'
78
+ }
75
79
} ) ,
76
80
config ( {
77
81
plugins : [ terser ( { output : { preamble : PREAMBLE , comments : false } } ) ] ,
78
- output : { format : 'es' , file : 'dist/body-segmentation.esm.js' }
82
+ output : { format : 'es' , file : 'dist/body-segmentation.esm.js' }
79
83
} )
80
84
] ;
0 commit comments