@@ -96,7 +96,8 @@ export async function extractDependenciesAndSize(
96
96
} ) ;
97
97
const externalDepsNotResolvedBundle = await rollup . rollup ( {
98
98
input,
99
- external : id => id . startsWith ( '@firebase' ) // exclude all firebase dependencies
99
+ // exclude all firebase dependencies and tslib
100
+ external : id => id . startsWith ( '@firebase' ) || id === 'tslib'
100
101
} ) ;
101
102
await externalDepsNotResolvedBundle . write ( {
102
103
file : externalDepsNotResolvedOutput ,
@@ -224,7 +225,14 @@ export function extractDeclarations(
224
225
} else if ( ts . isVariableDeclaration ( node ) ) {
225
226
declarations . variables . push ( node . name ! . getText ( ) ) ;
226
227
} else if ( ts . isEnumDeclaration ( node ) ) {
227
- declarations . enums . push ( node . name . escapedText . toString ( ) ) ;
228
+ // `const enum`s should not be analyzed. They do not add to bundle size and
229
+ // creating a file that imports them causes an error during the rollup step.
230
+ if (
231
+ // Identifies if this enum had a "const" modifier attached.
232
+ ! node . modifiers ?. some ( mod => mod . kind === ts . SyntaxKind . ConstKeyword )
233
+ ) {
234
+ declarations . enums . push ( node . name . escapedText . toString ( ) ) ;
235
+ }
228
236
} else if ( ts . isVariableStatement ( node ) ) {
229
237
const variableDeclarations = node . declarationList . declarations ;
230
238
@@ -238,9 +246,8 @@ export function extractDeclarations(
238
246
}
239
247
// Binding Pattern Example: export const {a, b} = {a: 1, b: 1};
240
248
else {
241
- const elements = variableDeclaration . name . elements as ts . NodeArray <
242
- ts . BindingElement
243
- > ;
249
+ const elements = variableDeclaration . name
250
+ . elements as ts . NodeArray < ts . BindingElement > ;
244
251
elements . forEach ( ( node : ts . BindingElement ) => {
245
252
declarations . variables . push ( node . name . getText ( sourceFile ) ) ;
246
253
} ) ;
0 commit comments