From 8e114ef91d3dddd417085a72a368072d88e74c4c Mon Sep 17 00:00:00 2001 From: Martin Sonnberger Date: Fri, 13 Nov 2026 13:56:55 +0100 Subject: [PATCH] fix(replay): Minify the compression worker to ES2020 The embedded compression worker is minified with `minifySync`, which doesn't pick up `transform.target` and defaults to esnext. It shipped `||=`/`&&=` (ES2021), so the worker fails to start on ES2020-only browsers. Because it is embedded as a string, `lint:es-compatibility` never saw it, so the build now parses it as ES2020. Co-Authored-By: Claude Opus 5.5 --- packages/replay-worker/rollup.worker.config.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/replay-worker/rollup.worker.config.mjs b/packages/replay-worker/rollup.worker.config.mjs index 323772986beb..e282d9c4b1bc 100644 --- a/packages/replay-worker/rollup.worker.config.mjs +++ b/packages/replay-worker/rollup.worker.config.mjs @@ -1,6 +1,7 @@ // inspired by https://justinribeiro.com/chronicle/2020/07/17/building-module-web-workers-for-cross-browser-compatibility-with-rollup/ import { treeShakePreset } from '@sentry-internal/rollup-utils'; +import { parse } from 'acorn'; import { defineConfig } from 'rolldown'; import { minifySync } from 'rolldown/utils'; @@ -42,7 +43,11 @@ const config = defineConfig([ // emits string literals as backticks, which would terminate the literal early and silently // produce an empty chunk. renderChunk(code) { - const { code: minified } = minifySync('worker.js', code, { module: true }); + // Unlike `output.minify`, `minifySync` doesn't pick up `transform.target` and defaults to esnext. + const { code: minified } = minifySync('worker.js', code, { module: true, compress: { target: 'es2020' } }); + + // `lint:es-compatibility` can't see into the string we embed below, so check the syntax here. + parse(minified, { ecmaVersion: 2020, sourceType: 'module' }); return `export default ${JSON.stringify(minified)};`; },