Skip to content

feat(types): use terser types from terser package #20274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sapphi-red
Copy link
Member

Description

Removed the inlined types for terser and made it use the types from terser package when installed.
This would:

  • make the types aligned with the installed terser version
  • reduce the package size of Vite
  • reduce the maintenance burden of syncing type defs

The only downside of this is that users that doesn't use terser but sets terser options and wants to have a stricter type needs to install terser now.

@sapphi-red sapphi-red added p2-nice-to-have Not breaking anything but nice to have (priority) trigger: preview labels Jun 23, 2025
Copy link

pkg-pr-new bot commented Jun 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/vite@20274

commit: 6602a1c

Copy link

pkg-pr-new bot commented Jun 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/vite@20274

commit: 6602a1c

@sapphi-red
Copy link
Member Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 6602a1c: Open

suite result latest scheduled
histoire failure failure
react-router failure failure
waku success failure
vike failure failure

astro, analogjs, laravel, qwik, marko, rakkas, one, unocss, quasar, ladle, nuxt, storybook, sveltekit, vite-plugin-svelte, vite-plugin-pwa, vite-plugin-react, vite-environment-examples, vitest, vitepress, vuepress, vite-plugin-cloudflare, vite-rsc, vite-plugin-vue, vite-setup-catalogue

Comment on lines +10 to +11
export type TerserMinifyOptions = Terser.MinifyOptions
export type TerserMinifyOutput = Terser.MinifyOutput
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to re-export the type instead of other modules importing Terser directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to avoid Terser to be renamed to Terser$1 in the output dts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see 👍

@sapphi-red sapphi-red merged commit a5799fa into vitejs:main Jun 24, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority) trigger: preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants