Skip to content

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:

ts
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 pointJavaScript loadedgzip
belgica1031 KB110 KB
belgica/territory251 KB33 KB
belgica/canton-boundaries254 KB34 KB
belgica/arrondissement-boundaries254 KB34 KB
belgica/courts587 KB55 KB
belgica/court-locations80 KB10 KB
belgica/courts/format1 KB1 KB
belgica/courts/load16 KB2 KB
belgica/cantons67 KB8 KB
belgica/cantons/territory78 KB17 KB
belgica/prisons62 KB7 KB
belgica/houses-of-justice27 KB4 KB
belgica/interest-rates13 KB3 KB
belgica/calendar8 KB3 KB
belgica/postal-codes169 KB19 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 needUse
Every court, with lookups and filtersbelgica/courts
One type, all of Belgiumbelgica/data/courts/<type>.json, or loadCourts({ type })
One type in one arrondissementbelgica/data/courts/<type>/<arrondissement>.json, or loadCourts({ type, arrondissement })
One court by a stored idloadCourt(id)
One court's contacts, hours and websitebelgica/data/courts/details/<id>.json, or loadCourtDetails(id)
Names and contacts of a court you already holdbelgica/courts/format, which loads no data
Cantons without the legal text of their areabelgica/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:

ts
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.

Code under MIT, data under CC BY 4.0. Reference data, not legal advice: check the official sources.