Description
As the SDK grows, accidental imports of heavy polyfills or unused Stellar SDK sub-modules can silently inflate the distributed bundle, harming browser-based dApp consumers who pay the cost at page load time. There is currently no CI enforcement of bundle size, meaning regressions are only discovered after reaching consumers. A size regression guard would measure the minified and gzipped ESM bundle on every pull request and fail the build if the size exceeds a threshold or grows by more than an allowed percentage relative to the main-branch baseline.
Technical Context
New script scripts/bundle-size-guard.ts executed via tsx. Uses esbuild (already a dev dependency) to produce a one-shot ESM bundle from src/index.ts, then zlib.gzip to measure compressed size. Baseline recorded in scripts/bundle-size-baseline.json. A new bundle:check npm script added to package.json. A companion bundle:update-baseline script regenerates the baseline file. Thresholds defined in scripts/bundle-size-config.ts.
Acceptance Criteria
Description
As the SDK grows, accidental imports of heavy polyfills or unused Stellar SDK sub-modules can silently inflate the distributed bundle, harming browser-based dApp consumers who pay the cost at page load time. There is currently no CI enforcement of bundle size, meaning regressions are only discovered after reaching consumers. A size regression guard would measure the minified and gzipped ESM bundle on every pull request and fail the build if the size exceeds a threshold or grows by more than an allowed percentage relative to the main-branch baseline.
Technical Context
New script
scripts/bundle-size-guard.tsexecuted viatsx. Usesesbuild(already a dev dependency) to produce a one-shot ESM bundle fromsrc/index.ts, thenzlib.gzipto measure compressed size. Baseline recorded inscripts/bundle-size-baseline.json. A newbundle:checknpm script added topackage.json. A companionbundle:update-baselinescript regenerates the baseline file. Thresholds defined inscripts/bundle-size-config.ts.Acceptance Criteria
npm run bundle:checkexits with code 0 when the bundle is within threshold and code 1 when it exceeds it, printing a human-readable size comparisonbundle-size-report.jsonnpm run bundle:update-baselineoverwritesbundle-size-baseline.jsonwith current measurements; the script is guarded against accidental invocation outside CI by checking aBUNDLE_BASELINE_UPDATE=trueenv var