Example validation workflows
Example validation workflows let engineers build the example suite in two modes and check that its TypeScript code still matches the library API. The workflows use each example's own package scripts while the repository-level scripts decide which examples to include and which library source or package surface to use. For the wider role of the examples, see Examples and framework integrations.
Example build modes
Local example builds
Local builds let an engineer run an example against the library source in the repository. The shared Vite setup also supplies the local API key to the example and maps the library imports to src, so changes can be checked before a package build exists. Only example packages that declare both build-local and the shared local Vite config are selected. The extended component library, map-3d, and Terra Draw examples meet this contract. The Next.js example does not, so the local selector skips it. scripts/build-examples-local.sh also skips _template and packages that do not meet those conditions. The root build:examples:local command first expects the example installation step and then runs this selection.
References: scripts/build-examples-local.sh• L5-35 examples/vite.config.local.mjs• L4-29 examples/…/package.json• L11-15 examples/…/package.json• L14-18 examples/…/package.json• L12-16 examples/…/package.json• L3-9 package.json• L49-50
Distribution example builds
Distribution builds check the normal build path for each example. scripts/build-examples.sh visits every example directory except _template and runs its build script. Each example therefore produces its build through the package and tool settings that it will use outside the local source-alias setup.
References: scripts/build-examples.sh• L3-20 examples/…/package.json• L10-15 examples/…/package.json• L16-21 examples/…/package.json• L11-16 examples/…/package.json• L14-18 examples/…/package.json• L3-9 examples/…/package.json• L12-16
Example type validation
TypeScript example checks
TypeScript example checks verify the example suite without writing output files. scripts/typecheck-examples.sh finds each example with a tsconfig.json and invokes the repository TypeScript compiler with that project. The shared example configuration extends the repository configuration and maps @vis.gl/react-google-maps imports to the local source, which makes the check sensitive to changes in the library API used by examples. For the package surface that consumers type against, see Package exports and types. The root test:tsc:examples command exposes this workflow.
References: scripts/typecheck-examples.sh• L5-22 examples/tsconfig.base.json• L1-17 tsconfig.json• L1-22 package.json• L53-57
Example package contracts
An example participates in these workflows through a small package contract. Its package must provide the script used by the selected workflow, and its TypeScript project must describe the files and library imports that the compiler should check. The extended component library, map-3d, and Terra Draw packages provide the local and distribution build scripts needed for both build modes. The Next.js package provides the standard distribution build but not the local build contract. The worker clustering example shows that a package can add its own test command without changing the repository-wide build or typecheck selection.
| Workflow | Example contract | Result |
|---|---|---|
| Local build | build-local and vite.config.local.mjs reference | Build against repository source and local Vite settings |
| Distribution build | build script | Build through the example's standard package setup |
| Type check | tsconfig.json | Run tsc --noEmit for that example |
References: scripts/build-examples-local.sh• L17-35 scripts/build-examples.sh• L11-20 scripts/typecheck-examples.sh• L14-21 examples/…/package.json• L11-16 examples/…/package.json• L14-18 examples/…/package.json• L3-9 examples/…/package.json• L12-16 examples/…/package.json• L16-22
Validation flow
The build and typecheck workflows use different gates because a successful bundle does not prove that the example's types match the current library API. This diagram shows how repository commands select example projects and produce either built assets or compiler feedback.
flowchart TD
A[Repository command] --> B{Validation mode}
B -->|Local build| C[Select local-build packages]
C --> D[Use shared Vite local config]
D --> E[Build against source aliases]
B -->|Distribution build| F[Visit example packages]
F --> G[Run each build script]
G --> H[Build distribution examples]
B -->|Type check| I[Select packages with tsconfig.json]
I --> J[Run repository tsc with no emit]
J --> K[Report API and example type errors]
References: scripts/build-examples-local.sh• L8-35 scripts/build-examples.sh• L5-20 scripts/typecheck-examples.sh• L9-22 package.json• L47-57
Change checklist
When these files or sections are changed, remember to consider these:
- When an example package changes its build script or local config reference, check whether the local selector still includes it.
- When library exports or source paths change, check the aliases in examples/tsconfig.base.json and examples/vite.config.local.mjs together.
- When an example is added or renamed, check that its package has the scripts and tsconfig.json needed by the intended repository workflow.
- When the root script names change, update the commands that expose local builds and example type checks.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
scripts/install-examples.sh is missing while build:examples:local is used | The root local-build command stops before it reaches the local build selector | Restore or replace the installation step before relying on the root command |
An example omits build-local or the shared local Vite reference | The local selector silently skips that example | Keep the package script and config reference together |
| An example has no tsconfig.json | The example is omitted from repository type validation | Add a project config when the example must be covered |
| A library import path changes without a matching local alias change | Local builds or type checks can resolve a package instead of the intended source, or fail to resolve it | Update the Vite and TypeScript aliases as one contract |
Key files
| File | Why to read it |
|---|---|
| package.json | Defines the repository commands for example builds and type checks. |
| scripts/build-examples-local.sh | Shows how local-build packages are selected. |
| scripts/build-examples.sh | Shows how standard example builds are distributed across packages. |
| scripts/typecheck-examples.sh | Shows how TypeScript projects enter the example validation pass. |
| examples/vite.config.local.mjs | Defines the source-alias and local runtime context for local builds. |
| examples/tsconfig.base.json | Defines the shared TypeScript view of the library API for examples. |
| examples/…/package.json | Shows an example package that supports both local and distribution builds. |
| examples/…/package.json | Shows an example package that supports both local and distribution builds. |
| examples/…/package.json | Shows an example package that supports the distribution build path. |
| examples/…/package.json | Shows an example package that supports both local and distribution builds. |