-
Notifications
You must be signed in to change notification settings - Fork 6.8k
perf: allow assertions to be removed in production mode #20146
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
cf1e243 to
8f3416b
Compare
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.
Overall looks good, I'll do a preliminary presubmit. FWIW, I probably would have preferred to make this change in smaller parts.
|
Changed to |
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.
LGTM. One question about View Engine support.
| const correspondingDropList = CdkDropList._dropLists.find(list => list.id === drop); | ||
|
|
||
| if (!correspondingDropList && isDevMode()) { | ||
| if (!correspondingDropList && (typeof ngDevMode === 'undefined' || ngDevMode)) { |
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.
Does removing isDevMode() mean that View Engine apps will have warnings/errors as in dev mode? It looks like View Engine enableProdMode does not set ngDevMode at all. Maybe it should?
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.
Ah, I assumed that it would. We would need to fix that since we still need to report these issues in ViewEngine.
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 believe that enableProdMode doesn't set the variable, because it's supposed to be replaced during build time. I don't think that this will be an issue for ViewEngine apps, because the majority of the current checks were running in production too. We have a handful of isDevMode ones, but they're sanity checks so it wouldn't really be a problem if they ran in production. The only one that may be a problem is the theme check in the common module since it has a getComputedStyle call so I'll add an exception for it.
cbfcffc to
643217b
Compare
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.
LGTM
Caretaker note: let's be sure to test this explicitly in an internal app to make sure the warnings are still logged as expected
|
Caretaker note: hold off on merging this until Aug 17th so we can make a heads up announcement internally |
|
@crisbeto would you mind rebasing? I want to peek at how much this reduces bundle size by |
|
Re-rebased to fix the test failures. |
src/material/sidenav/drawer.ts
Outdated
| if (drawer.position == 'end') { | ||
| if (this._end != null) { | ||
| throwMatDuplicatedDrawerError('end'); | ||
| if (typeof ngDevMode === 'undefined' || ngDevMode) { |
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.
@crisbeto just noticed this one is actually gating actual behavior for the component (setting this._end or this._start)
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.
ops, good catch. Fixed, although it does reveal that if we have some faulty logic, our tests won't catch it since they're only being run in dev mode.
|
Also I tested our internal component gallery app with this and it reduced the production bundle size by 4620 bytes. |
ac96786 to
1ea40c8
Compare
Wraps all assertions in `ngDevMode` checks so that they can be stripped away in production mode. Furthermore, changes all the places where we were using the old `isDevMode` check.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Wraps all assertions in
ngDevModechecks so that they can be stripped away in production mode. Furthermore, changes all the places where we were using the oldisDevModecheck.