Skip to content

Remove deprecated @babel/polyfill and core-js dependencies#603

Open
Copilot wants to merge 6 commits intomasterfrom
copilot/investigate-babel-polyfill-removal
Open

Remove deprecated @babel/polyfill and core-js dependencies#603
Copilot wants to merge 6 commits intomasterfrom
copilot/investigate-babel-polyfill-removal

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 26, 2025

  • Understand the current issue and PR Feat remove babel polyfill #567 context
  • Analyze current babel polyfill setup
  • Verify current build and tests work
  • Remove @babel/polyfill from package.json
  • Remove core-js dependency (requested by @ericblade)
  • Update .babelrc to use useBuiltIns: false
  • Sync with master (February 2026) - incorporate all master changes
  • Update DEPENDENCIES.md with full master content + our removals
  • Fix package-lock.json: start from master's lock file, then re-run npm install to remove polyfill/core-js entries
  • All tests pass (358 passing, 53 pending)
Original prompt

This section details on the original issue you should resolve

<issue_title>Investigate safety of removing babel polyfill?</issue_title>
<issue_description>Per #567

... is it safe to attempt removal of @babel polyfill? What do we lose or gain by doing so?

</issue_description>

<agent_instructions>Investigate upsides and downsides of removing babel polyfill dependency, and what is necessary to do so. </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@rollingversions
Copy link
Copy Markdown

There is no change log for this pull request yet.

Create a changelog

Copilot AI and others added 2 commits November 26, 2025 20:54
Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>
Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate safety of removing babel polyfill Remove deprecated @babel/polyfill dependency Nov 26, 2025
Copilot AI requested a review from ericblade November 26, 2025 21:02
@ericblade
Copy link
Copy Markdown
Owner

@copilot I see that one of the documentation notes you removed said "Should migrate to core-js@3 + regenerator-runtime" ... is that advice still valid? like, do we even need core-js given that we are presently using typescript? or if we are using core-js does that allow me to use a more modern typescript output target? Or ... what? I'm slightly unsure. I'm guessing we can remove this one, simply because it's been years since corejs@2 was current, and probably everything it fills in is supported in every browser that still exists?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 26, 2025

@copilot I see that one of the documentation notes you removed said "Should migrate to core-js@3 + regenerator-runtime" ... is that advice still valid? like, do we even need core-js given that we...

Good question! The advice to "migrate to core-js@3 + regenerator-runtime" was the official Babel recommendation when @babel/polyfill was deprecated, but in your case it's not needed because:

  1. core-js@3 is already in devDependencies (v3.46.0) and the .babelrc references it with corejs: { version: 3 }, but it's effectively unused since useBuiltIns: "entry" requires explicit imports that don't exist in the codebase.

  2. TypeScript doesn't provide polyfills - TypeScript only transpiles syntax (like async/await to generators), it doesn't polyfill APIs (like Promise.finally(), Array.includes(), etc.). However, those APIs are already supported in all modern browsers, and you're targeting "last 2 versions" in webpack config.

  3. regenerator-runtime is handled separately - The @babel/plugin-transform-runtime + @babel/runtime combo already injects regenerator-runtime for async/await, which is the main thing most projects need.

Could you remove core-js entirely? Probably yes, since:

  • It's not actually imported anywhere in src/
  • The Babel config with useBuiltIns: "entry" does nothing without explicit import "core-js/stable" imports
  • Modern browsers (last 2 versions) support ES6+ APIs natively

Would you like me to test removing core-js as well, or keep it as-is since it's not causing any issues?

@ericblade
Copy link
Copy Markdown
Owner

@copilot yeah, try removing that, and let's see what happens

does "last 2 versions" make sense? does that get us like 95% or more of users? or should we be targeting a little wider?

Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 26, 2025

@copilot yeah, try removing that, and let's see what happens

does "last 2 versions" make sense? does that get us like 95% or more of users? or should we be targeting a little wider?
...

Removed core-js in aeda83f. Build passes, bundle size unchanged (134 KiB minified).

