Skip to content

fix(replay-worker): Maintain ES5 compatibility for web worker code #17169

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mingquan5830
Copy link

Problem

The web worker string contains ES6+ syntax that cannot be handled by tools like webpack + babel when targeting ES5 environments, which causes compatibility issues when used in projects that need to transpile to ES5.

Root Cause

I know there have been discussions about dropping ES5 support. While users who want ES5 support need to handle transpilation themselves in their projects, but web worker strings are quite special. Processing them as ES5 separately would make them compatible with more build environments.

The TypeScript configuration in packages/replay-worker/tsconfig.json was set to target: "es2018", causing the generated worker code to use modern JavaScript syntax that cannot be properly transpiled by build tools in downstream projects.

Solution

Changed the TypeScript compilation target from es2018 to es5 in the replay-worker package configuration. This ensures:

  • Web worker code is generated as ES5-compatible JavaScript
  • Build tools like webpack + babel can properly handle the worker code
  • No breaking changes to the public API
  • All existing tests continue to pass

Changes

  • Modified packages/replay-worker/tsconfig.json: target: "es2018"target: "es5"

Testing

  • ✅ Existing unit tests pass
  • ✅ Code quality checks (lint) pass
  • ✅ Generated worker code is now ES5 compatible

@mingquan5830 mingquan5830 requested a review from a team as a code owner July 25, 2025 09:17
@mydea
Copy link
Member

mydea commented Jul 25, 2025

hmm, is this change enough to actually output ES5 compatible code? 🤔 if so, then IMHO it's fine, we need to see if there is an overly big bundle size impact, but likely it's fine 🤔 cc @chargome and @billyvg thoughts?

@chargome
Copy link
Member

Bundle size looks alright, if this does the job lgtm!

Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

@chargome & @billyvg feel free to merge if you approve!

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.

3 participants