diff --git a/packages/replay-worker/package.json b/packages/replay-worker/package.json index 7a25d4b38d6c..030facbf7afb 100644 --- a/packages/replay-worker/package.json +++ b/packages/replay-worker/package.json @@ -46,10 +46,10 @@ }, "homepage": "https://docs.sentry.io/platforms/javascript/session-replay/", "devDependencies": { + "@rollup/plugin-commonjs": "^21.0.1", "@types/pako": "^2.0.0" }, "dependencies": { - "@rollup/plugin-commonjs": "25.0.7", "pako": "2.1.0" }, "engines": { diff --git a/packages/replay-worker/src/Compressor.ts b/packages/replay-worker/src/Compressor.ts index b16e930282ff..18515574bf25 100644 --- a/packages/replay-worker/src/Compressor.ts +++ b/packages/replay-worker/src/Compressor.ts @@ -2,6 +2,11 @@ import type * as PakoTypes from 'pako'; // @ts-expect-error no types here import * as pako from 'pako/lib/deflate.js'; +// NOTE: We have to do this weird workaround because by default, +// pako does not treeshake when importing from 'pako'. +// In order to get proper tree shaking, we have to import from 'pako/lib/deflate.js', +// Which is not great but works +// types come from @types/pako, so we can safely use them by casting const Deflate = (pako as typeof PakoTypes).Deflate; const deflate = (pako as typeof PakoTypes).deflate; const constants = (pako as typeof PakoTypes).constants; diff --git a/yarn.lock b/yarn.lock index 260c30b9383d..719b4959d285 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4753,18 +4753,6 @@ is-reference "1.2.1" magic-string "^0.27.0" -"@rollup/plugin-commonjs@25.0.7": - version "25.0.7" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.7.tgz#145cec7589ad952171aeb6a585bbeabd0fd3b4cf" - integrity sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ== - dependencies: - "@rollup/pluginutils" "^5.0.1" - commondir "^1.0.1" - estree-walker "^2.0.2" - glob "^8.0.3" - is-reference "1.2.1" - magic-string "^0.30.3" - "@rollup/plugin-commonjs@^15.0.0": version "15.1.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz#1e7d076c4f1b2abf7e65248570e555defc37c238"