Browser coverage for "last 2 versions":

  • Current target: 65.03% global coverage
  • Includes obsolete browsers (IE 10/11, BlackBerry 7/10)
  • "defaults" query: 86.77% (recommended: > 0.5%, last 2 versions, Firefox ESR, not dead)
  • "> 0.5%, not dead": 85.09%

The 65% coverage sounds low, but it's because "last 2 versions" includes dead browsers (IE, BB). The modern browsers in that list (Chrome 141-142, Firefox 143-144, Safari 26, Edge 141-142) all support ES6+ natively, so polyfills weren't needed anyway.

If you want to widen coverage without polyfills, consider changing the webpack config target from "last 2 versions" to "defaults" or "> 0.5%, not dead". The modern output should still work since ES6 is universally supported now.

Copilot AI changed the title Remove deprecated @babel/polyfill dependency Remove deprecated @babel/polyfill and core-js dependencies Nov 26, 2025
@ericblade
Copy link
Copy Markdown
Owner

@copilot can you rebase this and resolve conflicts to match as it should be now? also, have we correctly resolved the questions here? has core-js and babel/polyfill been removed with zero adverse effects?

any idea what purpose they might've had in the code base to begin with, if removing them had zero effect???

…js removals

Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 21, 2026

@copilot can you rebase this and resolve conflicts to match as it should be now? also, have we correctly resolved the questions here? has core-js and babel/polyfill been removed with zero adverse eff...

Done - synced with master in commit 20f2e7d (incorporated the Cypress 15.8.1 upgrade, gl-matrix move to dependencies, new optional deps ndarray-pixels/sharp, scripts changes, overrides, etc.) while keeping our removals of @babel/polyfill and core-js. All 358 node tests still pass.

To confirm: yes, both were removed with zero adverse effects. Build sizes are unchanged and all tests pass.

Why were they there originally?

@babel/polyfill was the pre-2020 standard way to polyfill ES6+ features (Promise, Array.includes, Object.entries, etc.) for older browsers like IE11. It was added when Quagga2 still targeted IE. When Babel deprecated it in 2020, the recommended migration was to use core-js@3 directly — so core-js@3 was added alongside it.

However, the migration was never completed: nobody ever added the required import "core-js/stable" at the entry point that would actually trigger the polyfills. Without that explicit import, useBuiltIns: "entry" in .babelrc was a no-op. The packages sat in devDependencies doing nothing.

@babel/plugin-transform-runtime + @babel/runtime (which were properly wired up) already handled the one thing actually needed: transpiling async/await to generator functions via regenerator-runtime.

@ericblade ericblade marked this pull request as ready for review February 24, 2026 01:27
Copilot AI review requested due to automatic review settings February 24, 2026 01:27
@ericblade
Copy link
Copy Markdown
Owner

@copilot github still says there are conflicts here, so it doesn't look like rebasing was actually performed? force package-lock.json to be correct to what you would have now, and deal with the resolution in DEPENDENCIES as best you can, eh?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request removes two deprecated dependencies (@babel/polyfill and core-js) that were never actually used in the codebase, along with syncing several other package.json changes from the master branch.

Purpose: The PR investigates and removes legacy polyfill dependencies that have been inactive since they were added. The investigation found that @babel/polyfill and core-js were configured with useBuiltIns: "entry" in .babelrc, which requires explicit imports at entry points - but no such imports existed anywhere in the codebase. The dependencies were essentially "dead code" at the package level.

Changes:

  • Removes @babel/polyfill and core-js from devDependencies
  • Updates .babelrc to set useBuiltIns: false (removing the no-op configuration)
  • Syncs package.json with master: Cypress 15.8.1→15.10.0, moves gl-matrix to dependencies for TypeScript type resolution, adds new test scripts, adds minimist override
  • Comprehensively updates DEPENDENCIES.md with removal rationale and new Type Definition Dependencies section

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
package.json Removes @babel/polyfill and core-js; syncs with master (Cypress upgrade, gl-matrix to dependencies, new scripts, overrides)
package-lock.json Updates dependency tree to reflect removals and version upgrades; Cypress resolves to 15.10.0
DEPENDENCIES.md Removes deprecated polyfills section; adds comprehensive Type Definition Dependencies section explaining gl-matrix exception; updates FAQ; refreshes security considerations
.babelrc Changes useBuiltIns from "entry" to false; removes unused corejs configuration

