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

fix(legacy): modern polyfill autodetection was injecting more polyfills than needed #14428

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Sep 21, 2023

Description

Modern chunks are targeting "ESM + dynamic import + import.meta + async generator" but the polyfill detection was using { esmodules: true } as the target.

injected modern polyfills in legacy playground

before

 {
  'core-js/modules/es.symbol.description.js',
  'core-js/modules/es.symbol.async-iterator.js',
  'core-js/modules/es.array.iterator.js',
  'core-js/modules/web.dom-collections.iterator.js',
  'core-js/modules/es.error.cause.js',
  'core-js/modules/es.promise.js',
  'core-js/modules/web.url.js',
  'core-js/modules/web.url-search-params.js',
  'core-js/modules/web.url-search-params.delete.js',
  'core-js/modules/web.url-search-params.has.js',
  'core-js/modules/web.url-search-params.size.js',
  'core-js/modules/es.string.ends-with.js',
  'core-js/modules/esnext.set.difference.v2.js',
  'core-js/modules/esnext.set.intersection.v2.js',
  'core-js/modules/esnext.set.is-disjoint-from.v2.js',
  'core-js/modules/esnext.set.is-subset-of.v2.js',
  'core-js/modules/esnext.set.is-superset-of.v2.js',
  'core-js/modules/esnext.set.symmetric-difference.v2.js',
  'core-js/modules/esnext.set.union.v2.js',
  'core-js/modules/es.json.stringify.js',
  'core-js/modules/web.dom-exception.constructor.js',
  'core-js/modules/web.dom-exception.stack.js',
  'core-js/modules/web.dom-exception.to-string-tag.js',
  'core-js/modules/web.structured-clone.js',
  'core-js/modules/es.array.push.js'
}

after

{
  'core-js/modules/web.dom-collections.iterator.js',
  'core-js/modules/web.url.js',
  'core-js/modules/web.url-search-params.js',
  'core-js/modules/web.url-search-params.delete.js',
  'core-js/modules/web.url-search-params.has.js',
  'core-js/modules/web.url-search-params.size.js',
  'core-js/modules/es.error.cause.js',
  'core-js/modules/esnext.set.difference.v2.js',
  'core-js/modules/esnext.set.intersection.v2.js',
  'core-js/modules/esnext.set.is-disjoint-from.v2.js',
  'core-js/modules/esnext.set.is-subset-of.v2.js',
  'core-js/modules/esnext.set.is-superset-of.v2.js',
  'core-js/modules/esnext.set.symmetric-difference.v2.js',
  'core-js/modules/esnext.set.union.v2.js',
  'core-js/modules/web.dom-exception.stack.js',
  'core-js/modules/web.structured-clone.js',
  'core-js/modules/es.array.push.js'
}

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added plugin: legacy p3-minor-bug An edge case that only affects very specific usage (priority) labels Sep 21, 2023
@stackblitz
Copy link

stackblitz bot commented Sep 21, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Good catch!

@sapphi-red sapphi-red merged commit 1c2e941 into vitejs:main Sep 22, 2023
12 checks passed
@sapphi-red sapphi-red deleted the fix/legacy-incorrect-modern-polyfill-detection branch September 22, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) plugin: legacy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants