chore: drop IE11 from browserslist, keep ES5 bundle as polyfill canary#3669
Conversation
Remove IE 11 from packages/browser/package.json#browserslist. The ES5 bundle (array.full.es5.js) is still built with IE11-compatible Babel targets (hard-coded in rollup.config.mjs) and validated by es-check in CI, so it continues to act as a canary that surfaces when we need a new polyfill. The previous attempt to drop IE11 broke CI because two tests (web-vitals.test.ts and posthog-core-also.test.ts) reference let mockX: jest.Mock from inside jest.mock(...) factories. Jest hoists the factory above the declaration, which is a TDZ bug. With IE 11 in browserslist, babel-jest's @babel/preset-env was transpiling let -> var, masking the bug. Switching the two declarations to var is the canonical jest workaround for out-of-scope mock references. Generated-By: PostHog Code Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
|
Reviews (1): Last reviewed commit: "chore: drop IE11 from browserslist, keep..." | Re-trigger Greptile |
|
Size Change: 0 B Total Size: 16.4 MB ℹ️ View Unchanged
|
packages/browser/babel.config.cjs used @babel/preset-env without explicit targets, which falls back to package.json#browserslist. That config is what jest and testcafe both use to transpile sources and test code. With IE 11 removed from browserslist, testcafe's ClientFunction bodies stopped being transpiled to ES5 and the browserstack IE11 test hung at posthog.init (the test runner injects its ClientFunction wrapper into the page; IE11 chokes on arrow functions and default params). Pinning the babel targets here decouples this transpile pipeline from package.json#browserslist. Same reason the rollup ES5 build hard-codes its own targets in rollup.config.mjs. This also restores the let -> var test fix from the previous commit: with babel now consistently transpiling let to var for jest, the TDZ bug in those jest.mock factories is masked again. Reverting keeps the test source untouched relative to main. Generated-By: PostHog Code Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96
testcafe ignores the project's babel config (BASE_BABEL_OPTIONS sets babelrc: false, configFile: false). It transpiles its injected ClientFunction wrappers with @babel/preset-env and no targets, which falls back to the browserslist module — which reads package.json#browserslist. So the real lever for fixing the IE11 hang is browserslist, not babel.config.cjs. Set BROWSERSLIST inline on the testcafe workflow step instead, which: - keeps package.json#browserslist clean (IE11 truly removed) - keeps babel.config.cjs untouched (jest runs in node, no need to transpile to es5) - limits the IE11 target to the one place it actually matters: the testcafe ClientFunction transpile pipeline Revert babel.config.cjs and restore the let -> var fix in the two jest.mock factories — the TDZ bug there is real (jest hoists the factory above the let declaration), independent of any babel config. Generated-By: PostHog Code Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96
The var declarations are necessary so the assignments inside the hoisted jest.mock factories don't hit TDZ. Add per-line eslint-disable instead of leaving CI red on no-var. Generated-By: PostHog Code Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
| RUN_ID: ${{ github.run_id }} | ||
| BROWSER: ${{ matrix.browser }} | ||
| BROWSERSLIST: "> 0.5%, last 2 versions, Firefox ESR, not dead, IE 11" |
There was a problem hiding this comment.
this is what was missing when previous attempts to do this lead to these tests freezing
…able Generated-By: PostHog Code Task-Id: 4411132c-c680-4a22-be01-98a36d63cf96

Summary
IE 11frompackages/browser/package.json#browserslist— we don't actually support IE11.array.full.es5.js) build and thees-checkworkflow intact. Babelpreset-envtargets for the ES5 build are hard-coded inrollup.config.mjs(still include'IE 11'), so the ES5 polyfill set is unchanged. The ES5 bundle is now a canary:es-checkfailing on it tells us we've introduced something the polyfill set can't cover yet.web-vitals.test.ts,posthog-core-also.test.ts). They referencedlet mockX: jest.Mockfrom insidejest.mock(...)factories, which jest hoists above the declaration. Babel was previously transpilinglet->var(because IE 11 was in browserslist), masking the bug. Switching the two declarations tovar— the canonical jest workaround for out-of-scope mock references — is the actual root cause of the CI failure the previous attempt hit.Test plan
pnpm lintpassespnpm buildsucceeds forpackages/browserES5 support checkworkflow (es-check es5 onarray.full.es5.js) is green — this is the IE11 bundle test we explicitly want to keep validatingES6 support check(es-check es6 onarray.full.js) is greenpnpm --filter posthog-js test:unitpasses (modulo the pre-existing flaky perf assertion inlogs.test.ts)library-cicompat playwright job behaves the same as on main (non-blocking)Created with PostHog Code