-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: don't bundle everything into console recorder #1594
Open
pauldambra
wants to merge
10
commits into
rrweb-io:master
Choose a base branch
from
PostHog:fix/console-bundle-size
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bacf51d
add bundle analysis so we can see what we're doing
pauldambra e7b5512
move patch to the utils package
pauldambra 3d7a510
changeset
pauldambra 804380a
prettier?
pauldambra 8d05556
explicit peers
pauldambra 3ba47f1
check bundle sizes
pauldambra d50efa8
Wat
pauldambra 4e1b1d3
quotes?
pauldambra 0edb1e3
like this
pauldambra 47ba0dc
like this
pauldambra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@rrweb/rrweb-plugin-console-record": patch | ||
"rrweb": patch | ||
"@rrweb/utils": patch | ||
--- | ||
|
||
move patch function into rrweb/utils to improve bundling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import type { listenerHandler, RecordPlugin, IWindow } from '@rrweb/types'; | ||
import { utils } from 'rrweb'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the fix here... this line was including the whole of rrweb |
||
import { ErrorStackParser, StackFrame } from './error-stack-parser'; | ||
import { stringify } from './stringify'; | ||
import { patch } from '@rrweb/utils'; | ||
|
||
export type StringifyOptions = { | ||
// limit of string length | ||
|
@@ -183,7 +183,7 @@ function initLogObserver( | |
}; | ||
} | ||
// replace the logger.{level}. return a restore function | ||
return utils.patch( | ||
return patch( | ||
_logger, | ||
level, | ||
(original: (...args: Array<unknown>) => void) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
'now you can use replayer.getMirror() to access the mirror instance of a replayer,' + | ||
'\r\n' + | ||
'or you can use record.mirror to access the mirror instance during recording.'; | ||
/** @deprecated */ | ||
Check warning on line 34 in packages/rrweb/src/utils.ts GitHub Actions / ESLint Report Analysispackages/rrweb/src/utils.ts#L34
|
||
export let _mirror: DeprecatedMirror = { | ||
map: {}, | ||
getId() { | ||
|
@@ -115,7 +115,7 @@ | |
set(value) { | ||
// put hooked setter into event loop to avoid of set latency | ||
setTimeout(() => { | ||
d.set!.call(this, value); | ||
}, 0); | ||
if (original && original.set) { | ||
original.set.call(this, value); | ||
|
@@ -126,49 +126,6 @@ | |
return () => hookSetter(target, key, original || {}, true); | ||
} | ||
|
||
// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts | ||
export function patch( | ||
source: { [key: string]: any }, | ||
name: string, | ||
replacement: (...args: unknown[]) => unknown, | ||
): () => void { | ||
try { | ||
if (!(name in source)) { | ||
return () => { | ||
// | ||
}; | ||
} | ||
|
||
const original = source[name] as () => unknown; | ||
const wrapped = replacement(original); | ||
|
||
// Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work | ||
// otherwise it'll throw "TypeError: Object.defineProperties called on non-object" | ||
if (typeof wrapped === 'function') { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
wrapped.prototype = wrapped.prototype || {}; | ||
Object.defineProperties(wrapped, { | ||
__rrweb_original__: { | ||
enumerable: false, | ||
value: original, | ||
}, | ||
}); | ||
} | ||
|
||
source[name] = wrapped; | ||
|
||
return () => { | ||
source[name] = original; | ||
}; | ||
} catch { | ||
return () => { | ||
// | ||
}; | ||
// This can throw if multiple fill happens on a global object like XMLHttpRequest | ||
// Fixes https://github.com/getsentry/sentry-javascript/issues/2043 | ||
} | ||
} | ||
|
||
// guard against old third party libraries which redefine Date.now | ||
let nowTimestamp = Date.now; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've lost track of the number of times these bundle visualisers have come in useful for me