fix(replay-worker): Maintain ES5 compatibility for web worker code #17169
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 totarget: "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
toes5
in the replay-worker package configuration. This ensures:Changes
packages/replay-worker/tsconfig.json
:target: "es2018"
→target: "es5"
Testing