Skip to content

Commit

Permalink
Make modulereport print size of bundle with all modules
Browse files Browse the repository at this point in the history
Seems like useful information to have.
  • Loading branch information
lawrence-forooghian committed Jan 24, 2024
1 parent 71caf05 commit 85b70d3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/moduleReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Table from 'cli-table';
// The maximum size we allow for a minimal useful Realtime bundle (i.e. one that can subscribe to a channel)
const minimalUsefulRealtimeBundleSizeThresholdsKiB = { raw: 94, gzip: 29 };

const baseClientNames = ['BaseRest', 'BaseRealtime'];

// List of all modules accepted in ModulesMap
const moduleNames = [
'Rest',
Expand Down Expand Up @@ -117,7 +119,7 @@ async function runSourceMapExplorer(bundleInfo: BundleInfo) {
async function calculateAndCheckModuleSizes(): Promise<Output> {
const output: Output = { tableRows: [], errors: [] };

for (const baseClient of ['BaseRest', 'BaseRealtime']) {
for (const baseClient of baseClientNames) {
const baseClientSizes = await getImportSizes([baseClient]);

// First output the size of the base client
Expand Down Expand Up @@ -207,6 +209,13 @@ async function calculateAndCheckMinimalUsefulRealtimeBundleSize(): Promise<Outpu
return output;
}

async function calculateAllModulesBundleSize(): Promise<TableRow> {
const exports = [...baseClientNames, ...moduleNames, ...functions.map((val) => val.name)];
const sizes = await getImportSizes(exports);

return { description: 'All modules', sizes };
}

// Performs a sense check that there are no unexpected files making a large contribution to the BaseRealtime bundle size.
async function checkBaseRealtimeFiles() {
const baseRealtimeBundleInfo = getBundleInfo(['BaseRealtime']);
Expand Down Expand Up @@ -295,6 +304,7 @@ async function checkBaseRealtimeFiles() {
const output = (
await Promise.all([
calculateAndCheckMinimalUsefulRealtimeBundleSize(),
calculateAllModulesBundleSize().then((tableRow): Output => ({ tableRows: [tableRow], errors: [] })),
calculateAndCheckModuleSizes(),
calculateAndCheckFunctionSizes(),
])
Expand Down

0 comments on commit 85b70d3

Please sign in to comment.