Skip to content

Fix size analysis script issues #4380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions repo-scripts/size-analysis/analysis-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export async function extractDependenciesAndSize(
});
const externalDepsNotResolvedBundle = await rollup.rollup({
input,
external: id => id.startsWith('@firebase') // exclude all firebase dependencies
// exclude all firebase dependencies and tslib
external: id => id.startsWith('@firebase') || id === 'tslib'
});
await externalDepsNotResolvedBundle.write({
file: externalDepsNotResolvedOutput,
Expand Down Expand Up @@ -224,7 +225,11 @@ export function extractDeclarations(
} else if (ts.isVariableDeclaration(node)) {
declarations.variables.push(node.name!.getText());
} else if (ts.isEnumDeclaration(node)) {
declarations.enums.push(node.name.escapedText.toString());
if (
!node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ConstKeyword)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some comments ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

) {
declarations.enums.push(node.name.escapedText.toString());
}
} else if (ts.isVariableStatement(node)) {
const variableDeclarations = node.declarationList.declarations;

Expand All @@ -238,9 +243,8 @@ export function extractDeclarations(
}
// Binding Pattern Example: export const {a, b} = {a: 1, b: 1};
else {
const elements = variableDeclaration.name.elements as ts.NodeArray<
ts.BindingElement
>;
const elements = variableDeclaration.name
.elements as ts.NodeArray<ts.BindingElement>;
elements.forEach((node: ts.BindingElement) => {
declarations.variables.push(node.name.getText(sourceFile));
});
Expand Down