-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: provide guidance in browser console when logging $state
objects
#13142
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
Conversation
Wrap console.log/warn/error statements in DEV mode with a check whether or not they contain state objects. Closes #13123 This is an alternative or enhancement to #13070. Alternative if we deem it the better solution. Enhancement because it's not as robust as a custom formatter: We only check the top level of each entry (though we could maybe traverse a few levels), and if you're logging class instances, snapshot currently stops at the boundaries there and so you don't get snapshotted values for these (arguably this is a more general problem of $inspect and $state.snapshot), whereas with custom formatter it doesn't matter at which level you come across it.
🦋 Changeset detectedLatest commit: ec9ea5d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I think we need this in addition to the formatter as for many people that use Chrome, the experience of using the formatter will exceed the experience of anything else. This can serve as a nice fallback for those on Safari. |
@dummdidumm |
untrack the whole function See #13142 (comment)
* fix: ensure snapshot logs don't affect dependency graph untrack the whole function See #13142 (comment) * try-catch * appease eslint --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
Wrap console.log/warn/error statements in DEV mode with a check whether or not they contain state objects. Closes #13123
This is an alternative or enhancement to #13070. Alternative if we deem it the better solution. Enhancement because it's not as robust as a custom formatter: We only check the top level of each entry (though we could maybe traverse a few levels), and if you're logging class instances, snapshot currently stops at the boundaries there and so you don't get snapshotted values for these (arguably this is a more general problem of $inspect and $state.snapshot), whereas with custom formatter it doesn't matter at which level you come across it.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint