import { Loader, BuildOptions } from 'esbuild'; import { TransformOptions } from '@babel/core'; import { HtmlTagDescriptor } from 'vite'; interface ESBuildPluginBabelOptions { config?: TransformOptions; filter?: RegExp; namespace?: string; loader?: Loader | ((path: string) => Loader); polyfill?: boolean; } interface VitePublicTypescriptOptions { /** * @description dir of input typescript files * @default 'public-typescript' * * @note relative to vite root */ inputDir?: string; /** * @description dir of public files * @see https://vitejs.dev/config/shared-options.html#publicdir * * @note usually for non-vite projects */ publicDir?: string; /** * @description dir of output javascript files after building, relative to publicDir */ outputDir?: string; /** * @description esbuild BuildOptions * @see https://esbuild.github.io/api/#general-options */ esbuildOptions?: BuildOptions | undefined; /** * @description use babel to transform * @default true */ babel?: boolean | ESBuildPluginBabelOptions; /** * @description manifest filename * @default 'manifest' */ manifestName?: string; /** * @description * whether generate js with hash, * if number, set hash length * * @default true */ hash?: boolean | number; /** * @description build-out destination * @default 'memory' * * @note usually set to 'file' in non-vite projects */ destination?: 'memory' | 'file'; /** * @description manifest cache dir * @default 'node_modules/.vite-plugin-public-typescript' * * @note relative to vite root */ cacheDir?: string; /** * @description base path for all files * @see https://vitejs.dev/config/shared-options.html#base * * @note relative to vite root * @note usually for non-vite projects */ base?: string; } declare function getManifestInNode(root?: string): Record; type ScriptDescriptor = Omit[]; type ManifestScriptsFn = (manifest: Record) => ScriptDescriptor; declare function injectScriptsToHtml(html: string, scripts: ManifestScriptsFn): string; declare function injectScripts(scripts: ManifestScriptsFn): any; declare function publicTypescript(options?: VitePublicTypescriptOptions): any; export { type ManifestScriptsFn, type ScriptDescriptor, type VitePublicTypescriptOptions, publicTypescript as default, getManifestInNode, injectScripts, injectScriptsToHtml, publicTypescript };