@@ -102,14 +102,16 @@ export function resolveMemoryExterns(deps, externsId, referencedBy) {
102
102
const es5BuildPlugins = [
103
103
typescriptPlugin ( {
104
104
typescript,
105
- tsconfigOverride : {
106
- compilerOptions : {
107
- allowJs : true
108
- }
109
- } ,
110
- include : [ "*.js" , "**/*.js" ] ,
105
+ transformers : appendPrivatePrefixTransformers ,
106
+ cacheRoot : `./.cache/es5.mangled/`
111
107
} ) ,
112
- sourcemaps ( )
108
+ {
109
+ transform ( code , id ) {
110
+ return code . replace ( / \/ \* \* @ c l a s s \* \/ / g, "\/*@__PURE__*\/" ) ;
111
+ }
112
+ } ,
113
+ json ( ) ,
114
+ terser ( manglePrivatePropertiesOptions )
113
115
] ;
114
116
115
117
const es2017BuildPlugins = [
@@ -120,14 +122,33 @@ const es2017BuildPlugins = [
120
122
target : 'es2017'
121
123
}
122
124
} ,
123
- cacheRoot : './.cache/browser /' ,
125
+ cacheRoot : './.cache/es2017.mangled /' ,
124
126
transformers : appendPrivatePrefixTransformers
125
127
} ) ,
126
128
json ( { preferConst : true } ) ,
127
129
terser ( manglePrivatePropertiesOptions )
128
130
] ;
129
131
130
132
const browserBuilds = [
133
+ // ES5 ESM Build (with persistence)
134
+ {
135
+ input : 'index.ts' ,
136
+ output : { file : pkg . module , format : 'es' , sourcemap : true } ,
137
+ plugins : es5BuildPlugins ,
138
+ external : resolveBrowserExterns
139
+ } ,
140
+ // ES5 ESM Build (memory-only)
141
+ {
142
+ input : 'index.memory.ts' ,
143
+ output : {
144
+ file : path . resolve ( './memory' , memoryPkg . module ) ,
145
+ format : 'es' ,
146
+ sourcemap : true
147
+ } ,
148
+ plugins : es5BuildPlugins ,
149
+ external : ( id , referencedBy ) =>
150
+ resolveMemoryExterns ( browserDeps , id , referencedBy )
151
+ } ,
131
152
// ES2017 ESM build (with persistence)
132
153
{
133
154
input : 'index.ts' ,
@@ -151,41 +172,27 @@ const browserBuilds = [
151
172
external : ( id , referencedBy ) =>
152
173
resolveMemoryExterns ( browserDeps , id , referencedBy )
153
174
} ,
154
- // ES5 ESM Build (with persistence)
155
- //
156
- // This and all following builds are based on the mangling and tree-shaking
157
- // in the ESM2017 build, since the ESM2017 build results in improved tree
158
- // shaking and property name mangling.
159
- {
160
- input : pkg . esm2017 ,
161
- output : { file : pkg . module , format : 'es' , sourcemap : true } ,
162
- plugins : es5BuildPlugins
163
- } ,
164
- // ES5 ESM Build (memory-only)
165
- {
166
- input : path . resolve ( './memory' , memoryPkg . esm2017 ) ,
167
- output : {
168
- file : path . resolve ( './memory' , memoryPkg . module ) ,
169
- format : 'es' ,
170
- sourcemap : true
171
- } ,
172
- plugins : es5BuildPlugins
173
- } ,
174
175
// ES5 CJS Build (with persistence)
176
+ //
177
+ // This build is based on the mangling in the ESM build above, since
178
+ // Terser's Property name mangling doesn't work well with CJS's syntax.
175
179
{
176
- input : pkg . esm2017 ,
180
+ input : pkg . module ,
177
181
output : { file : pkg . browser , format : 'cjs' , sourcemap : true } ,
178
- plugins : es5BuildPlugins
182
+ plugins : [ sourcemaps ( ) ]
179
183
} ,
180
184
// ES5 CJS Build (memory-only)
185
+ //
186
+ // This build is based on the mangling in the ESM build above, since
187
+ // Terser's Property name mangling doesn't work well with CJS's syntax.
181
188
{
182
- input : path . resolve ( './memory' , memoryPkg . esm2017 ) ,
189
+ input : path . resolve ( './memory' , memoryPkg . module ) ,
183
190
output : {
184
191
file : path . resolve ( './memory' , memoryPkg . browser ) ,
185
192
format : 'cjs' ,
186
193
sourcemap : true
187
194
} ,
188
- plugins : es5BuildPlugins
195
+ plugins : [ sourcemaps ( ) ]
189
196
}
190
197
] ;
191
198
0 commit comments