server.tsconfigPath
- Type:
string - Default:
<appDirectory>/tsconfig.json
Specifies the tsconfig file used by server-side TypeScript processes.
This option affects:
- BFF / API compilation (
@modern-js/plugin-bff) - Custom server compilation (
*.tsfiles underserver/) - Runtime ts-node registration, such as SSR,
modern.config.ts, and.tsfiles underconfig/
When this option is not set, <appDirectory>/tsconfig.json is used by default.
When to use
Use this option when frontend and server-side code need different TypeScript configurations.
For example, the frontend can use moduleResolution: "Bundler", while the server side uses moduleResolution: "NodeNext" for type resolution of conditional exports or subpath exports.
Example
The example below uses tsconfig.server.json as the file name. You can use another name in your project.
Add <appDirectory>/tsconfig.server.json:
tsconfig.server.json
Specify this file in modern.config.ts:
modern.config.ts
Notes
tsconfigPathis resolved relative toappDirectory. Absolute paths are also supported.- It is recommended to inherit shared options such as
pathsfrom the root tsconfig throughextends, instead of maintaining them in multiple files. - If the configured file does not exist, TypeScript / ts-node will throw an error at startup.