Files
2026-10-17 12:09:36 -04:00

63 lines
2.3 KiB
TypeScript

import { Plugin } from "vite";
import { ReactCompilerBabelPluginOptions, ReactCompilerOptions, RolldownBabelPreset } from "#optionalTypes";
//#region src/reactCompilerPreset.d.ts
export declare const reactCompilerPreset: (options?: ReactCompilerBabelPluginOptions) => RolldownBabelPreset;
//#endregion
//#region src/index.d.ts
interface ReactCompilerPluginOptions extends ReactCompilerOptions {
/**
* Log recoverable React Compiler diagnostics through Vite.
* Fatal diagnostics are always logged and fail the transform.
* @default false
* @deprecated Use `reportDiagnostics` instead
*/
logDiagnostics?: boolean;
}
export interface Options {
/**
* Can be used to process extra files like `.mdx`
* @example include: /\.(mdx|js|jsx|ts|tsx)$/
* @default /\.[tj]sx?$/
*/
include?: string | RegExp | Array<string | RegExp>;
/**
* Can be used to exclude JSX/TSX files that runs in a worker or are not React files.
* Except if explicitly desired, you should keep node_modules in the exclude list
* @example exclude: [/\/pdf\//, /\.solid\.tsx$/, /\/node_modules\//]
* @default /\/node_modules\//
*/
exclude?: string | RegExp | Array<string | RegExp>;
/**
* Control where the JSX factory is imported from.
* https://oxc.rs/docs/guide/usage/transformer/jsx.html#import-source
* @default 'react'
*/
jsxImportSource?: string;
/**
* Note: Skipping React import with classic runtime is not supported from v4
* @default "automatic"
*/
jsxRuntime?: 'classic' | 'automatic';
/**
* React Fast Refresh runtime URL prefix.
* Useful in a module federation context to enable HMR by specifying
* the host application URL in the Vite config of a remote application.
* @example
* reactRefreshHost: 'http://localhost:3000'
*/
reactRefreshHost?: string;
/**
* Enable React Compiler with its default options or configure it.
* This requires `oxc-transform-react` to be installed.
* @default false
* @experimental
*/
compiler?: boolean | ReactCompilerPluginOptions;
}
declare function viteReact(opts?: Options): Plugin[];
declare namespace viteReact {
var preambleCode: string;
}
declare function viteReactForCjs(this: unknown, options: Options): Plugin[];
//#endregion
export { type ReactCompilerPluginOptions as ReactCompilerOptions, viteReact as default, viteReactForCjs as "module.exports" };