TypeScript
Every package in Refract is TypeScript-first. Each one has its owntsconfig.json tuned to what it needs to produce — a CommonJS library, an ES module bundle, or a browser SPA. Here’s a tour of what’s set up and why.
Backend (apps/backend/tsconfig.json)
The backend compiles to CommonJS for Node.js. It’s intentionally minimal — the goal is to get a clean dist/ for production, and the test suite is excluded from compilation entirely:
esModuleInterop: truelets you writeimport Stripe from 'stripe'instead ofimport * as Stripe from 'stripe'for CommonJS modules that don’t have a default export.resolveJsonModule: trueallows importing.jsonfiles directly — handy for things likejest.config.json.- Test files are excluded because
ts-jesthandles their compilation separately at test time.
Frontend (apps/frontend/tsconfig.app.json)
The frontend uses a split config: tsconfig.app.json for the application source and tsconfig.node.json for Vite’s config file. The top-level tsconfig.json just references both.
tsconfig.app.json is where the interesting settings live:
moduleResolution: "bundler"is the modern mode for Vite/esbuild — it understands bare specifiers and TypeScript extensions without the old Node resolution quirks.noEmit: truemeans TypeScript is purely a type-checker here. Vite handles the actual compilation.noUnusedLocalsandnoUnusedParametersare turned on — TypeScript will error if you declare a variable or parameter you never use. This catches a lot of accidental dead code.noUncheckedSideEffectImportsprevents imports that exist only for side effects without an explicit acknowledgement — helps keep the import graph intentional.
Shared (apps/shared/tsconfig.json)
The shared package outputs both declarations and source maps alongside CommonJS JS, because it’s consumed by both the backend and the tool packages:
declaration: true and declarationMap: true produce the .d.ts files that let the backend and tool packages get full type information when importing from apps/shared. If you add a new type or schema to shared, run make build on the shared package before the backend will pick it up.
Tool packages (apps/tools/<tool>/<impl>/tsconfig.json)
All tool packages (BullMQ, SQS, Pino, Console, StatsD, etc.) share the same config shape as apps/shared — CommonJS output with declarations and source maps:
Building
build-all command is what CI uses. Note that backend tests depend on the compiled dist/ of all tool packages — so if you’re running backend tests locally and something isn’t found, a make build-all will usually fix it.
💡 Tip: if you’re adding a new tool package, make sure to runmake pnpm-installafter adding it topnpm-workspace.yaml. Otherwise the workspace won’t know about it andmake build-allwon’t include it.