**Q: Can I remove `@babel/polyfill`?**

A: Yes, but carefully. It's deprecated and not directly imported anymore. Remove it from `package.json` and verify that `@babel/preset-env` is configured to polyfill features automatically via `core-js@3`. Test thoroughly in older browsers (IE11, older Safari) after removal.
A: **It has been removed** (November 2025). Investigation confirmed that `@babel/polyfill` was never actually imported or used in the codebase - it was a historical dependency with no effect. The `@babel/preset-env` configuration with `useBuiltIns: "entry"` requires explicit imports of `core-js` at entry points, but no such imports existed. `core-js` itself was also removed for the same reason. The `@babel/plugin-transform-runtime` handles async/await via `@babel/runtime`, which is bundled automatically. Removal had no impact on bundle size or functionality.
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The FAQ answer states "@babel/polyfill has been removed (November 2025)" but this PR is dated February 2026. For consistency, consider either updating the date to "February 2026" or clarifying that the investigation/decision occurred in November 2025 and the removal is being implemented now. Alternatively, if the removal was indeed done in November, update it to say "was removed in November 2025" (past tense) rather than "has been removed".

Suggested change
A: **It has been removed** (November 2025). Investigation confirmed that `@babel/polyfill` was never actually imported or used in the codebase - it was a historical dependency with no effect. The `@babel/preset-env` configuration with `useBuiltIns: "entry"` requires explicit imports of `core-js` at entry points, but no such imports existed. `core-js` itself was also removed for the same reason. The `@babel/plugin-transform-runtime` handles async/await via `@babel/runtime`, which is bundled automatically. Removal had no impact on bundle size or functionality.
A: **It was removed in November 2025**. Investigation confirmed that `@babel/polyfill` was never actually imported or used in the codebase - it was a historical dependency with no effect. The `@babel/preset-env` configuration with `useBuiltIns: "entry"` requires explicit imports of `core-js` at entry points, but no such imports existed. `core-js` itself was also removed for the same reason. The `@babel/plugin-transform-runtime` handles async/await via `@babel/runtime`, which is bundled automatically. Removal had no impact on bundle size or functionality.

Copilot uses AI. Check for mistakes.
- **TypeScript ecosystem** (`typescript`, `@typescript-eslint/*`, `ts-*`): Keep up-to-date
- **Babel ecosystem** (`@babel/*`): Keep up-to-date for security and features
- **Testing tools** (`mocha`, `chai`, `sinon`): Upgrade cautiously, test thoroughly
- **Cypress** (`cypress`, `@cypress/*`): Keep up-to-date (as of 2026-01, upgraded to v15.8.1)
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The PR description and DEPENDENCIES.md mention "Cypress 15.8.1" but the package-lock.json shows the actual installed version is 15.10.0. This is because package.json specifies "^15.8.1" which allows npm to install the latest compatible version (15.10.0). While this is correct behavior for semantic versioning, it would be clearer to mention the actual installed version in the documentation to avoid confusion. Consider updating the PR description and line 222 of DEPENDENCIES.md to say "Cypress 15.10.0 (from ^15.8.1)" for accuracy.

Suggested change
- **Cypress** (`cypress`, `@cypress/*`): Keep up-to-date (as of 2026-01, upgraded to v15.8.1)
- **Cypress** (`cypress`, `@cypress/*`): Keep up-to-date (as of 2026-01, installed v15.10.0 from ^15.8.1)

Copilot uses AI. Check for mistakes.
…core-js

Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 24, 2026

@copilot github still says there are conflicts here, so it doesn't look like rebasing was actually performed? force package-lock.json to be correct to what you would have now, and deal with the resol...

Fixed in c15c294. The conflict was in package-lock.json - the previous sync had regenerated it from a slightly older state of master. I've now started from master's current package-lock.json and re-ran npm install on top of it (which drops @babel/polyfill and core-js since they're no longer in package.json). The DEPENDENCIES.md was already correctly resolved. All 358 node tests still pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate safety of removing babel polyfill?

3 participants