TypeScript Configuration
Modern.js ships shared TypeScript presets in @modern-js/tsconfig. A project usually needs just two files: the main tsconfig.json, and a tsconfig.server.json only when it has server-side code.
Presets
Two-file layout
tsconfig.json is the single main config, and every path alias (paths) lives here:
isolatedModules, moduleDetection: force and noEmitOnError are set in the project file rather than in base, so upgrading @modern-js/tsconfig does not add these checks to an existing project. With noEmitOnError: true, a type error in api/ fails modern build; without it, BFF type errors are only reported. New projects get them from the template; add them to an existing tsconfig.json when you are ready to fix what they report.
When the project has a BFF (api/) or a custom server (server/), add "@api/*": ["./api/lambda/*"] to paths, add api and server to include, and create:
The framework uses this file to compile api/, server/ and shared/ (with the project's own tsc command) and to run server source at dev time. The four compilerOptions override only their own keys; everything else, including paths, is inherited from tsconfig.json. They are the same fields as @modern-js/tsconfig/server, inlined so tools still on ts-node 10 (which does not support extends arrays) can read the file.
Why two files
Bundlers expect module: ESNext, while the type check of server code should resolve modules the way Node does (NodeNext). No single module value satisfies both, so the server side overrides the module options separately. The output format is decided by the framework from package.json#type, independently of these two fields.
Without tsconfig.server.json
The server config is resolved as server.tsconfigPath → tsconfig.server.json → tsconfig.json. When tsconfig.server.json is picked up by convention, a one-line message shows which file is used. When it falls back to tsconfig.json, the output still follows package.json#type (a CommonJS project still gets require) and nothing is reported; only when its module is an ES module value and the project is not type: module is the server code compiled with module: CommonJS, as with the previous base preset. type: module projects are never rewritten. See server.tsconfigPath for the full rule.
Migrating an existing project
The previous create template wrote "baseUrl": "./" into tsconfig.json. TypeScript 6 reports TS5101 for baseUrl (deprecated) and TypeScript 7 reports TS5102 (removed). Projects that upgrade Modern.js but stay on TypeScript 5.x are not affected, and the framework build keeps honoring baseUrl.
Upgrading dependencies never rewrites project files. To migrate, run the modernjs-migrate-tsconfig Skill:
Results go to changed (applied) and manual (left to you) in <projectDir>/.agents/runs/modernjs-migrate-tsconfig/report.json. The script is safe to run again.
The rewrite is equivalent to baseUrl. For example, with baseUrl: "./src" and a source file importing utils/log (resolved to src/utils/log.ts):
Without such bare imports no "*" mapping is added. Without the Skill, apply the table above by hand.
Notes
- Never declare
pathsintsconfig.server.json: TypeScript replacespathswholesale instead of merging it key by key. baseUrlis no longer needed. Relative entries inpathsare resolved against the directory of the file that declares them.- If a project keeps
baseUrlon TypeScript 6, the server type check ignores TS5101 and the other deprecations and does not fail because of them; other type errors still fail the build. - The server compile does not rely on the TypeScript JS API, so BFF and custom servers keep working on TypeScript 7; ts-node is no longer needed.
- Keep
@modern-js/tsconfigand@modern-js/app-toolson the same version: the framework has to know how to compileapi/,server/andshared/from a bundler-modetsconfig.json.