Skip to content

Upgrade Babel to 8 and move polyfill injection to babel-plugin-polyfill-corejs3 - #15169

Merged
rtibbles merged 1 commit into
learningequality:developfrom
rtibblesbot:issue-15138-85358f
Aug 9, 2026
Merged

Upgrade Babel to 8 and move polyfill injection to babel-plugin-polyfill-corejs3#15169
rtibbles merged 1 commit into
learningequality:developfrom
rtibblesbot:issue-15138-85358f

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Injection moves off the removed useBuiltIns onto babel-plugin-polyfill-corejs3entry-global for the polyfills bundle and Jest, usage-global for the sandbox. core-js unifies on the catalog at 3.49.0.

References

Fixes #15138. Supersedes #15113 — close when this lands.
Criteria ticked with evidence: #15169 (comment)

Reviewer guidance

  • jest.conf/babel.config.js:8 — polyfill-corejs3 advertises @babel/runtime-corejs3 whatever its method, and transform-runtime follows it; hence moduleName.
  • package.json:108@babel/parser held at 7.x in recast's scope: 8.x is ESM-only and recast require()s it undeclared.
  • jest.conf/index.js:25@vue/vue2-jest@29.2.6 peers jest 29 / babel-jest 29 / @babel/core 7, all mismatched.
  • pnpm-lock.yaml — one non-Babel move: terser 5.49.2 → 5.46.0, deduped onto the copy already there under an optional terser-webpack-plugin.

Polyfill accounting

core-js-compat over browserslist-config-kolibri: 300 → 327 modules, 65 added, 38 removed. Every removal is an esnext.X with a matching es.X addition.

38 graduations, 27 new modules

Graduated: iterator.*, set.* v2, json.* raw-json, array-buffer.* transfer/detached, symbol.[async-]dispose, [async-]disposable-stack, async-iterator.async-dispose, suppressed-error, array.from-async, map/object.group-by, promise.try, promise.with-resolvers.

Group New
Float16 es.data-view.{get,set}-float16, es.math.f16round
Uint8Array es.uint8-array.{from,to,set-from}-{base64,hex}
getOrInsert es.{map,weak-map}.get-or-insert[-computed]
Other stable es.error.is-error, es.iterator.concat, es.math.sum-precise, es.regexp.escape
Proposals esnext.data-view.{get,set}-uint8-clamped, esnext.iterator.{chunks,sliding,windows,zip,zip-keyed}, esnext.number.clamp, esnext.symbol.custom-matcher
Web web.url.parse

