Appearance
marmotte / vite/dts
vite/dts
Interfaces
PluginOptions
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:43
Properties
afterBuild()?
optionalafterBuild: (emittedFiles) =>MaybePromise<void>
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:237
Hook called after all declaration files are written.
It will be received a map (path -> content) that records those emitted files.
Parameters
emittedFiles
Map<string, string>
Returns
MaybePromise<void>
Default
ts
() => {}afterDiagnostic()?
optionalafterDiagnostic: (diagnostics) =>MaybePromise<void>
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:210
Hook called after diagnostic is emitted.
According to the diagnostics.length, you can judge whether there is any type error.
Parameters
diagnostics
readonly Diagnostic[]
Returns
MaybePromise<void>
Default
ts
() => {}afterRollup()?
optionalafterRollup: (result) =>MaybePromise<void>
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:229
Hook called after rolling up declaration files.
Parameters
result
ExtractorResult
Returns
MaybePromise<void>
Default
ts
() => {}aliasesExclude?
optionalaliasesExclude: (string|RegExp)[]
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:108
Set which paths should be excluded when transforming aliases.
Default
ts
[]beforeWriteFile()?
optionalbeforeWriteFile: (filePath,content) =>MaybePromise<false|void| {content?:string;filePath?:string; }>
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:220
Hook called prior to writing each declaration file.
This allows you to transform the path or content.
The file will be skipped when the return value false or Promise<false>.
Parameters
filePath
string
content
string
Returns
MaybePromise<false | void | { content?: string; filePath?: string; }>
Default
ts
() => {}bundledPackages?
optionalbundledPackages:string[]
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:167
Bundled packages for @microsoft/api-extractor.
Default
ts
[]See
https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
cleanVueFileName?
optionalcleanVueFileName:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:116
Whether to transform file names ending in '.vue.d.ts' to '.d.ts'.
If there is a duplicate name after transform, it will fall back to the original name.
Default
ts
falseclearPureImport?
optionalclearPureImport:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:142
Whether to remove import 'xxx'.
Default
ts
truecompilerOptions?
optionalcompilerOptions:CompilerOptions|null
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:79
Override compilerOptions.
Default
ts
nullcopyDtsFiles?
optionalcopyDtsFiles:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:188
Whether to copy .d.ts source files to outDir.
Default
ts
falseRemarks
Before 2.0, the default was true.
declarationOnly?
optionaldeclarationOnly:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:196
Whether to emit declaration files only.
When true, all the original outputs of vite (rollup) will be force removed.
Default
ts
falseentryRoot?
optionalentryRoot:string
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:65
Override root path of entry files (useful in monorepos).
The output path of each file will be calculated based on the value provided.
The default is the smallest public path for all source files.
exclude?
optionalexclude:string|string[]
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:136
Override exclude glob.
Defaults to exclude property of tsconfig.json or 'node_modules/**' if not supplied.
include?
optionalinclude:string|string[]
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:130
Override include glob (relative to root).
Defaults to include property of tsconfig.json (relative to tsconfig.json located).
insertTypesEntry?
optionalinsertTypesEntry:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:152
Whether to generate types entry file(s).
When true, uses package.json types property if it exists or ${outDir}/index.d.ts.
Value is forced to true when rollupTypes is true.
Default
ts
falselogLevel?
optionallogLevel:LogLevel
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:202
Logging level for this plugin.
Defaults to the 'logLevel' property of your Vite config.
outDir?
optionaloutDir:string|string[]
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:57
Output directory for declaration files.
Can be an array to output to multiple directories.
Defaults to 'build.outDir' of the Vite config, or outDir of tsconfig.json if using Rollup.
pathsToAliases?
optionalpathsToAliases:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:102
Parsing paths of tsconfig.json to aliases.
Note that these aliases only use for declaration files.
Default
ts
trueRemarks
Only use first replacement of each path.
resolvers?
optionalresolvers:Resolver[]
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:93
Specify custom resolvers.
Default
ts
[]rollupConfig?
optionalrollupConfig:RollupConfig
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:174
Override the config of @microsoft/api-extractor.
Default
ts
nullSee
https://api-extractor.com/pages/setup/configure_api_report/
rollupOptions?
optionalrollupOptions:IExtractorInvokeOptions
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:181
Override the invoke options of @microsoft/api-extractor.
Default
ts
nullSee
https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
rollupTypes?
optionalrollupTypes:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:160
Rollup type declaration files after emitting them.
Powered by @microsoft/api-extractor - time-intensive operation.
Default
ts
falseroot?
optionalroot:string
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:49
Specify root directory.
Defaults to the 'root' of the Vite config, or process.cwd() if using Rollup.
staticImport?
optionalstaticImport:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:124
Whether to transform dynamic imports to static (eg import('vue').DefineComponent to import { DefineComponent } from 'vue').
Value is forced to true when rollupTypes is true.
Default
ts
falsestrictOutput?
optionalstrictOutput:boolean
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:73
Restrict declaration files output to outDir.
If true, generated declaration files outside outDir will be ignored.
Default
ts
truetsconfigPath?
optionaltsconfigPath:string
Defined in: node_modules/vite-plugin-dts/dist/index.d.ts:87
Specify tsconfig.json path.
Plugin resolves include and exclude globs from tsconfig.json.
If not specified, plugin will find config file from root.
Functions
default()
default(
options?):object
Defined in: src/vite/dts.ts:14
A wrapper around vite-plugin-dts that also exposes the options so that other plugins can use the same TS config without having to copy paste settings
Parameters
options?
PluginOptions = {}
Returns
api
api:
object
api.options
options:
PluginOptions
apply?
optionalapply:"serve"|"build"| (this,config,env) =>boolean
Apply the plugin only for serve or build, or on certain conditions.
applyToEnvironment()?
optionalapplyToEnvironment: (environment) =>true|PluginOption|Promise<boolean>
Experimental
Define environments where this plugin should be active By default, the plugin is active in all environments
Parameters
environment
PartialEnvironment
Returns
true | PluginOption | Promise<boolean>
augmentChunkHash?
optionalaugmentChunkHash:ObjectHook<(this,chunk) =>string|void, { }>
banner?
optionalbanner:ObjectHook<AddonHook, { }>
buildApp?
optionalbuildApp:ObjectHook<BuildAppHook>
Experimental
Build Environments
buildEnd?
optionalbuildEnd:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
buildStart?
optionalbuildStart:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
cacheKey?
optionalcacheKey:string
closeBundle?
optionalcloseBundle:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
closeWatcher?
optionalcloseWatcher:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
config?
optionalconfig:ObjectHook<(this,config,env) =>void|Omit<UserConfig,"plugins"> |Promise<void|Omit<UserConfig,"plugins"> |null> |null>
Modify vite config before it's resolved. The hook can either mutate the passed-in config directly, or return a partial config object that will be deeply merged into existing config.
Note: User plugins are resolved before running this hook so injecting other plugins inside the config hook will have no effect.
configEnvironment?
optionalconfigEnvironment:ObjectHook<(this,name,config,env) =>void|EnvironmentOptions|Promise<void|EnvironmentOptions|null> |null>
Modify environment configs before it's resolved. The hook can either mutate the passed-in environment config directly, or return a partial config object that will be deeply merged into existing config. This hook is called for each environment with a partially resolved environment config that already accounts for the default environment config values set at the root level. If plugins need to modify the config of a given environment, they should do it in this hook instead of the config hook. Leaving the config hook only for modifying the root default environment config.
configResolved?
optionalconfigResolved:ObjectHook<(this,config) =>void|Promise<void>>
Use this hook to read and store the final resolved vite config.
configurePreviewServer?
optionalconfigurePreviewServer:ObjectHook<PreviewServerHook>
Configure the preview server. The hook receives the PreviewServer instance. This can also be used to store a reference to the server for use in other hooks.
The hooks are called before other middlewares are applied. A hook can return a post hook that will be called after other middlewares are applied. Hooks can be async functions and will be called in series.
configureServer?
optionalconfigureServer:ObjectHook<ServerHook>
Configure the vite server. The hook receives the ViteDevServer instance. This can also be used to store a reference to the server for use in other hooks.
The hooks will be called before internal middlewares are applied. A hook can return a post hook that will be called after internal middlewares are applied. Hook can be async functions and will be called in series.
enforce?
optionalenforce:"pre"|"post"
Enforce plugin invocation tier similar to webpack loaders. Hooks ordering is still subject to the order property in the hook object.
Plugin invocation order:
- alias resolution
enforce: 'pre'plugins- vite core plugins
- normal plugins
- vite build plugins
enforce: 'post'plugins- vite build post plugins
footer?
optionalfooter:ObjectHook<AddonHook, { }>
generateBundle?
optionalgenerateBundle:ObjectHook<(this, ...parameters) =>void|Promise<void>, { }>
handleHotUpdate?
optionalhandleHotUpdate:ObjectHook<(this,ctx) =>void|ModuleNode[] |Promise<void|ModuleNode[]>>
Perform custom handling of HMR updates. The handler receives a context containing changed filename, timestamp, a list of modules affected by the file change, and the dev server instance.
The hook can return a filtered list of modules to narrow down the update. e.g. for a Vue SFC, we can narrow down the part to update by comparing the descriptors.
The hook can also return an empty array and then perform custom updates by sending a custom hmr payload via server.ws.send().
If the hook doesn't return a value, the hmr update will be performed as normal.
hotUpdate?
optionalhotUpdate:ObjectHook<(this,options) =>void|EnvironmentModuleNode[] |Promise<void|EnvironmentModuleNode[]>>
Perform custom handling of HMR updates. The handler receives an options containing changed filename, timestamp, a list of modules affected by the file change, and the dev server instance.
The hook can return a filtered list of modules to narrow down the update. e.g. for a Vue SFC, we can narrow down the part to update by comparing the descriptors.
The hook can also return an empty array and then perform custom updates by sending a custom hmr payload via environment.hot.send().
If the hook doesn't return a value, the hmr update will be performed as normal.
intro?
optionalintro:ObjectHook<AddonHook, { }>
load?
optionalload:ObjectHook<(this,id,options?) => LoadResult | Promise<LoadResult>, {filter?: {id?: StringFilter<string | RegExp> | undefined; }; }>
moduleParsed?
optionalmoduleParsed:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
name
name:
string=PLUGIN_NAME
onLog?
optionalonLog:ObjectHook<(this,level,log) => boolean | NullValue, { }>
options?
optionaloptions:ObjectHook<(this, ...parameters) => NullValue | InputOptions | Promise<NullValue | InputOptions>, { }>
outputOptions?
optionaloutputOptions:ObjectHook<(this,options) => NullValue | OutputOptions, { }>
outro?
optionaloutro:ObjectHook<AddonHook, { }>
perEnvironmentStartEndDuringDev?
optionalperEnvironmentStartEndDuringDev:boolean
Experimental
Opt-in this plugin into per-environment buildStart and buildEnd during dev. For backward-compatibility, the buildStart hook is called only once during dev, for the client environment. Plugins can opt-in to be called per-environment, aligning with the build hook behavior.
perEnvironmentWatchChangeDuringDev?
optionalperEnvironmentWatchChangeDuringDev:boolean
Experimental
Opt-in this plugin into per-environment watchChange during dev. For backward-compatibility, the watchChange hook is called only once during dev, for the client environment. Plugins can opt-in to be called per-environment, aligning with the watchChange hook behavior.
renderChunk?
optionalrenderChunk:ObjectHook<(this, ...parameters) => string | NullValue | { code: string; map?: SourceMapInput | undefined; } | Promise<string | NullValue | { code: string; map?: SourceMapInput | undefined; }>, { }>
renderDynamicImport?
optionalrenderDynamicImport:ObjectHook<(this,options) => NullValue | { left: string; right: string; }, { }>
renderError?
optionalrenderError:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
renderStart?
optionalrenderStart:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
resolveDynamicImport?
optionalresolveDynamicImport:ObjectHook<(this, ...parameters) => ResolveIdResult | Promise<ResolveIdResult>, { }>
resolveFileUrl?
optionalresolveFileUrl:ObjectHook<ResolveFileUrlHook, { }>
resolveId?
optionalresolveId:ObjectHook<(this,source,importer,options) => ResolveIdResult | Promise<ResolveIdResult>, {filter?: {id?: StringFilter<RegExp> | undefined; }; }>
extend hooks with ssr flag
resolveImportMeta?
optionalresolveImportMeta:ObjectHook<ResolveImportMetaHook, { }>
sharedDuringBuild?
optionalsharedDuringBuild:boolean
Experimental
Opt-in this plugin into the shared plugins pipeline. For backward-compatibility, plugins are re-recreated for each environment during vite build --app We have an opt-in per plugin, and a general builder.sharedPlugins In a future major, we'll flip the default to be shared by default
shouldTransformCachedModule?
optionalshouldTransformCachedModule:ObjectHook<(this, ...parameters) => boolean | NullValue | Promise<boolean | NullValue>, { }>
transform?
optionaltransform:ObjectHook<(this,code,id,options?) => TransformResult | Promise<TransformResult>, {filter?: {code?: StringFilter<string | RegExp> | undefined;id?: StringFilter<string | RegExp> | undefined; }; }>
transformIndexHtml?
optionaltransformIndexHtml:IndexHtmlTransform
Transform index.html. The hook receives the following arguments:
- html: string
- ctx: IndexHtmlTransformContext, which contains:
- path: public path when served
- filename: filename on disk
- server?: ViteDevServer (only present during serve)
- bundle?: rollup.OutputBundle (only present during build)
- chunk?: rollup.OutputChunk
- originalUrl?: string
It can either return a transformed string, or a list of html tag descriptors that will be injected into the <head> or <body>.
By default the transform is applied after vite's internal html transform. If you need to apply the transform before vite, use an object: { order: 'pre', handler: hook }
version?
optionalversion:string
watchChange?
optionalwatchChange:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
writeBundle?
optionalwriteBundle:ObjectHook<(this, ...parameters) =>void|Promise<void>, {sequential?:boolean; }>
getDTSPlugin()
getDTSPlugin(
config):object[]
Defined in: src/vite/dts.ts:26
Parameters
config
ResolvedConfig
Returns
getDTSPluginOptions()
getDTSPluginOptions(
config):PluginOptions
Defined in: src/vite/dts.ts:30
Parameters
config
ResolvedConfig