Skip to content
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

@vitejs/plugin-legacy 自定义 modernPolyfills targets #10093

Closed
4 tasks done
ccqgithub opened this issue Sep 13, 2022 · 2 comments
Closed
4 tasks done

@vitejs/plugin-legacy 自定义 modernPolyfills targets #10093

ccqgithub opened this issue Sep 13, 2022 · 2 comments

Comments

@ccqgithub
Copy link

ccqgithub commented Sep 13, 2022

Description

现在,现代浏览器的polyfills只能基于 { esmodules: true },不能自定义,希望新增一个参数来自定义。

Suggested solution

添加一个modernTargets参数,传给@vitejs/plugin-legacy,如:

legacy({
        targets: ['chrome 87', 'safari 13', 'firefox 78', 'edge 88'],
        modernPolyfills: true,
        modernTargets: {
          browsers: [
            // 'defaults',
            'chrome 87',
            'safari 13',
            'firefox 78',
            'edge 88'
          ]
        }
      })

插件代码如:

await detectPolyfills(raw, { esmodules: !options.modernTargets, ...options.modernTargets }, modernPolyfills);

Alternative

No response

Additional context

No response

Validations

@lsdsjy
Copy link
Contributor

lsdsjy commented Sep 14, 2022

Duplicate of #6922?

@ccqgithub
Copy link
Author

Duplicate of #6922?

Oh, yes!i close this.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants