1 | import { TransformOptions, ParserOptions } from '@babel/core';
|
2 | import { ResolvedConfig, PluginOption } from 'vite';
|
3 |
|
4 | interface Options {
|
5 | include?: string | RegExp | Array<string | RegExp>;
|
6 | exclude?: string | RegExp | Array<string | RegExp>;
|
7 | |
8 |
|
9 |
|
10 |
|
11 | fastRefresh?: boolean;
|
12 | |
13 |
|
14 |
|
15 |
|
16 | jsxRuntime?: 'classic' | 'automatic';
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 | jsxImportSource?: string;
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 | jsxPure?: boolean;
|
29 | |
30 |
|
31 |
|
32 | babel?: BabelOptions | ((id: string, options: {
|
33 | ssr?: boolean;
|
34 | }) => BabelOptions);
|
35 | }
|
36 | type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | interface ReactBabelOptions extends BabelOptions {
|
42 | plugins: Extract<BabelOptions['plugins'], any[]>;
|
43 | presets: Extract<BabelOptions['presets'], any[]>;
|
44 | overrides: Extract<BabelOptions['overrides'], any[]>;
|
45 | parserOpts: ParserOptions & {
|
46 | plugins: Extract<ParserOptions['plugins'], any[]>;
|
47 | };
|
48 | }
|
49 | type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
|
50 | type ReactBabelHookContext = {
|
51 | ssr: boolean;
|
52 | id: string;
|
53 | };
|
54 | declare module 'vite' {
|
55 | interface Plugin {
|
56 | api?: {
|
57 | |
58 |
|
59 |
|
60 | reactBabel?: ReactBabelHook;
|
61 | };
|
62 | }
|
63 | }
|
64 | declare function viteReact(opts?: Options): PluginOption[];
|
65 | declare namespace viteReact {
|
66 | var preambleCode: string;
|
67 | }
|
68 |
|
69 | export { BabelOptions, Options, ReactBabelOptions, viteReact as default };
|