From 02bbe27709702e18583ac3be8efed7c6138e7752 Mon Sep 17 00:00:00 2001 From: cut0 Date: Tue, 14 Oct 2025 04:53:54 +0900 Subject: [PATCH] feat: add jsx compiler options --- mod.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mod.ts b/mod.ts index 29fc8e0..06d8f34 100644 --- a/mod.ts +++ b/mod.ts @@ -182,6 +182,22 @@ export interface BuildOptions { */ experimentalDecorators?: boolean; useUnknownInCatchVariables?: boolean; + + /** + * Controls how JSX constructs are emitted in JavaScript files. + * + * See more: https://www.typescriptlang.org/tsconfig/#jsx + * @default ts.JsxEmit.React + */ + jsx: ts.JsxEmit; + /** + * @default "React.createElement" + */ + jsxFactory: string; + /** + * @default "React.Fragment" + */ + jsxFragmentFactory: string; }; /** Filter out diagnostics that you want to ignore during type checking and emitting. * @returns `true` to surface the diagnostic or `false` to ignore it. @@ -293,9 +309,10 @@ export async function build(options: BuildOptions): Promise { false, emitDecoratorMetadata: options.compilerOptions?.emitDecoratorMetadata ?? false, - jsx: ts.JsxEmit.React, - jsxFactory: "React.createElement", - jsxFragmentFactory: "React.Fragment", + jsx: options.compilerOptions?.jsx ?? ts.JsxEmit.React, + jsxFactory: options.compilerOptions?.jsxFactory ?? "React.createElement", + jsxFragmentFactory: options.compilerOptions?.jsxFragmentFactory ?? + "React.Fragment", importsNotUsedAsValues: ts.ImportsNotUsedAsValues.Remove, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler,