Skip to content

Commit f92e14a

Browse files
committed
docs: update the bundle sizes after the tree-shaking work
The bundle size table of the getting started page (English and Portuguese) is refreshed from `node scripts/tree-shaking.ts --json`: a root import of isValidCpf is now about 0.5 KB minified (0.3 KB gzipped) instead of 1.4 KB (0.8 KB), in the README too. The lookup validators no longer share a row with their getters, since they now bundle the codes alone: isValidCbo, isValidCnae, isValidNbs, isValidCest and isValidCid10 get rows of their own, and isValidCfop (2.8 KB) and isValidServiceItem (1.2 KB) leave the table of heavy utils. The getCities, isValidCid10 and getCid10 notes of the utilities page get their new sizes as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLkm9YrtAifc6XCLFVEsdH
1 parent bbd076f commit f92e14a

5 files changed

Lines changed: 45 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Brazilian Utils is a zero-dependency library of small utilities for the day-to-d
3434
## Why Brazilian Utils
3535

3636
- **Zero runtime dependencies.** Nothing else lands in your `node_modules` or in your bundle.
37-
- **Tree-shakeable, down to the function.** `import { isValidCpf }` costs about 1.4 KB minified (0.8 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
37+
- **Tree-shakeable, down to the function.** `import { isValidCpf }` costs about 0.5 KB minified (0.3 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
3838
- **Runs everywhere.** Node.js `^20.19.0 || >=22.12.0`, Bun, Deno and evergreen browsers, all tested in CI.
3939
- **Written in TypeScript.** Types ship with the package, and every pull request is checked against the last release so the public API never changes silently.
4040
- **Validated against the official rules.** Every validator cites the specification, law or dataset it implements, and the test suite is mutation-tested, not just covered.

‎docs/getting-started.md‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Brazilian Utils is a zero-dependency library of small utilities for the day-to-d
99
## Why Brazilian Utils
1010

1111
- **Zero runtime dependencies.** Nothing else lands in your `node_modules` or in your bundle.
12-
- **Tree-shakeable, down to the function.** `import { isValidCpf }` costs about 1.4 KB minified (0.8 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
12+
- **Tree-shakeable, down to the function.** `import { isValidCpf }` costs about 0.5 KB minified (0.3 KB gzipped). Every util is also its own subpath entry, so the heavy ones can be lazy-loaded.
1313
- **Runs everywhere.** Node.js `^20.19.0 || >=22.12.0`, Bun, Deno and evergreen browsers, all tested in CI.
1414
- **Written in TypeScript.** Types ship with the package, and every pull request is checked against the last release so the public API never changes silently.
1515
- **Validated against the official rules.** Every validator cites the specification, law or dataset it implements, and the test suite is mutation-tested, not just covered.
@@ -62,12 +62,29 @@ Without Context7, point the assistant at [llms.txt](https://brazilian-utils.com.
6262

6363
## Bundle size
6464

65-
The package is tree-shakeable: importing one util from the root pulls in only that util's code. `isValidCpf`, for example, adds about 1.4 KB minified (0.8 KB gzipped) to your bundle.
65+
The package is tree-shakeable: importing one util from the root pulls in only that util's code. `isValidCpf`, for example, adds about 0.5 KB minified (0.3 KB gzipped) to your bundle.
6666

6767
A few utils embed an official dataset and weigh far more than everything else combined:
6868

6969
| Util | Dataset | Minified | Gzipped |
7070
| --- | --- | --- | --- |
71+
| `getCid10` | CID-10 V2008 categories and subcategories, with the DATASUS descriptions | 988.2 KB | 123.5 KB |
72+
| `getMunicipalities` · `getMunicipalityByCode` · `getMunicipality` | 5571 IBGE municipalities, with names and codes | 153.6 - 154.0 KB | 49.4 - 49.7 KB |
73+
| `getCities` | 5571 IBGE municipality names | 153.4 KB | 49.2 KB |
74+
| `getCbo` | CBO 2002 occupation titles | 115.7 KB | 29.5 KB |
75+
| `getCest` | CEST descriptions and segments (Convênio ICMS 142/18) | 115.6 KB | 26.1 KB |
76+
| `getCnae` | CNAE-Subclasses 2.3 | 91.6 KB | 20.0 KB |
77+
| `isValidNcm` | NCM (Nomenclatura Comum do Mercosul) codes | 82.6 KB | 22.8 KB |
78+
| `getNbs` | NBS 2.0 (Nomenclatura Brasileira de Serviços) descriptions | 80.6 KB | 13.1 KB |
79+
| `getCfop` | CFOP operation descriptions | 67.6 KB | 6.3 KB |
80+
| `getClassTrib` | cClassTrib (IBS/CBS) names and descriptions | 50.0 KB | 9.0 KB |
81+
| `getBanks` · `getBankByCode` · `getBankByIspb` | Banco Central STR participants (COMPE + ISPB) | 37.5 - 37.8 KB | 9.0 - 9.2 KB |
82+
| `isValidCid10` | CID-10 V2008 category and subcategory codes, without the descriptions | 26.2 KB | 6.8 KB |
83+
| `getServiceItem` | Service list of the Lei Complementar 116/2003 | 26.1 KB | 8.4 KB |
84+
| `isValidCbo` | CBO 2002 occupation codes, without the titles | 16.2 KB | 5.5 KB |
85+
| `isValidCnae` | CNAE-Subclasses 2.3 codes, without the descriptions | 9.6 KB | 3.4 KB |
86+
| `isValidNbs` | NBS 2.0 codes, without the descriptions | 8.5 KB | 2.3 KB |
87+
| `isValidCest` | CEST codes, without the descriptions | 7.6 KB | 2.3 KB |
7188
| `getCid10` | CID-10 V2008 categories and subcategories, with the DATASUS descriptions | 1030.4 KB | 146.9 KB |
7289
| `getMunicipalities` · `getMunicipalityByCode` · `getMunicipality` | 5571 IBGE municipalities, with names and codes | 154.9 - 156.5 KB | 50.3 - 50.4 KB |
7390
| `getCities` | 5571 IBGE municipality names | 154.2 KB | 49.8 KB |

‎docs/pt-br/getting-started.md‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Brazilian Utils é uma biblioteca de utilitários, sem dependências, para os pr
99
## Por que Brazilian Utils
1010

1111
- **Zero dependências de runtime.** Nada além da biblioteca entra no seu `node_modules` ou no seu bundle.
12-
- **Tree-shakeable até a função.** `import { isValidCpf }` custa cerca de 1,4 KB minificado (0,8 KB com gzip). Cada utilitário também é um subpath próprio, então os pesados podem ser carregados sob demanda.
12+
- **Tree-shakeable até a função.** `import { isValidCpf }` custa cerca de 0,5 KB minificado (0,3 KB com gzip). Cada utilitário também é um subpath próprio, então os pesados podem ser carregados sob demanda.
1313
- **Roda em qualquer lugar.** Node.js `^20.19.0 || >=22.12.0`, Bun, Deno e navegadores modernos, todos testados no CI.
1414
- **Escrita em TypeScript.** Os tipos vêm no pacote, e todo pull request é comparado com a última versão publicada para que a API pública nunca mude em silêncio.
1515
- **Validada contra as regras oficiais.** Cada validador cita a especificação, lei ou base de dados que implementa, e a suíte de testes passa por mutation testing, não só por cobertura.
@@ -62,12 +62,29 @@ Sem o Context7, aponte o assistente para o [llms.txt](https://brazilian-utils.co
6262

6363
## Tamanho do bundle
6464

65-
O pacote é tree-shakeable: importar um utilitário da raiz traz apenas o código daquele utilitário. `isValidCpf`, por exemplo, adiciona cerca de 1,4 KB minificado (0,8 KB com gzip) ao seu bundle.
65+
O pacote é tree-shakeable: importar um utilitário da raiz traz apenas o código daquele utilitário. `isValidCpf`, por exemplo, adiciona cerca de 0,5 KB minificado (0,3 KB com gzip) ao seu bundle.
6666

6767
Alguns utilitários embutem uma base de dados oficial e pesam muito mais que todos os outros somados:
6868

6969
| Utilitário | Base de dados | Minificado | Gzip |
7070
| --- | --- | --- | --- |
71+
| `getCid10` | categorias e subcategorias da CID-10 V2008, com as descrições do DATASUS | 988,2 KB | 123,5 KB |
72+
| `getMunicipalities` · `getMunicipalityByCode` · `getMunicipality` | 5571 municípios do IBGE, com nomes e códigos | 153,6 - 154,0 KB | 49,4 - 49,7 KB |
73+
| `getCities` | nomes dos 5571 municípios do IBGE | 153,4 KB | 49,2 KB |
74+
| `getCbo` | títulos das ocupações da CBO 2002 | 115,7 KB | 29,5 KB |
75+
| `getCest` | descrições e segmentos do CEST (Convênio ICMS 142/18) | 115,6 KB | 26,1 KB |
76+
| `getCnae` | CNAE-Subclasses 2.3 | 91,6 KB | 20,0 KB |
77+
| `isValidNcm` | códigos NCM (Nomenclatura Comum do Mercosul) | 82,6 KB | 22,8 KB |
78+
| `getNbs` | descrições da NBS 2.0 (Nomenclatura Brasileira de Serviços) | 80,6 KB | 13,1 KB |
79+
| `getCfop` | descrições das operações do CFOP | 67,6 KB | 6,3 KB |
80+
| `getClassTrib` | nomes e descrições do cClassTrib (IBS/CBS) | 50,0 KB | 9,0 KB |
81+
| `getBanks` · `getBankByCode` · `getBankByIspb` | participantes do STR do Banco Central (COMPE + ISPB) | 37,5 - 37,8 KB | 9,0 - 9,2 KB |
82+
| `isValidCid10` | códigos das categorias e subcategorias da CID-10 V2008, sem as descrições | 26,2 KB | 6,8 KB |
83+
| `getServiceItem` | lista de serviços da Lei Complementar 116/2003 | 26,1 KB | 8,4 KB |
84+
| `isValidCbo` | códigos das ocupações da CBO 2002, sem os títulos | 16,2 KB | 5,5 KB |
85+
| `isValidCnae` | códigos da CNAE-Subclasses 2.3, sem as descrições | 9,6 KB | 3,4 KB |
86+
| `isValidNbs` | códigos da NBS 2.0, sem as descrições | 8,5 KB | 2,3 KB |
87+
| `isValidCest` | códigos do CEST, sem as descrições | 7,6 KB | 2,3 KB |
7188
| `getCid10` | categorias e subcategorias da CID-10 V2008, com as descrições do DATASUS | 1030,4 KB | 146,9 KB |
7289
| `getMunicipalities` · `getMunicipalityByCode` · `getMunicipality` | 5571 municípios do IBGE, com nomes e códigos | 154,9 - 156,5 KB | 50,3 - 50,4 KB |
7390
| `getCities` | nomes dos 5571 municípios do IBGE | 154,2 KB | 49,8 KB |

‎docs/pt-br/utilities.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ Retorna os nomes das cidades brasileiras: todas as cidades, ou só as de um esta
18171817
- Ordenadas no locale "pt-BR".
18181818
- Qualquer `state` falsy pede a lista completa, enquanto `getMunicipalities` retorna `[]`.
18191819
- `state` diferencia maiúsculas de minúsculas: `'sp'`, como um código desconhecido, retorna `[]`.
1820-
- Embute os 5571 nomes (~154,2 KB minificado, ~49,8 KB com gzip). Veja [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle) para carregá-la sob demanda via `@brazilian-utils/brazilian-utils/get-cities`.
1820+
- Embute os 5571 nomes (~153,4 KB minificado, ~49,2 KB com gzip). Veja [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle) para carregá-la sob demanda via `@brazilian-utils/brazilian-utils/get-cities`.
18211821
18221822
```javascript
18231823
import { getCities } from '@brazilian-utils/brazilian-utils';
@@ -3301,7 +3301,7 @@ Valida um código CID-10 contra as tabelas que o DATASUS publica, a edição bra
33013301
- Os dois níveis da classificação são válidos: as categorias de 3 caracteres (`A00`) e as subcategorias de 4 caracteres, escritas com o ponto (`A00.0`) ou sem ele (`A000`).
33023302
- Maiúsculas, minúsculas e espaços em volta são ignorados. Qualquer outra coisa (outro separador, um quinto caractere, um sufixo de cruz ou asterisco, um valor que não é string) é rejeitada.
33033303
- As tabelas V2008 do DATASUS são a única fonte, então um código que não está nelas não é encontrado; os códigos de COVID-19 que a OMS acrescentou depois de 2008 não são encontrados: `U07.1` (COVID-19, vírus identificado), `U07.2` (vírus não identificado), `U09.9` (condição pós-COVID-19) e `U10.9` (síndrome inflamatória multissistêmica associada à COVID-19).
3304-
- Só uma tabela de códigos é lida (cerca de 27 KB minificada), não as descrições que `getCid10` carrega.
3304+
- Só uma tabela de códigos é lida (cerca de 26 KB minificada), não as descrições que `getCid10` carrega.
33053305
33063306
```javascript
33073307
import { isValidCid10 } from '@brazilian-utils/brazilian-utils';
@@ -3351,7 +3351,7 @@ Busca um código CID-10 e retorna a sua descrição oficial em português. O res
33513351
33523352
- Mesmas regras de entrada de `isValidCid10`. O `code` vem em maiúsculas e sem o ponto. Retorna `null` quando o código é desconhecido ou o valor não está em uma forma documentada.
33533353
- Mesma tabela de `isValidCid10`, a V2008 do DATASUS: os códigos de COVID-19 que a OMS acrescentou depois de 2008 não são encontrados: `U07.1` (COVID-19, vírus identificado), `U07.2` (vírus não identificado), `U09.9` (condição pós-COVID-19) e `U10.9` (síndrome inflamatória multissistêmica associada à COVID-19).
3354-
- Este é o utilitário mais pesado do pacote: ele embute as 2045 categorias e 12188 subcategorias com suas descrições, cerca de 1 MB minificado (147 KB com gzip). Carregue-o sob demanda pelo seu subpath, como mostrado em [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle), e use `isValidCid10` quando a descrição não for necessária.
3354+
- Este é o utilitário mais pesado do pacote: ele embute as 2045 categorias e 12188 subcategorias com suas descrições, cerca de 990 KB minificado (124 KB com gzip). Carregue-o sob demanda pelo seu subpath, como mostrado em [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle), e use `isValidCid10` quando a descrição não for necessária.
33553355
33563356
```javascript
33573357
import { getCid10 } from '@brazilian-utils/brazilian-utils';

‎docs/utilities.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ Get the names of Brazilian cities: every city, or only those of one state. **Dep
18171817
- Sorted in the "pt-BR" locale.
18181818
- Any falsy `state` asks for the full list, where `getMunicipalities` returns `[]`.
18191819
- `state` is case-sensitive: `'sp'`, like an unknown code, returns `[]`.
1820-
- Embeds all 5571 names (~154.2 KB minified, ~49.8 KB gzipped). See [Bundle size](getting-started.md#bundle-size) to lazy-load it via `@brazilian-utils/brazilian-utils/get-cities`.
1820+
- Embeds all 5571 names (~153.4 KB minified, ~49.2 KB gzipped). See [Bundle size](getting-started.md#bundle-size) to lazy-load it via `@brazilian-utils/brazilian-utils/get-cities`.
18211821
18221822
```javascript
18231823
import { getCities } from '@brazilian-utils/brazilian-utils';
@@ -3301,7 +3301,7 @@ Check if a CID-10 code exists in the tables DATASUS publishes, the Brazilian Por
33013301
- Both levels of the classification are valid: the 3 character categories (`A00`) and the 4 character subcategories, written with the dot (`A00.0`) or without it (`A000`).
33023302
- Letter case and surrounding whitespace are ignored. Anything else (another separator, a fifth character, a dagger or asterisk suffix, a value that is not a string) is rejected.
33033303
- The DATASUS V2008 tables are the only source, so a code that is not in them is not found; the COVID-19 codes the WHO added after 2008 are not found: `U07.1` (COVID-19, virus identified), `U07.2` (virus not identified), `U09.9` (post COVID-19 condition) and `U10.9` (multisystem inflammatory syndrome associated with COVID-19).
3304-
- Only a table of codes is read (about 27 KB minified), not the descriptions `getCid10` carries.
3304+
- Only a table of codes is read (about 26 KB minified), not the descriptions `getCid10` carries.
33053305
33063306
```javascript
33073307
import { isValidCid10 } from '@brazilian-utils/brazilian-utils';
@@ -3351,7 +3351,7 @@ Look a CID-10 code up and get its official Brazilian Portuguese description. The
33513351
33523352
- Same input rules as `isValidCid10`. `code` is upper case and has no dot. Returns `null` when the code is unknown or the value is not in a documented form.
33533353
- Same table as `isValidCid10`, the DATASUS V2008 one: the COVID-19 codes the WHO added after 2008 are not found: `U07.1` (COVID-19, virus identified), `U07.2` (virus not identified), `U09.9` (post COVID-19 condition) and `U10.9` (multisystem inflammatory syndrome associated with COVID-19).
3354-
- This is the heaviest util of the package: it embeds the 2045 categories and 12188 subcategories with their descriptions, about 1 MB minified (147 KB gzipped). Load it lazily through its subpath, as shown in [Bundle size](getting-started.md#bundle-size), and use `isValidCid10` when the description is not needed.
3354+
- This is the heaviest util of the package: it embeds the 2045 categories and 12188 subcategories with their descriptions, about 990 KB minified (124 KB gzipped). Load it lazily through its subpath, as shown in [Bundle size](getting-started.md#bundle-size), and use `isValidCid10` when the description is not needed.
33553355
33563356
```javascript
33573357
import { getCid10 } from '@brazilian-utils/brazilian-utils';

0 commit comments

Comments
 (0)