-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
disable debug names in production builds #2780
Conversation
🦋 Changeset detectedLatest commit: 9b00a94 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 |
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.
Thanks for looking into this. Looks awesome! Small request for changes as I think the mapid_
can probably be dropped entirely (or it is used somewhere, and in that case I'm not sure the change is safe)
@@ -88,7 +88,7 @@ export class ComputedValue<T> implements IObservable, IComputedValue<T>, IDeriva | |||
lastAccessedBy_ = 0 | |||
lowestObserverState_ = IDerivationState_.UP_TO_DATE_ | |||
unboundDepsCount_ = 0 | |||
mapid_ = "#" + getNextId() | |||
mapid_ = __DEV__ ? "#" + getNextId() : "#" |
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.
Looking at this one, it seems that mapid_
is used nowhere. Feel free to drop it entirely if that still passes the test
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.
If we delete mapid_ directly, The Unit Tests will be failed.
- keep it
- delete it and
jest --updateSnapshot
Choice which one ? Sir.
packages/mobx/src/core/reaction.ts
Outdated
@@ -57,15 +57,15 @@ export class Reaction implements IDerivation, IReactionPublic { | |||
diffValue_ = 0 | |||
runId_ = 0 | |||
unboundDepsCount_ = 0 | |||
mapid_ = "#" + getNextId() | |||
mapid_ = __DEV__ ? "#" + getNextId() : "#" |
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.
Same (probably the IDerivation interface needs to adapted as well)
2 😊
…On Sat, 6 Feb 2021, 14:23 ChenLei, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/mobx/src/core/computedvalue.ts
<#2780 (comment)>:
> @@ -88,7 +88,7 @@ export class ComputedValue<T> implements IObservable, IComputedValue<T>, IDeriva
lastAccessedBy_ = 0
lowestObserverState_ = IDerivationState_.UP_TO_DATE_
unboundDepsCount_ = 0
- mapid_ = "#" + getNextId()
+ mapid_ = __DEV__ ? "#" + getNextId() : "#"
If we delete mapid_ directly, The Unit Tests will be failed.
1. keep it
2. delete it and jest --updateSnapshot
Choice which one ? Sir.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2780 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBDM5ONCKUUAZZMMPV3S5VGHLANCNFSM4XCYDEKA>
.
|
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.
Looking great! Thanks for making these changes. As a really nit you might want to mention in the changelog that it will reduce memory usage of MobX in production builds, which is why some projects might be interested in upgrading :)
Fun, |
That's funny, I was a sophomore college student in 2016, after 5 years I delete it. hah O(∩_∩)O~~ |
So you means add |
|
Publishing older versions has to be done manually. I don't think this change can be classified as "critical bugfix". It's not worth the hassle imo and as Michel said, people might be at least motivated to upgrade to V6 which is our goal here. |
Ok , I got it. 😄 |
@iChenLei yes that was about the changeset indeed :) |
@iChenLei Perhaps be more explicit in the changeset and mention the removal of |
Thanks, let's merge. |
Is it an intention to pass |
Code change checklist
/docs
. For new functionality, at leastAPI.md
should be updatednpm run perf
)PR Background
reopen pr for #2748
Sumaary
Why not just add
__DEV__
forgetNextId()
getNextId()
is default debugnames gen util, and most time we will create newAtom
,ObservableValue
withname
constructor params, so it also create manycancatenated string
andstring
in JS Heap.(more details -> #2737Run simple benchmark
This is JS Heap compare between different logic process.
If we only deal with
getNextId()
, not optimized enough .@mweststrate Need your code review, maybe I missing something. Thank you, sir 😄