Emitted core-js/modules/* for polyfills.js:

Step Emitted vs previous
Babel 7, useBuiltIns: 'entry', corejs 3.31 300
core-js → 3.49 327 all 103 changed ids are in the compat diff
useBuiltIns → polyfill-corejs3 327 byte-identical
Babel 7 → 8 327 identical

Bundle 211,870 → 230,596 bytes (gz 73,633 → 80,399), all the core-js bump.

Sandbox usage mode: 58 modules before and after, the one change esnext.json.parsees.json.parse. Re-measure with babel-loader's caller flags; without them preset-env down-transforms import() and injects a spurious es.weak-map.

Criteria not met as written

  1. Latest core-js — 3.49.0; minimumReleaseAge blocks 3.50.0 until 2026-08-12.
  2. A feature test separating browsers that need the bundle — not achievable at any version: the cohort passing the ES2023 array-copy test needs 184 modules at 3.31 and 211 at 3.49, and no es.* module dominates all three engines. It stays a legacy-cohort cutoff — measurement.
  3. Matching corejs: hints — that preset-env key is gone; the literal is polyfill-corejs3's version, '3.49' in all three configs.
  4. BrowserStack Chrome 49 — unverified: no credentials or tunnel here.

Verification

pnpm test-jest 318/318, pnpm sandbox-build, make assets, make dist, prek: pass. No useBuiltIns outside node_modules.

AI usage

Used Claude Code to plan and implement the upgrade, and to measure the compat and emitted-import diffs rather than reason about them. Verified with the full Jest suite, the sandbox build and the WHL build.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-08-08 10:26 UTC

@github-actions github-actions Bot added DEV: renderers HTML5 apps, videos, exercises, etc. DEV: frontend SIZE: small labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

npm Package Versions

Warning

The following packages have changed files but no version bump:

Package Version Changed files
kolibri-jest-config 1.0.0 3

If these changes affect published code, consider bumping the version.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@rtibblesbot
rtibblesbot force-pushed the issue-15138-85358f branch 3 times, most recently from 3ef1d27 to 5213ad0 Compare August 8, 2026 09:49
@rtibblesbot
rtibblesbot marked this pull request as ready for review August 8, 2026 10:05
@rtibblesbot

Copy link
Copy Markdown
Contributor Author

Acceptance criteria, ticked here because this account cannot edit the issue body (PATCH /issues/15138 → 403).

  • No babel config sets useBuiltIns; polyfill-corejs3 does entry-global for the polyfills bundle and Jest, usage-global for the sandbox — grep -rn useBuiltIns outside node_modules is empty.
  • All four packages declare "core-js": "catalog:"kolibri/core/package.json:13, packages/kolibri-jest-config/package.json:21, packages/kolibri-sandbox/package.json:35, packages/kolibri-zip/package.json:10.
  • Catalog at ^3.49.0; the version literal is '3.49' in all three configs. Not 3.50.0 — minimumReleaseAge blocks it until 2026-08-12. corejs: itself is gone; it was a preset-env key.
  • @babel/core, @babel/preset-env, @babel/plugin-transform-runtime, @babel/runtime all ^8.0.0. The lone 7.x literal is the @babel/parser override scoped to recast.
  • polyfillLoader.js comment names the feature and calls the threshold a legacy-cohort cutoff. The separation the criterion asks for is unachievable at any core-js version — measured in Upgrade to Babel 8 and unify core-js on the pnpm catalog #15138 (comment).
  • core-js-compat diff 3.31 → 3.49 accounted for in the PR body: 300 → 327, 65 added, 38 removed, every removal an esnext.X with a matching es.X.
  • pnpm test-jest 318/318, pnpm sandbox-build, make assets, make dist, prek — all pass locally; CI 55 green, 0 failing.
  • BrowserStack Chrome 49 — not run. No credentials or tunnel in this environment. The emitted set is 327 modules and the loader's feature test is unchanged, so Chrome 49 still fires it, but that is inference, not a browser run.

…ll-corejs3

Babel 8 removes preset-env's `useBuiltIns`. Each of the three configs that set
it keeps its injection mode: `entry-global` for the core polyfills bundle and
Jest, `usage-global` for the sandbox. The core-js version hint moves with it,
onto the plugin's `version` option.

core-js unifies on the catalog at 3.49.0 — 3.50.0 is inside the 7-day
`minimumReleaseAge` window. 300 -> 327 generated modules; all 38 removals are
proposals that graduated to `es.*` in the same diff.

Consequences of the major:

- `vue-jest@3` reaches @babel/core through the `babel-core` bridge, which dies
  under 8. `@vue/vue2-jest` delegates to babel-jest instead.
- transform-runtime needs an explicit `moduleName`: polyfill-corejs3 advertises
  `@babel/runtime-corejs3` as the helper module whatever its `method`.
- `@babel/parser` is pinned to 7.x inside recast's scope — recast requires it
  from CJS without declaring it, and 8.x is ESM-only.
- `@babel/plugin-syntax-import-assertions` is dropped; it has no 8.x release,
  and nothing transformed here uses import attributes.

polyfillLoader.js's comment claimed browsers passing its ES2023 array-method
test support the full polyfill set. That was already false at 3.31; the comment
now states the test as the legacy-cohort cutoff it is.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes make sense - manual QA checks out, no regressions when testing on Chrome 65.

@rtibbles
rtibbles merged commit 50284be into learningequality:develop Aug 9, 2026
76 checks passed
@rtibblesbot
rtibblesbot deleted the issue-15138-85358f branch August 9, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DEV: frontend DEV: renderers HTML5 apps, videos, exercises, etc. SIZE: small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to Babel 8 and unify core-js on the pnpm catalog

2 participants