import MagicString from "magic-string"; import type { Plugin } from "vite"; export interface RebaseCollectionsPluginOptions { /** * The path to the collections directory containing the schema definitions. * Use a relative or absolute path from the root of your frontend workspace. */ collectionsDir: string; } /** * Perform the AST-based transform on `code`. * * Parses the source with the TypeScript compiler API, walks the tree for * `PropertyAssignment` nodes whose name matches one of `LAZY_COMPONENT_KEYS` * and whose initializer is a string literal starting with `./` or `../`. * * Each match is rewritten in-place via `magic-string` so that source-maps * remain correct. * * @returns `{ code, map }` if at least one replacement was made; `null` otherwise. */ export declare function transformCollectionSource(code: string, id: string): { code: string; map: ReturnType; } | null; /** * A Vite plugin that dynamically loads and automatically wires Rebase collections. * * It provides two capabilities: * 1. A **virtual module** `"virtual:rebase-collections"` that statically exports * the resolved collections array. * 2. A **transform hook** that converts string-based component references * (e.g. `Field: "../../components/MyField"`) into `LazyComponentRef` objects * (`{ __rebaseLazy: true, load: () => import(...) }`), enabling code-splitting * and preventing the backend from loading React-dependent modules. */ /** * Annotated `Plugin` rather than inferred. * * The return used to be a bare object literal, and TypeScript 6 stopped * accepting it where vite wants a `PluginOption`: `configureServer` is an * `ObjectHook`, so a plain method's inferred signature is not assignable, and * the whole config object then failed with "Excessive stack depth comparing * types" — an error naming the caller's `defineConfig` rather than the plugin * that caused it. A scaffolded frontend runs `vite build && tsc` with * `vite.config.ts` in its `include`, so that was a broken `pnpm build` for * every new project on TS 6, reported against a file the user did not write. * * Declaring the type puts the check here, where the hooks are, instead of at * every call site. */ export declare function rebaseCollectionsPlugin(options: RebaseCollectionsPluginOptions): Plugin; /** * How the admin's dependencies are split into cached chunks. * * This was sixty-five lines copied verbatim into every scaffold's * `vite.config.ts`, comments and all — which meant every project got a frozen * snapshot of a decision that keeps being revised. When we learned that naming * `lucide-react` welded 822 kB of icons into the preload set, the fix landed * in the template and in nothing already generated. * * A name here says these modules travel TOGETHER. It does not say they travel * late: a chunk becomes a static dependency of the entry — and so a * `modulepreload` in index.html — the moment any one module in it is * statically reachable. Naming a library that is only partly lazy therefore * drags the lazy part onto the critical path. Read the two exceptions below * before adding a line. * * @example * ```ts * build: { rollupOptions: { output: { manualChunks: rebaseManualChunks } } } * ``` */ export declare function rebaseManualChunks(id: string): string | undefined;