@@ -51,7 +51,8 @@ const transformers = [
51
51
52
52
const terserOptions = {
53
53
output : {
54
- comments : false
54
+ comments : "all" ,
55
+ beautify : true
55
56
} ,
56
57
mangle : {
57
58
properties : {
@@ -60,19 +61,6 @@ const terserOptions = {
60
61
}
61
62
} ;
62
63
63
- /**
64
- * ES5 Builds
65
- */
66
- const es5BuildPlugins = [
67
- typescriptPlugin ( {
68
- typescript,
69
- transformers,
70
- cacheRoot : './.cache/es5.min/'
71
- } ) ,
72
- json ( ) ,
73
- terser ( terserOptions )
74
- ] ;
75
-
76
64
const es5Builds = [
77
65
/**
78
66
* Node.js Build
@@ -81,7 +69,11 @@ const es5Builds = [
81
69
input : 'index.node.ts' ,
82
70
output : [ { file : pkg . main , format : 'cjs' , sourcemap : true } ] ,
83
71
plugins : [
84
- ...es5BuildPlugins ,
72
+ typescriptPlugin ( {
73
+ typescript,
74
+ cacheRoot : './.cache/node.cjs/'
75
+ } ) ,
76
+ json ( ) ,
85
77
// Needed as we also use the *.proto files
86
78
copy ( {
87
79
assets : [ './src/protos' ]
@@ -96,15 +88,37 @@ const es5Builds = [
96
88
)
97
89
} ,
98
90
/**
99
- * Browser Builds
91
+ * Browser CJS Build
92
+ *
93
+ * The Browser CJS build is not mangled as Terser's property name mangling
94
+ * does not work well with CommonJS-style files.
100
95
*/
101
96
{
102
97
input : 'index.ts' ,
103
- output : [
104
- { file : pkg . browser , format : 'cjs' , sourcemap : true } ,
105
- { file : pkg . module , format : 'es' , sourcemap : true }
98
+ output :{ file : pkg . browser , format : 'cjs' , sourcemap : true } ,
99
+ plugins : [
100
+ typescriptPlugin ( {
101
+ typescript,
102
+ cacheRoot : './.cache/cjs/'
103
+ } ) ,
104
+ json ( )
105
+ ] ,
106
+ } ,
107
+ /**
108
+ * Browser ESM Build
109
+ */
110
+ {
111
+ input : 'index.ts' ,
112
+ output : { file : pkg . module , format : 'es' , sourcemap : true } ,
113
+ plugins : [
114
+ typescriptPlugin ( {
115
+ typescript,
116
+ transformers,
117
+ cacheRoot : './.cache/esm/'
118
+ } ) ,
119
+ json ( ) ,
120
+ terser ( terserOptions )
106
121
] ,
107
- plugins : es5BuildPlugins ,
108
122
external : id => deps . some ( dep => id === dep || id . startsWith ( `${ dep } /` ) )
109
123
}
110
124
] ;
@@ -120,7 +134,7 @@ const es2017BuildPlugins = [
120
134
target : 'es2017'
121
135
}
122
136
} ,
123
- cacheRoot : './.cache/es2017.min /' ,
137
+ cacheRoot : './.cache/esm2017 /' ,
124
138
transformers
125
139
} ) ,
126
140
json ( { preferConst : true } ) ,
0 commit comments