Skip to content

Commit 88ea2d0

Browse files
pauldambraJuice10
andauthored
fix: move patch function into utils to improve bundling (#1631)
* fix: move patch function into utils to improve bundling --------- Co-authored-by: pauldambra <pauldambra@users.noreply.github.com> Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
1 parent 3e9e42f commit 88ea2d0

File tree

13 files changed

+71
-54
lines changed

13 files changed

+71
-54
lines changed

.changeset/itchy-tables-compete.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@rrweb/rrweb-plugin-console-record": patch
3+
"@rrweb/record": patch
4+
"rrweb": patch
5+
"@rrweb/utils": patch
6+
---
7+
8+
Move patch function into @rrweb/utils to improve bundling

packages/plugins/rrweb-plugin-console-record/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"puppeteer": "^20.9.0"
5454
},
5555
"peerDependencies": {
56-
"rrweb": "^2.0.0-alpha.18"
56+
"rrweb": "^2.0.0-alpha.18",
57+
"@rrweb/utils": "^2.0.0-alpha.18"
5758
}
5859
}

packages/plugins/rrweb-plugin-console-record/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { listenerHandler, RecordPlugin, IWindow } from '@rrweb/types';
2-
import { utils } from 'rrweb';
2+
import { patch } from '@rrweb/utils';
33
import { ErrorStackParser, StackFrame } from './error-stack-parser';
44
import { stringify } from './stringify';
55

@@ -183,7 +183,7 @@ function initLogObserver(
183183
};
184184
}
185185
// replace the logger.{level}. return a restore function
186-
return utils.patch(
186+
return patch(
187187
_logger,
188188
level,
189189
(original: (...args: Array<unknown>) => void) => {

packages/record/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
},
5757
"dependencies": {
5858
"@rrweb/types": "^2.0.0-alpha.18",
59-
"rrweb": "^2.0.0-alpha.18"
59+
"rrweb": "^2.0.0-alpha.18",
60+
"@rrweb/utils": "^2.0.0-alpha.18"
6061
},
6162
"browserslist": [
6263
"supports es6-class"

packages/record/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
},
1212
{
1313
"path": "../rrweb"
14+
},
15+
{
16+
"path": "../utils"
1417
}
1518
]
1619
}

packages/rrweb/src/record/observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import {
1515
getWindowWidth,
1616
isBlocked,
1717
legacy_isTouchEvent,
18-
patch,
1918
StyleSheetMirror,
2019
nowTimestamp,
2120
} from '../utils';
21+
import { patch } from '@rrweb/utils';
2222
import type { observerParam, MutationBufferParam } from '../types';
2323
import {
2424
IncrementalSource,

packages/rrweb/src/record/observers/canvas/2d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
type IWindow,
66
type listenerHandler,
77
} from '@rrweb/types';
8-
import { hookSetter, isBlocked, patch } from '../../../utils';
8+
import { hookSetter, isBlocked } from '../../../utils';
9+
import { patch } from '@rrweb/utils';
910
import { serializeArgs } from './serialize-args';
1011

1112
export default function initCanvas2DMutationObserver(

packages/rrweb/src/record/observers/canvas/canvas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ICanvas } from 'rrweb-snapshot';
22
import type { blockClass, IWindow, listenerHandler } from '@rrweb/types';
3-
import { isBlocked, patch } from '../../../utils';
3+
import { isBlocked } from '../../../utils';
4+
import { patch } from '@rrweb/utils';
45

56
function getNormalizedContextName(contextType: string) {
67
return contextType === 'experimental-webgl' ? 'webgl' : contextType;

packages/rrweb/src/record/observers/canvas/webgl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
type IWindow,
77
type listenerHandler,
88
} from '@rrweb/types';
9-
import { hookSetter, isBlocked, patch } from '../../../utils';
9+
import { hookSetter, isBlocked } from '../../../utils';
10+
import { patch } from '@rrweb/utils';
1011
import { saveWebGLVar, serializeArgs } from './serialize-args';
1112

1213
function patchGLPrototype(

packages/rrweb/src/record/shadow-dom-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import {
99
initScrollObserver,
1010
initAdoptedStyleSheetObserver,
1111
} from './observer';
12-
import { patch, inDom } from '../utils';
12+
import { inDom } from '../utils';
1313
import type { Mirror } from 'rrweb-snapshot';
1414
import { isNativeShadowDom } from 'rrweb-snapshot';
15-
import dom from '@rrweb/utils';
15+
import dom, { patch } from '@rrweb/utils';
1616

1717
type BypassOptions = Omit<
1818
MutationBufferParam,

0 commit comments

Comments
 (0)