You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that type-checking the codebase with TypeScript is an expensive operation, having to do so twice during the build operation would be wasteful.
The vite-plugin-dts internally creates an instance of TypeScript program, as well as host and service. It would be really great if we could reuse the same instances for other work we may need to do during the build outside the vite-plugin-dts.
For example, custom-elements-manifest accepts TypeScript source files instances (or if you don't provide them, it will create them for you) - being able to provide it the same instances that vite-plugin-dts used would let me speed up the build and ensure more consistency.
Suggested solution
Make vite-plugin-dts expose the program instance it creates internally (host and service would be nice too, but not essential). For example, if we could provide a callback to vite-plugin-dts as a config option, and it would call that callback with TypeScript program instance as an argument, that would be great.
Let us provide the TypeScript program instance to vite-plugin-dts or intercept it's creation so that we can have a reference to it
Alternative
I see that the plugin provides the program instance to the resolvers transform callback. My current hacky workaround is to add one dummy resolver that will get the reference to the program instance.
The other option, that is not ideal, is for me to overwrite vue-tsc's createProgram() method to spy on when vitePluginDts calls it to get a reference to the program. However, this solution would be very fragile.
Description
Given that type-checking the codebase with TypeScript is an expensive operation, having to do so twice during the build operation would be wasteful.
The
vite-plugin-dts
internally creates an instance of TypeScriptprogram
, as well ashost
andservice
. It would be really great if we could reuse the same instances for other work we may need to do during the build outside thevite-plugin-dts
.For example,
custom-elements-manifest
accepts TypeScript source files instances (or if you don't provide them, it will create them for you) - being able to provide it the same instances thatvite-plugin-dts
used would let me speed up the build and ensure more consistency.Suggested solution
Make
vite-plugin-dts
expose theprogram
instance it creates internally (host
andservice
would be nice too, but not essential). For example, if we could provide a callback tovite-plugin-dts
as a config option, and it would call that callback with TypeScriptprogram
instance as an argument, that would be great.Let us provide the TypeScript
program
instance tovite-plugin-dts
or intercept it's creation so that we can have a reference to itAlternative
I see that the plugin provides the
program
instance to theresolvers
transform callback. My current hacky workaround is to add one dummy resolver that will get the reference to theprogram
instance.The other option, that is not ideal, is for me to overwrite vue-tsc's
createProgram()
method to spy on whenvitePluginDts
calls it to get a reference to the program. However, this solution would be very fragile.Additional context
Thank you for the great work on this plugin!
Validations
The text was updated successfully, but these errors were encountered: