Skip to content

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

Open
@cobaltt7

Description

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions