Skip to content

Shrink the bundle: split modules and pack the datasets, no behaviour change - #616

Merged
hyanmandian merged 15 commits into
claude/final-validationfrom
claude/bundle-shrink
Sep 29, 2026
Merged

hyanmandian merged 15 commits into
claude/final-validationfrom
claude/bundle-shrink

Conversation

@hyanmandian

@hyanmandian hyanmandian commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Second PR of the stack (base: #615). The smallest consumer bundle without any behaviour, type or API change: only module splits, import changes and more compact, content-identical dataset encodings decoded lazily on first read.

Totals (esbuild, every export imported)

tree bytes gzip
base (#615) 1,891,363 336,019
this PR 1,419,421 (-25%) 299,486 (-11%)

Biggest single-import wins (bytes / gzip)

export before after
getAreaCodeByMunicipalityCode 169,039 / 53,412 24,137 / 5,708 (-89% gz)
isValidCid10 26,853 / 7,004 6,813 / 2,502 (-64% gz)
getCities 157,195 / 50,505 65,718 / 27,023 (-46% gz)
getMunicipalities, getMunicipalityByCode, getCodeByMunicipalityName ~157,400 / ~50,600 ~78,000 / ~30,300 (-40% gz)
getMunicipalitiesByAreaCode 171,815 / 54,034 92,476 / 33,746 (-38% gz)
banks (getBanks, getBankByCode, getBankByIspb) ~38,700 / ~9,400 ~27,000 / ~7,900 (-16% gz)
formatIsbn, getIsbnInfo ~27,600 / ~6,300 ~15,600 / ~5,600 (-11% gz)
getCid10 1,012,034 / 126,523 738,866 / 116,179 (-8% gz)

Subpath entries: get-cst-ibs-cbs, is-valid-cst-ibs-cbs and is-valid-class-trib drop from ~50 KB to 1-3 KB each (they shared a chunk with 48 KB of cClassTrib descriptions), is-valid-legal-nature from 5.9 KB to 1 KB, is-valid-mobile-phone from 3.8 KB to 1.9 KB (a type-only import cycle made rolldown merge the phone chunks).

What changed

  • Municipalities: names and codes ship apart, so a code lookup never bundles a name; codes are base 36 differences with the IBGE check digit derived (the 9 codes that break the check digit rule are stored explicitly), and the state comes from the first two digits of the code (a test asserts that rule for every code, so a dataset refresh that breaks it fails).
  • Description tables (CID-10, CBO, CEST, CFOP, CNAE, NBS, LC 116 service list, municipality names): one string, front-coded against the previous line, unpacked once by _internals/unpack-texts.
  • CID-10 categories as base 36 distances plus subcategory masks; ISBN range ends without their trailing 9s; banks as three columns sharing the COMPE code list with isValidBankAccount; the cClassTrib and legal nature codes out of the modules that hold their descriptions.
  • Every generator in scripts/ emits the new encodings: regenerating from the committed data reproduces every file byte for byte, and old and new tables were compared entry by entry.

Trade-off

The first call of a lookup unpacks its table once (for example isValidCid10 ~2.6 ms, getCid10 ~2 ms on a laptop); warm calls are as fast or faster (getMunicipalityByCode 10.3 µs to 0.9 µs), and the next PR makes the lookups much faster still.

The size figures in docs/getting-started.md, docs/utilities.md, the README and the state-city guide (EN and PT) are regenerated from scripts/tree-shaking.ts.

Gates

vp check, tests with 100% coverage, build, jscpd, knip, check:api (731 type assertions against 2.4.0 hold), commitlint, Stryker 100% on the changed files; a differential run over 12.9M calls finds 0 output differences against #615.

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
brazilian-utils Ready Ready Preview Sep 29, 2026 11:06am UTC

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 66b42ed1-1697-407f-b2a5-b3c9dfd65660

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@brazilian-utils/brazilian-utils@616

commit: e883225

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Tree-shaking report

✅ No size regression. 13 grew, 33 shrank out of 198 exports.

Base Head Δ
Pre-existing exports, all imported 1847.0 KB 1386.2 KB (gzip 292.5 KB) -460.9 KB (-25.0%)
Full import 1847.0 KB 1386.2 KB (gzip 292.5 KB) -460.9 KB (-25.0%)
Exports 198 198 0

What changed (46)

Export Base Head Δ gzip
🟢 getCid10 988.3 KB 721.5 KB -266.8 KB (-27.0%) 113.5 KB
🟢 getAreaCodeByMunicipalityCode 165.1 KB 23.6 KB -141.5 KB (-85.7%) 5.6 KB
🟢 getCities 153.5 KB 64.2 KB -89.3 KB (-58.2%) 26.4 KB
🟢 getCodeByMunicipalityName 153.6 KB 76.0 KB -77.6 KB (-50.5%) 29.4 KB
🟢 getMunicipalitiesByAreaCode 167.8 KB 90.3 KB -77.5 KB (-46.2%) 33.0 KB
🟢 getMunicipalities 153.7 KB 76.2 KB -77.5 KB (-50.4%) 29.5 KB
🟢 getMunicipalityByCode 153.8 KB 76.3 KB -77.4 KB (-50.3%) 29.6 KB
🟢 getMunicipality 154.2 KB 76.9 KB -77.3 KB (-50.1%) 29.9 KB
🟢 getCbo 107.6 KB 80.6 KB -27.0 KB (-25.1%) 24.1 KB
🟢 getNbs 75.6 KB 51.1 KB -24.5 KB (-32.4%) 11.3 KB
🟢 getCnae 86.6 KB 66.8 KB -19.8 KB (-22.9%) 17.7 KB
🟢 isValidCid10 26.2 KB 6.7 KB -19.6 KB (-74.6%) 2.4 KB
🟢 formatIsbn 27.0 KB 15.3 KB -11.8 KB (-43.5%) 5.5 KB
🟢 getIsbnInfo 26.9 KB 15.1 KB -11.8 KB (-43.7%) 5.4 KB
🟢 getBankByCode 37.8 KB 26.5 KB -11.3 KB (-30.0%) 7.8 KB
🟢 getBankByIspb 37.8 KB 26.4 KB -11.3 KB (-30.0%) 7.7 KB
🟢 getBanks 37.6 KB 26.2 KB -11.3 KB (-30.2%) 7.6 KB
🟢 getCfop 66.8 KB 56.9 KB -9.9 KB (-14.8%) 5.1 KB
🟢 getCest 111.6 KB 102.3 KB -9.4 KB (-8.4%) 24.1 KB
🟢 getServiceItem 26.1 KB 25.5 KB -553 B (-2.1%) 8.2 KB
Show the other 26
Export Base Head Δ gzip
🟡 isValidCbo 6.7 KB 6.7 KB +15 B (+0.2%) 1.7 KB
🟡 isValidBankAccount 5.1 KB 5.1 KB +11 B (+0.2%) 1.9 KB
🟡 isValidCest 3.6 KB 3.6 KB +11 B (+0.3%) 856 B
🟡 isValidCfop 1.9 KB 2.0 KB +11 B (+0.6%) 700 B
🟡 isValidCnae 4.6 KB 4.6 KB +11 B (+0.2%) 1.9 KB
🟡 isValidNbs 3.5 KB 3.5 KB +11 B (+0.3%) 1.3 KB
🟡 isValidNcm 29.6 KB 29.6 KB +11 B (+0.0%) 9.0 KB
🟡 isValidServiceItem 1.1 KB 1.1 KB +11 B (+1.0%) 570 B
🟡 isValidPhone 1.9 KB 1.9 KB +8 B (+0.4%) 963 B
🟡 isValidLegalNature 911 B 918 B +7 B (+0.8%) 554 B
🟢 generateLegalNature 5.0 KB 5.0 KB -4 B (-0.1%) 1.6 KB
🟢 generatePixPayload 4.7 KB 4.7 KB -4 B (-0.1%) 2.1 KB
🟢 getCstIbsCbs 967 B 963 B -4 B (-0.4%) 534 B
🟢 getLegalNature 5.7 KB 5.7 KB -4 B (-0.1%) 1.9 KB
🟢 getLegalNatures 5.1 KB 5.1 KB -4 B (-0.1%) 1.6 KB
🟢 getLegalNaturesByCategory 5.6 KB 5.6 KB -4 B (-0.1%) 1.9 KB
🟡 getNfeKeyInfo 2.2 KB 2.2 KB +4 B (+0.2%) 1.2 KB
🟢 getPixKeyInfo 2.7 KB 2.7 KB -4 B (-0.1%) 1.3 KB
🟢 getPixPayloadInfo 4.8 KB 4.8 KB -4 B (-0.1%) 2.2 KB
🟢 isValidClassTrib 1.8 KB 1.8 KB -4 B (-0.2%) 610 B
🟢 isValidCstIbsCbs 894 B 890 B -4 B (-0.4%) 504 B
🟡 isValidLandlinePhone 886 B 890 B +4 B (+0.5%) 561 B
🟢 isValidMobilePhone 927 B 923 B -4 B (-0.4%) 590 B
🟡 isValidNfeKey 1.6 KB 1.6 KB +4 B (+0.2%) 958 B
🟢 isValidPixKey 2.5 KB 2.5 KB -4 B (-0.2%) 1.2 KB
🟢 isValidPixPayload 4.3 KB 4.3 KB -4 B (-0.1%) 2.0 KB
All exports (198)
Export Base Head Δ gzip
⚪ GetAddressInfoByCepError 112 B 112 B 0 B 124 B
⚪ GetAddressInfoByCepNotFoundError 205 B 205 B 0 B 145 B
⚪ GetAddressInfoByCepServiceError 204 B 204 B 0 B 143 B
⚪ GetAddressInfoByCepValidationError 203 B 203 B 0 B 144 B
⚪ GetCepInfoByAddressError 112 B 112 B 0 B 124 B
⚪ GetCepInfoByAddressNotFoundError 205 B 205 B 0 B 145 B
⚪ GetCepInfoByAddressValidationError 203 B 203 B 0 B 144 B
⚪ addBusinessDays 9.5 KB 9.5 KB 0 B 3.3 KB
⚪ capitalize 2.5 KB 2.5 KB 0 B 1.2 KB
⚪ convertCurrencyToWords 2.0 KB 2.0 KB 0 B 1.0 KB
⚪ convertDateToWords 2.4 KB 2.4 KB 0 B 1.2 KB
⚪ convertLicensePlateToMercosul 632 B 632 B 0 B 425 B
⚪ convertNumberToWords 1.6 KB 1.6 KB 0 B 817 B
⚪ differenceInBusinessDays 9.3 KB 9.3 KB 0 B 3.3 KB
⚪ formatBoleto 668 B 668 B 0 B 407 B
⚪ formatCEP 489 B 489 B 0 B 348 B
⚪ formatCNPJ 639 B 639 B 0 B 430 B
⚪ formatCPF 540 B 540 B 0 B 376 B
⚪ formatCaepf 506 B 506 B 0 B 358 B
⚪ formatCbo 491 B 491 B 0 B 350 B
⚪ formatCei 503 B 503 B 0 B 356 B
⚪ formatCep 489 B 489 B 0 B 348 B
⚪ formatCertidao 532 B 532 B 0 B 361 B
⚪ formatCest 493 B 493 B 0 B 350 B
⚪ formatCfop 489 B 489 B 0 B 349 B
⚪ formatCid10 478 B 478 B 0 B 339 B
⚪ formatCnae 493 B 493 B 0 B 352 B
⚪ formatCnh 536 B 536 B 0 B 374 B
⚪ formatCno 507 B 507 B 0 B 357 B
⚪ formatCnpj 639 B 639 B 0 B 430 B
⚪ formatCns 506 B 506 B 0 B 352 B
⚪ formatCpf 540 B 540 B 0 B 376 B
⚪ formatCurrency 1023 B 1023 B 0 B 613 B
⚪ formatIban 267 B 267 B 0 B 228 B
🟢 formatIsbn 27.0 KB 15.3 KB -11.8 KB (-43.5%) 5.5 KB
⚪ formatLegalNature 489 B 489 B 0 B 349 B
⚪ formatLicensePlate 361 B 361 B 0 B 270 B
⚪ formatNbs 496 B 496 B 0 B 353 B
⚪ formatNcm 494 B 494 B 0 B 352 B
⚪ formatNfeKey 724 B 724 B 0 B 461 B
⚪ formatPassport 187 B 187 B 0 B 174 B
⚪ formatPhone 2.6 KB 2.6 KB 0 B 1.2 KB
⚪ formatPis 540 B 540 B 0 B 377 B
⚪ formatProcessoJuridico 509 B 509 B 0 B 357 B
⚪ formatSuframa 499 B 499 B 0 B 354 B
⚪ formatVoterId 542 B 542 B 0 B 377 B
⚪ generateBoleto 1.4 KB 1.4 KB 0 B 779 B
⚪ generateCNPJ 843 B 843 B 0 B 524 B
⚪ generateCPF 694 B 694 B 0 B 456 B
⚪ generateCep 1.3 KB 1.3 KB 0 B 471 B
⚪ generateCnh 565 B 565 B 0 B 343 B
⚪ generateCnpj 843 B 843 B 0 B 524 B
⚪ generateCpf 694 B 694 B 0 B 456 B
🟢 generateLegalNature 5.0 KB 5.0 KB -4 B (-0.1%) 1.6 KB
⚪ generateLicensePlate 308 B 308 B 0 B 243 B
⚪ generatePassport 226 B 226 B 0 B 191 B
⚪ generatePhone 670 B 670 B 0 B 419 B
⚪ generatePis 357 B 357 B 0 B 273 B
🟢 generatePixPayload 4.7 KB 4.7 KB -4 B (-0.1%) 2.1 KB
⚪ generateProcessoJuridico 821 B 821 B 0 B 523 B
⚪ generateRenavam 378 B 378 B 0 B 284 B
⚪ generateSuframa 451 B 451 B 0 B 335 B
⚪ generateVoterId 922 B 922 B 0 B 587 B
⚪ getAddressInfoByCep 5.3 KB 5.3 KB 0 B 2.1 KB
🟢 getAreaCodeByMunicipalityCode 165.1 KB 23.6 KB -141.5 KB (-85.7%) 5.6 KB
⚪ getAreaCodeInfo 3.1 KB 3.1 KB 0 B 989 B
⚪ getAreaCodesByState 814 B 814 B 0 B 463 B
🟢 getBankByCode 37.8 KB 26.5 KB -11.3 KB (-30.0%) 7.8 KB
🟢 getBankByIspb 37.8 KB 26.4 KB -11.3 KB (-30.0%) 7.7 KB
🟢 getBanks 37.6 KB 26.2 KB -11.3 KB (-30.2%) 7.6 KB
⚪ getBoletoInfo 2.7 KB 2.7 KB 0 B 1.4 KB
🟢 getCbo 107.6 KB 80.6 KB -27.0 KB (-25.1%) 24.1 KB
⚪ getCepInfoByAddress 2.2 KB 2.2 KB 0 B 1.1 KB
⚪ getCertidaoInfo 1.0 KB 1.0 KB 0 B 594 B
🟢 getCest 111.6 KB 102.3 KB -9.4 KB (-8.4%) 24.1 KB
🟢 getCfop 66.8 KB 56.9 KB -9.9 KB (-14.8%) 5.1 KB
🟢 getCid10 988.3 KB 721.5 KB -266.8 KB (-27.0%) 113.5 KB
🟢 getCities 153.5 KB 64.2 KB -89.3 KB (-58.2%) 26.4 KB
⚪ getClassTrib 50.0 KB 50.0 KB 0 B 9.0 KB
🟢 getCnae 86.6 KB 66.8 KB -19.8 KB (-22.9%) 17.7 KB
⚪ getCnpjInfo 964 B 964 B 0 B 542 B
🟢 getCodeByMunicipalityName 153.6 KB 76.0 KB -77.6 KB (-50.5%) 29.4 KB
⚪ getCpfInfo 994 B 994 B 0 B 614 B
🟢 getCstIbsCbs 967 B 963 B -4 B (-0.4%) 534 B
⚪ getFormatLicensePlate 420 B 420 B 0 B 301 B
⚪ getGtinInfo 821 B 821 B 0 B 559 B
⚪ getHolidays 8.4 KB 8.4 KB 0 B 2.9 KB
⚪ getIbanInfo 752 B 752 B 0 B 492 B
🟢 getIsbnInfo 26.9 KB 15.1 KB -11.8 KB (-43.7%) 5.4 KB
🟢 getLegalNature 5.7 KB 5.7 KB -4 B (-0.1%) 1.9 KB
🟢 getLegalNatures 5.1 KB 5.1 KB -4 B (-0.1%) 1.6 KB
🟢 getLegalNaturesByCategory 5.6 KB 5.6 KB -4 B (-0.1%) 1.9 KB
🟢 getMunicipalities 153.7 KB 76.2 KB -77.5 KB (-50.4%) 29.5 KB
🟢 getMunicipalitiesByAreaCode 167.8 KB 90.3 KB -77.5 KB (-46.2%) 33.0 KB
🟢 getMunicipality 154.2 KB 76.9 KB -77.3 KB (-50.1%) 29.9 KB
🟢 getMunicipalityByCode 153.8 KB 76.3 KB -77.4 KB (-50.3%) 29.6 KB
🟢 getNbs 75.6 KB 51.1 KB -24.5 KB (-32.4%) 11.3 KB
🟡 getNfeKeyInfo 2.2 KB 2.2 KB +4 B (+0.2%) 1.2 KB
⚪ getNfseKeyInfo 2.6 KB 2.6 KB 0 B 1.2 KB
🟢 getPixKeyInfo 2.7 KB 2.7 KB -4 B (-0.1%) 1.3 KB
🟢 getPixPayloadInfo 4.8 KB 4.8 KB -4 B (-0.1%) 2.2 KB
⚪ getRegions 255 B 255 B 0 B 165 B
🟢 getServiceItem 26.1 KB 25.5 KB -553 B (-2.1%) 8.2 KB
⚪ getStateByCep 3.6 KB 3.6 KB 0 B 1.0 KB
⚪ getStateByIbgeCode 2.4 KB 2.4 KB 0 B 700 B
⚪ getStateCapital 955 B 955 B 0 B 638 B
⚪ getStateCodeByName 2.3 KB 2.3 KB 0 B 649 B
⚪ getStateNameByCode 2.2 KB 2.2 KB 0 B 594 B
⚪ getStates 2.2 KB 2.2 KB 0 B 539 B
⚪ getStatesByRegion 2.3 KB 2.3 KB 0 B 602 B
⚪ getTimezoneByState 755 B 755 B 0 B 342 B
⚪ isBusinessDay 8.8 KB 8.8 KB 0 B 3.1 KB
⚪ isHoliday 8.6 KB 8.6 KB 0 B 3.0 KB
🟡 isValidBankAccount 5.1 KB 5.1 KB +11 B (+0.2%) 1.9 KB
⚪ isValidBoleto 1.8 KB 1.8 KB 0 B 970 B
⚪ isValidCEP 165 B 165 B 0 B 165 B
⚪ isValidCNPJ 796 B 796 B 0 B 447 B
⚪ isValidCPF 500 B 500 B 0 B 334 B
⚪ isValidCaepf 782 B 782 B 0 B 479 B
🟡 isValidCbo 6.7 KB 6.7 KB +15 B (+0.2%) 1.7 KB
⚪ isValidCei 714 B 714 B 0 B 472 B
⚪ isValidCep 165 B 165 B 0 B 165 B
⚪ isValidCertidao 758 B 758 B 0 B 462 B
🟡 isValidCest 3.6 KB 3.6 KB +11 B (+0.3%) 856 B
🟡 isValidCfop 1.9 KB 2.0 KB +11 B (+0.6%) 700 B
🟢 isValidCid10 26.2 KB 6.7 KB -19.6 KB (-74.6%) 2.4 KB
🟢 isValidClassTrib 1.8 KB 1.8 KB -4 B (-0.2%) 610 B
🟡 isValidCnae 4.6 KB 4.6 KB +11 B (+0.2%) 1.9 KB
⚪ isValidCnh 612 B 612 B 0 B 372 B
⚪ isValidCno 718 B 718 B 0 B 474 B
⚪ isValidCnpj 796 B 796 B 0 B 447 B
⚪ isValidCns 746 B 746 B 0 B 475 B
⚪ isValidCpf 500 B 500 B 0 B 334 B
⚪ isValidCreditCard 555 B 555 B 0 B 389 B
⚪ isValidCsosn 330 B 330 B 0 B 262 B
⚪ isValidCst 978 B 978 B 0 B 549 B
🟢 isValidCstIbsCbs 894 B 890 B -4 B (-0.4%) 504 B
⚪ isValidEmail 244 B 244 B 0 B 198 B
⚪ isValidGtin 432 B 432 B 0 B 315 B
⚪ isValidIE 5.2 KB 5.2 KB 0 B 1.8 KB
⚪ isValidIban 531 B 531 B 0 B 376 B
⚪ isValidIe 5.2 KB 5.2 KB 0 B 1.8 KB
⚪ isValidIsbn 422 B 422 B 0 B 328 B
🟡 isValidLandlinePhone 886 B 890 B +4 B (+0.5%) 561 B
🟡 isValidLegalNature 911 B 918 B +7 B (+0.8%) 554 B
⚪ isValidLicensePlate 372 B 372 B 0 B 280 B
🟢 isValidMobilePhone 927 B 923 B -4 B (-0.4%) 590 B
🟡 isValidNbs 3.5 KB 3.5 KB +11 B (+0.3%) 1.3 KB
🟡 isValidNcm 29.6 KB 29.6 KB +11 B (+0.0%) 9.0 KB
🟡 isValidNfeKey 1.6 KB 1.6 KB +4 B (+0.2%) 958 B
⚪ isValidNfseKey 2.2 KB 2.2 KB 0 B 1.1 KB
⚪ isValidPIS 418 B 418 B 0 B 315 B
⚪ isValidPassport 197 B 197 B 0 B 186 B
🟡 isValidPhone 1.9 KB 1.9 KB +8 B (+0.4%) 963 B
⚪ isValidPis 418 B 418 B 0 B 315 B
🟢 isValidPixKey 2.5 KB 2.5 KB -4 B (-0.2%) 1.2 KB
🟢 isValidPixPayload 4.3 KB 4.3 KB -4 B (-0.1%) 2.0 KB
⚪ isValidProcessoJuridico 711 B 711 B 0 B 432 B
⚪ isValidRegistroProfissional 1.3 KB 1.3 KB 0 B 787 B
⚪ isValidRenavam 518 B 518 B 0 B 358 B
🟡 isValidServiceItem 1.1 KB 1.1 KB +11 B (+1.0%) 570 B
⚪ isValidServicePhone 1.0 KB 1.0 KB 0 B 573 B
⚪ isValidSuframa 611 B 611 B 0 B 418 B
⚪ isValidVin 898 B 898 B 0 B 600 B
⚪ isValidVoterId 728 B 728 B 0 B 433 B
⚪ parseBoleto 247 B 247 B 0 B 215 B
⚪ parseCaepf 199 B 199 B 0 B 183 B
⚪ parseCbo 198 B 198 B 0 B 182 B
⚪ parseCei 199 B 199 B 0 B 183 B
⚪ parseCep 198 B 198 B 0 B 182 B
⚪ parseCertidao 199 B 199 B 0 B 183 B
⚪ parseCest 198 B 198 B 0 B 182 B
⚪ parseCfop 198 B 198 B 0 B 182 B
⚪ parseCid10 177 B 177 B 0 B 170 B
⚪ parseCnae 198 B 198 B 0 B 182 B
⚪ parseCnh 199 B 199 B 0 B 183 B
⚪ parseCno 199 B 199 B 0 B 183 B
⚪ parseCnpj 298 B 298 B 0 B 240 B
⚪ parseCns 199 B 199 B 0 B 184 B
⚪ parseCpf 199 B 199 B 0 B 183 B
⚪ parseCurrency 610 B 610 B 0 B 409 B
⚪ parseIban 227 B 227 B 0 B 202 B
⚪ parseIsbn 150 B 150 B 0 B 150 B
⚪ parseLegalNature 198 B 198 B 0 B 182 B
⚪ parseLicensePlate 177 B 177 B 0 B 169 B
⚪ parseNbs 198 B 198 B 0 B 181 B
⚪ parseNcm 198 B 198 B 0 B 182 B
⚪ parseNfeKey 412 B 412 B 0 B 312 B
⚪ parseNfseKey 253 B 253 B 0 B 219 B
⚪ parsePassport 177 B 177 B 0 B 169 B
⚪ parsePhone 497 B 497 B 0 B 341 B
⚪ parsePis 199 B 199 B 0 B 183 B
⚪ parseProcessoJuridico 199 B 199 B 0 B 182 B
⚪ parseSuframa 198 B 198 B 0 B 181 B
⚪ parseVoterId 199 B 199 B 0 B 183 B
⚪ removeAccents 99 B 99 B 0 B 119 B
⚪ subBusinessDays 9.6 KB 9.6 KB 0 B 3.4 KB
⚪ toStandardSchema 324 B 324 B 0 B 254 B
How this is measured

Every export is imported alone into an esbuild consumer bundle (minified, tree-shaken) built from the head and from the base of this pull request; the sizes are the resulting bundles, gzip is their gzipped size. 🔴 marks a regression: a pre-existing export that grew more than 20% and more than 256 B, or the bundle importing every pre-existing export growing more than 5%. 🟡 is growth under the threshold, 🟢 a decrease, ⚪ no change, 🆕 an export that does not exist on the base (never a regression), 🗑️ an export that was removed. An intentional increase is accepted with the tree-shaking: accepted label.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0ad6d4e) to head (e883225).

Additional details and impacted files
@@                    Coverage Diff                    @@
##           claude/final-validation      #616   +/-   ##
=========================================================
  Coverage                   100.00%   100.00%           
=========================================================
  Files                          247       255    +8     
  Lines                         2500      2558   +58     
  Branches                       733       745   +12     
=========================================================
+ Hits                          2500      2558   +58     
Flag Coverage Δ
node 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…kup bundles what it reads

The IBGE table went from one array of [name, code] tuples to two modules: the names joined
by a separator, and the codes as base 36 differences with the check digit left out (nine
codes that break the rule are kept explicitly). getAreaCodeByMunicipalityCode no longer
bundles the names, and the others bundle about 40% less.
…rt of neighbouring texts

The CID-10, CBO, CEST, CFOP, CNAE, NBS and service list descriptions were arrays of quoted
strings. Each is now a single string with one text per line, each line starting with the
number of characters it shares with the previous text, unpacked on the first read. The
texts are unchanged.
…tions are packed

Each state's names are one packed string that shares the start of neighbouring names,
unpacked on the first read.
…gory masks

CID10_SUBCATEGORIES was a record of about 2,000 categories with their subcategory digits.
It is now a string of three characters per category, unpacked on the first read, which
cuts what isValidCid10 bundles from 26 KB to 6 KB.
…ith the bank account validator

The compensation codes move to their own module, which isValidBankAccount and the bank
getters both read; the ISPBs and the names are two strings unpacked on the first read.
… CST table module

The subpath builds of isValidCstIbsCbs, getCstIbsCbs and isValidClassTrib shared one chunk
with the 48 KB of cClassTrib descriptions; they now import only the modules they read.
…ach other's types

isValidMobilePhone imported PhoneVersion from isValidPhone, which imports it back, so the
subpath build merged both into one chunk with the service phone table. PhoneVersion now
lives with isValidMobilePhone and isValidPhone re-exports it.
…t holds the descriptions

isValidLegalNature shared one chunk with the descriptions and the legacy map of
getLegalNature; the codes are now a module of their own.
…code of its state

getMunicipalityByCode and getAreaCodeByMunicipalityCode read the state off the first two
digits of the code.
The module kept a top-level new Map(), which the conventions forbid for module scope state and which
readCodeTable already avoids. The cache is now created lazily on the first read.
The figures were measured before the datasets were packed. They now come from node
scripts/tree-shaking.ts on the built branch: the size table of the getting started page, the
isValidCpf intro figure, the getCities, isValidCid10 and getCid10 sizes of the utilities reference,
the state and city guides and their snippets. getStates is 2.2 KB, not 2.5 KB.
Stryker's 100% threshold failed on three mutants of the code this branch adds. The write
to the cache of readCodeTable and the extra pass of calculateMunicipalityCheckDigit (it
adds Number(""), which is 0) are equivalent and carry a disable directive with the
reason. A new test pins that unpackTexts reads the first text whole, whatever start
length it claims, which kills the third.

No behavior changes.
readCodeTable and unpackTexts hid the killable variants of their cache hit condition behind a
directive, and carried a stale one on a `??= new Map()` statement with no mutant. Both now read
the cache as `get(key) ?? store(...)`, so no condition is left to hide. readCodeTable gets a
test of its own (a table read, two tables kept apart, the same table handed back), which kills
the mutant of the store call, and unpackTexts already had that test. Stryker scores 100% on both
files with no directive.

No behavior changes.
The table readers of getCest and the municipality DDD lookups changed after the figures were
generated, so their size rows are measured again with node scripts/tree-shaking.ts on this
branch.
@hyanmandian
hyanmandian added this pull request to stack #618 September 29, 2026 12:49
@hyanmandian
hyanmandian merged commit d294baa into main Sep 29, 2026
30 checks passed

This branch was successfully deployed

1 active deployment
Preview — e8832252 Deployed Sep 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant