Skip to content

plugin-legacy: allow excluding polyfills #19074

Open
@jxn-30

Description

Description

When using @vitejs/plugin-legacy, I can use the auto-detection feature to automatically include the polyfills needed, based on my codebase and my browserslist config.
However, there may be polyfills that I don't want to have included e.g. because I want to use a different polyfill implementation or another dependency / import already provides a polyfill. I don't want to manually specify all the other polyfills but rather have the option to exclude one or more specific polyfills.

As far as I have seen, including such a feature would not be difficult to implement, thus I intend to provide a PR with a try in the near future.

Suggested solution

Two new options excludeLegacyPolyfills and excludeModernPolyfills, both of type string[].
Before creating the chunks, designated polyfills are filtered to remove the polyfills passed in options.

Alternatively, a single option excludePolyfills could also do the job but in my eyes, it is reasonable to stick to the seperated configuration between legacy and modern.

Alternative

No response

Additional context

No response

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