vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
67.06k stars 6.02k forks source link

Allow specifying assumptions in `@vitejs/plugin-legacy` #6965

Open cobaltt7 opened 2 years ago

cobaltt7 commented 2 years ago

Clear and concise description of the problem

Babel allows specifying compiler assumptions for smaller code output, see https://babeljs.io/docs/en/assumptions. However, @vitejs/plugin-legacy doesn't allow these options to be enabled.

Suggested solution

Add an option called assumptions and pass it to Babel.

I noticed this in the contributing guildlines:

Think before adding yet another option We already have many config options, and we should avoid fixing an issue by adding yet another one. Before adding an option, try to think about:

I think it's ok here since @vitejs/plugin-legacy doesn't have too many options right now.

Whether the problem is really worth addressing

Yes, this option could significantly reduce output size

Whether the problem can be fixed with a smarter default

Possibly...we could set the assumptions to those that work well with Vite but that might not work with users' code.

Whether the problem has workaround using existing options

No.

Whether the problem can be addressed with a plugin instead

No.

Alternative

No response

Additional context

I'd be willing to make a PR for this except I am not familliar with Jest nor pnpm.

Validations

github-actions[bot] commented 2 years ago

Hello @RedGuy12. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!