-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathindex.d.ts
More file actions
68 lines (64 loc) · 2.39 KB
/
index.d.ts
File metadata and controls
68 lines (64 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
declare global {
interface ImportMeta {
readonly viteRsc: {
loadCss: (importer?: string) => import('react').ReactNode
loadModule: <T>(environmentName: string, entryName?: string) => Promise<T>
loadBootstrapScriptContent: (entryName: string) => Promise<string>
/**
* Import a module from another environment using a module specifier.
*
* A more ergonomic alternative to `loadModule` that takes a relative path
* instead of an entry name, so the specifier matches what you'd use in
* `typeof import(...)` type annotations.
*
* @example
* ```ts
* const ssr = await import.meta.viteRsc.import<typeof import('./entry.ssr')>(
* './entry.ssr',
* { environment: 'ssr' }
* );
* ```
*
* @param specifier - Relative path to the module (e.g., './entry.ssr')
* @param options - Options object with `environment` specifying the target environment
* @returns Promise resolving to the module exports
*/
import: <T>(
specifier: string,
options: { environment: string },
) => Promise<T>
/**
* Import a client asset from a server environment (SSR/RSC) and get its URL.
*
* This is useful for loading client-side scripts and obtaining their URLs
* for bootstrap scripts or other dynamic imports.
*
* @example
* ```ts
* const asset = await import.meta.viteRsc.importAsset('./entry.browser.tsx', { entry: true });
* const bootstrapScriptContent = `import(${JSON.stringify(asset.url)})`;
* ```
*
* @param specifier - Relative path to the client asset (e.g., './entry.browser.tsx')
* @param options - Options object
* @param options.entry - When true, marks this asset as an entry point for client deps merging.
* This replaces the "index" entry convention when using customClientEntry.
* @returns Promise resolving to an object containing the asset URL
*/
importAsset: (
specifier: string,
options?: { entry?: boolean },
) => Promise<{ url: string }>
}
}
interface ImportMetaEnv {
readonly __vite_rsc_build__: boolean
}
}
declare module 'vite' {
interface UserConfig {
/** Options for `@vitejs/plugin-rsc` */
rsc?: import('@vitejs/plugin-rsc').RscPluginOptions
}
}
export {}