Every package in this monorepo ships the following exports block in its package.json:
"exports": {
"import": {
"@solid-primitives/source": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}By default, Node.js and TypeScript only recognise a fixed set of export conditions (import, require, browser, types, etc.). A custom condition is an arbitrary string that tools opt in to — it is silently ignored by anything that doesn't explicitly request it.
We use @solid-primitives/source to expose the raw TypeScript source file (./src/index.ts) alongside the compiled artefacts. When this condition is active, the resolver returns the .ts file instead of the .js/.d.ts pair, so cross-package imports inside the repo work without a build step: edit a file in packages/utils, and every other package that imports it sees the change instantly.
The technique is explained in detail in Colin McDonnell's article Live types in a TypeScript monorepo.
The root tsconfig.json sets:
"customConditions": ["@solid-primitives/source"]This tells the TypeScript language server and tsc to prefer .ts source when resolving workspace package imports — so IDE go-to-definition and type checking always reflect the live source, not a stale build.
The shared Vitest config passes the condition to Vite's resolver:
conditions: ["@solid-primitives/source", "browser", "development"]
// or for SSR:
conditions: ["@solid-primitives/source", "node"]This means tests import raw TypeScript directly and never need the dist/ folder to be current.
Any tool that adds @solid-primitives/source to its resolution conditions (e.g. a Vite-based playground) will likewise bypass the build output and work from source.
Consumers who install a package from npm — or who do not activate the custom condition — land on the normal compiled path:
types → ./dist/index.d.ts
default → ./dist/index.js
The src/ files are included in the published package anyway (they serve as source maps), but external tooling never resolves to them unless it explicitly opts in.
Copy the exports block above into the new package's package.json. No other changes are needed — the root tsconfig.json and shared Vitest config already activate the condition repo-wide.