Entry points and bundle size
The data is bundled into the JavaScript, so what an app loads depends on what it imports. On a server that rarely matters. In a browser it does: the courts and the legal text of every canton are hundreds of kilobytes.
One entry point per dataset
Importing from belgica loads every dataset except the boundaries and the court locations. Each dataset also has its own entry point, and importing from it loads that dataset alone:
import { getInterestRate } from 'belgica/interest-rates'
import { nextWorkingDay } from 'belgica/calendar'
import { getCourt } from 'belgica/courts'
import { getCanton } from 'belgica/territory'
import { getMunicipalitiesForPostalCode } from 'belgica/postal-codes'The API reference lists every entry point and what it exports. The jurisdiction functions, such as findCourtsWithJurisdiction, need both the territory and the courts and are only in the root.
The canton boundaries, the arrondissement boundaries and the court locations are only in their own entry points (belgica/canton-boundaries, belgica/arrondissement-boundaries, belgica/court-locations). The root never loads them.
Measured sizes
The JavaScript each entry point loads, with the chunks it imports, measured from the build of this version:
| Entry point | JavaScript loaded | gzip |
|---|---|---|
belgica | 1031 KB | 110 KB |
belgica/territory | 251 KB | 33 KB |
belgica/canton-boundaries | 254 KB | 34 KB |
belgica/arrondissement-boundaries | 254 KB | 34 KB |
belgica/courts | 587 KB | 55 KB |
belgica/court-locations | 80 KB | 10 KB |
belgica/courts/format | 1 KB | 1 KB |
belgica/courts/load | 16 KB | 2 KB |
belgica/cantons | 67 KB | 8 KB |
belgica/cantons/territory | 78 KB | 17 KB |
belgica/prisons | 62 KB | 7 KB |
belgica/houses-of-justice | 27 KB | 4 KB |
belgica/interest-rates | 13 KB | 3 KB |
belgica/calendar | 8 KB | 3 KB |
belgica/postal-codes | 169 KB | 19 KB |
The two boundary entry points read their geometry from data/ with a JSON import, so the sizes above leave it out: the canton boundaries are 23 MB of JSON and the arrondissement boundaries 8 MB.
Smaller still: only the courts you need
JSON can't be tree-shaken, so an app that imports belgica/courts ships every court. A browser app that needs only some courts can import smaller files, or load them when they're needed:
| You need | Use |
|---|---|
| Every court, with lookups and filters | belgica/courts |
| One type, all of Belgium | belgica/data/courts/<type>.json, or loadCourts({ type }) |
| One type in one arrondissement | belgica/data/courts/<type>/<arrondissement>.json, or loadCourts({ type, arrondissement }) |
| One court by a stored id | loadCourt(id) |
| One court's contacts, hours and website | belgica/data/courts/details/<id>.json, or loadCourtDetails(id) |
| Names and contacts of a court you already hold | belgica/courts/format, which loads no data |
| Cantons without the legal text of their area | belgica/cantons, and belgica/cantons/territory for the text |
The loaders are in belgica/courts/load. Only the courts you need describes the files and gives an example.
The raw files
Every data file is exported as well, for a JSON import or a bundler:
import courts from 'belgica/data/courts.json' with { type: 'json' }Their paths are public API, like the ids: they don't change within a major version. See without JavaScript for the list.