@@ -96,7 +96,8 @@ export async function extractDependenciesAndSize(
9696 } ) ;
9797 const externalDepsNotResolvedBundle = await rollup . rollup ( {
9898 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'
100101 } ) ;
101102 await externalDepsNotResolvedBundle . write ( {
102103 file : externalDepsNotResolvedOutput ,
@@ -224,7 +225,14 @@ export function extractDeclarations(
224225 } else if ( ts . isVariableDeclaration ( node ) ) {
225226 declarations . variables . push ( node . name ! . getText ( ) ) ;
226227 } 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+ }
228236 } else if ( ts . isVariableStatement ( node ) ) {
229237 const variableDeclarations = node . declarationList . declarations ;
230238
@@ -238,9 +246,8 @@ export function extractDeclarations(
238246 }
239247 // Binding Pattern Example: export const {a, b} = {a: 1, b: 1};
240248 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 > ;
244251 elements . forEach ( ( node : ts . BindingElement ) => {
245252 declarations . variables . push ( node . name . getText ( sourceFile ) ) ;
246253 } ) ;
0 commit comments