Skip to content

Commit 0ad353f

Browse files
committed
fix(replay): Remove unused parts of pako from build
See nodeca/pako#268, there is some issue with pako tree shaking ootb.
1 parent 8b7b81e commit 0ad353f

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

packages/replay-worker/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"@types/pako": "^2.0.0"
5050
},
5151
"dependencies": {
52-
"pako": "^2.1.0"
52+
"@rollup/plugin-commonjs": "25.0.7",
53+
"pako": "2.1.0"
5354
},
5455
"engines": {
5556
"node": ">=12"

packages/replay-worker/rollup.worker.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// inspired by https://justinribeiro.com/chronicle/2020/07/17/building-module-web-workers-for-cross-browser-compatibility-with-rollup/
22

33
import resolve from '@rollup/plugin-node-resolve';
4+
import commonjs from '@rollup/plugin-commonjs';
45
import typescript from '@rollup/plugin-typescript';
56
import { defineConfig } from 'rollup';
67
import { terser } from 'rollup-plugin-terser';
@@ -28,7 +29,9 @@ const config = defineConfig([
2829
file: './build/npm/esm/worker.ts',
2930
format: 'esm',
3031
},
32+
treeshake: 'smallest',
3133
plugins: [
34+
commonjs(),
3235
typescript({ tsconfig: './tsconfig.json', inlineSourceMap: false, sourceMap: false, inlineSources: false }),
3336
resolve(),
3437
terser({

packages/replay-worker/src/Compressor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { constants, Deflate, deflate } from 'pako';
1+
import type * as PakoTypes from 'pako';
2+
// @ts-expect-error no types here
3+
import * as pako from 'pako/lib/deflate.js';
4+
5+
const Deflate = (pako as typeof PakoTypes).Deflate;
6+
const deflate = (pako as typeof PakoTypes).deflate;
7+
const constants = (pako as typeof PakoTypes).constants;
28

39
/**
410
* A stateful compressor that can be used to batch compress events.
@@ -7,7 +13,7 @@ export class Compressor {
713
/**
814
* pako deflator instance
915
*/
10-
public deflate: Deflate;
16+
public deflate: PakoTypes.Deflate;
1117

1218
/**
1319
* If any events have been added.

yarn.lock

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4753,6 +4753,18 @@
47534753
is-reference "1.2.1"
47544754
magic-string "^0.27.0"
47554755

4756+
4757+
version "25.0.7"
4758+
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.7.tgz#145cec7589ad952171aeb6a585bbeabd0fd3b4cf"
4759+
integrity sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==
4760+
dependencies:
4761+
"@rollup/pluginutils" "^5.0.1"
4762+
commondir "^1.0.1"
4763+
estree-walker "^2.0.2"
4764+
glob "^8.0.3"
4765+
is-reference "1.2.1"
4766+
magic-string "^0.30.3"
4767+
47564768
"@rollup/plugin-commonjs@^15.0.0":
47574769
version "15.1.0"
47584770
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz#1e7d076c4f1b2abf7e65248570e555defc37c238"
@@ -23281,16 +23293,16 @@ pad@^3.2.0:
2328123293
dependencies:
2328223294
wcwidth "^1.0.1"
2328323295

23296+
[email protected], pako@^2.1.0:
23297+
version "2.1.0"
23298+
resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86"
23299+
integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==
23300+
2328423301
pako@^1.0.3, pako@~1.0.5:
2328523302
version "1.0.11"
2328623303
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
2328723304
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
2328823305

23289-
pako@^2.1.0:
23290-
version "2.1.0"
23291-
resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86"
23292-
integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==
23293-
2329423306
parallel-transform@^1.1.0:
2329523307
version "1.2.0"
2329623308
resolved "https://registry.yarnpkg.com/parallel-transform/-/parallel-transform-1.2.0.tgz#9049ca37d6cb2182c3b1d2c720be94d14a5814fc"

0 commit comments

Comments
 (0)