Introduction
Packages organization and scope
bonFHIR is composed of a series of packages. Some have dependencies with one another.
The idea is that you can only pull in what you need in your implementation.
Some packages are client-side only, some are server-side only, and some are both:
-
Client and Server; these can be leveraged in all parts of the stack:
@bonfhir/core
@bonfhir/us-core
@bonfhir/next
-
Client - they are reserved to client application:
@bonfhir/query
@bonfhir/react
@bonfhir/mantine
@bonfhir/gluestack-ui
-
Server:
-
Utilities - not meant for inclusion in a project:
@bonfhir/cli
create-bonfhir
(subset of@bonfhir/cli
)@bonfhir/codegen
Package formats
Most of the packages actually includes 4 versions:
The application bundler determines whether to use the CommonJS or ESM version, using Conditional exports.
The import path in the typescript files determines whether to use the R4B or R5:
import { ... } from "@bonfhir/core/r4b";
import { ... } from "@bonfhir/core/r5";
The functionality should be mostly equivalent between FHIR versions - only the type definitions change.
Also - take note that bonFHIR only supports Node v18+ - the FHIR Client in particular relies on the availability of the fetch API in the environment.
Typescript configuration
In order for typescript to work properly, some configuration is required.
Here are the recommended settings to have in your tsconfig.json
:
{
"module": "ES2022",
"moduleResolution": "Bundler",
"target": "ES2022"
}
The most important one here is the moduleResolution
field:
it needs to be either 'node16', 'nodenext' or 'bundler' in order to properly support Conditional exports.
The "bundler" setting needs to work in conjunction with an external bundler (which means that typescript is only used for type checking, not bundling the application).
We recommend that you use our project templates to get started with the correct settings.
To use them, simply run npm create bonfhir
on your command-line.