diff --git a/.changeset/export-setup-ts-runtime.md b/.changeset/export-setup-ts-runtime.md new file mode 100644 index 000000000000..4ea16bb68021 --- /dev/null +++ b/.changeset/export-setup-ts-runtime.md @@ -0,0 +1,13 @@ +--- +'@modern-js/app-tools': patch +--- + +feat(app-tools): export `setupTsRuntime` and `resolveTsRuntimeRegisterMode` from the public entry + +The server TypeScript runtime setup app-tools' own dev/build commands use +(ts-node when the project depends on it, Node.js native TypeScript as the +fallback, plus tsconfig-paths/alias registration) is now part of the public +API, so frameworks composing app-tools in-process (running their own command +actions instead of app-tools') can register the same runtime without keeping +a private copy of the logic. Also exports the `TsRuntimeRegisterMode` and +`TsRuntimeSetupOptions` types. diff --git a/packages/solutions/app-tools/src/index.ts b/packages/solutions/app-tools/src/index.ts index dc4fd16a77a8..559cd8db976c 100644 --- a/packages/solutions/app-tools/src/index.ts +++ b/packages/solutions/app-tools/src/index.ts @@ -172,6 +172,12 @@ export { dev } from './commands/dev'; export { serve } from './commands/serve'; export type { DevOptions } from './utils/types'; export { generateWatchFiles } from './utils/generateWatchFiles'; +export { + resolveTsRuntimeRegisterMode, + setupTsRuntime, + type TsRuntimeRegisterMode, + type TsRuntimeSetupOptions, +} from './utils/register'; export { resolveModernRsbuildConfig, type ResolveModernRsbuildConfigOptions, diff --git a/packages/solutions/app-tools/src/utils/register.ts b/packages/solutions/app-tools/src/utils/register.ts index 40c8402d7433..10bbcd969906 100644 --- a/packages/solutions/app-tools/src/utils/register.ts +++ b/packages/solutions/app-tools/src/utils/register.ts @@ -11,9 +11,9 @@ import { } from '@modern-js/utils'; import type { ConfigChain } from '@rsbuild/core'; -type TsRuntimeRegisterMode = 'ts-node' | 'node-loader' | 'unsupported'; +export type TsRuntimeRegisterMode = 'ts-node' | 'node-loader' | 'unsupported'; -interface TsRuntimeSetupOptions { +export interface TsRuntimeSetupOptions { moduleType?: string; /** * User-configured `server.tsconfigPath`. Forwarded into the shared