Skip to content

Commit

Permalink
fix(replay): Remove unused parts of pako from build
Browse files Browse the repository at this point in the history
See nodeca/pako#268, there is some issue with pako tree shaking ootb.
  • Loading branch information
mydea committed Oct 27, 2023
1 parent 8b7b81e commit 0ad353f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/replay-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"@types/pako": "^2.0.0"
},
"dependencies": {
"pako": "^2.1.0"
"@rollup/plugin-commonjs": "25.0.7",
"pako": "2.1.0"
},
"engines": {
"node": ">=12"
Expand Down
3 changes: 3 additions & 0 deletions packages/replay-worker/rollup.worker.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// inspired by https://justinribeiro.com/chronicle/2020/07/17/building-module-web-workers-for-cross-browser-compatibility-with-rollup/

import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
import { terser } from 'rollup-plugin-terser';
Expand Down Expand Up @@ -28,7 +29,9 @@ const config = defineConfig([
file: './build/npm/esm/worker.ts',
format: 'esm',
},
treeshake: 'smallest',
plugins: [
commonjs(),
typescript({ tsconfig: './tsconfig.json', inlineSourceMap: false, sourceMap: false, inlineSources: false }),
resolve(),
terser({
Expand Down
10 changes: 8 additions & 2 deletions packages/replay-worker/src/Compressor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { constants, Deflate, deflate } from 'pako';
import type * as PakoTypes from 'pako';
// @ts-expect-error no types here
import * as pako from 'pako/lib/deflate.js';

const Deflate = (pako as typeof PakoTypes).Deflate;
const deflate = (pako as typeof PakoTypes).deflate;
const constants = (pako as typeof PakoTypes).constants;

/**
* A stateful compressor that can be used to batch compress events.
Expand All @@ -7,7 +13,7 @@ export class Compressor {
/**
* pako deflator instance
*/
public deflate: Deflate;
public deflate: PakoTypes.Deflate;

/**
* If any events have been added.
Expand Down
22 changes: 17 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4753,6 +4753,18 @@
is-reference "1.2.1"
magic-string "^0.27.0"

"@rollup/[email protected]":
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"
Expand Down Expand Up @@ -23281,16 +23293,16 @@ pad@^3.2.0:
dependencies:
wcwidth "^1.0.1"

[email protected], pako@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86"
integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==

pako@^1.0.3, pako@~1.0.5:
version "1.0.11"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==

pako@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86"
integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==

parallel-transform@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/parallel-transform/-/parallel-transform-1.2.0.tgz#9049ca37d6cb2182c3b1d2c720be94d14a5814fc"
Expand Down

0 comments on commit 0ad353f

Please sign in to comment.