Skip to content
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(core): update isDevMode to rely on ngDevMode #47475

Closed

Conversation

alan-agius4
Copy link
Contributor

@alan-agius4 alan-agius4 commented Sep 19, 2022

This commits update isDevMode to rely on the ngDevMode which in the CLI is set by the bundler.

We also update @angular/platform-dynamic-browser and @angular/compiler to remove usage of jitDevMode, which was the last internal usages of isDevMode.

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Sep 19, 2022
@pkozlowski-opensource
Copy link
Member

We've discussed this on the fwk side in the past and I believe that this would be breaking change. Adding a label accordingly.

@alan-agius4
Copy link
Contributor Author

alan-agius4 commented Sep 19, 2022

@pkozlowski-opensource why would this be a breaking change?

Calling enableProdMode sets ngDevMode to false. So, what causes the breaking behaviour? The framework doesn't use the isDevMode method.

@alan-agius4 alan-agius4 added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Sep 19, 2022
@pkozlowski-opensource
Copy link
Member

The framework doesn't use the isDevMode method.

@alan-agius4 the framework does not, but the existing libraries might (and probably do).

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

It'd be great to add some additional docs for the isDevMode and enableProdMode functions to explain where the value is coming from and what'd be the best way to change it (via CLI flags vs enabling at runtime).

packages/core/src/util/is_dev_mode.ts Outdated Show resolved Hide resolved
packages/core/src/util/is_dev_mode.ts Show resolved Hide resolved
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed breaking changes action: merge The PR is ready for merge by the caretaker labels Sep 22, 2022
This commits update `isDevMode` to rely on the `ngDevMode` which in the CLI is set by the bundler.

We also update `@angular/platform-dynamic-browser` and `@angular/compiler` to remove usage of `jitDevMode`, with this change we remove all internal usages of `isDevMode`.
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Sep 23, 2022
@alxhub
Copy link
Member

alxhub commented Sep 23, 2022

This PR was merged into the repository by commit 85330f3.

@alxhub alxhub closed this in 85330f3 Sep 23, 2022
@alan-agius4 alan-agius4 deleted the dev-mode-platform-server branch September 23, 2022 20:59
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Sep 27, 2022
This commits update `isDevMode` to rely on the `ngDevMode` which in the CLI is set by the bundler.

We also update `@angular/platform-dynamic-browser` and `@angular/compiler` to remove usage of `jitDevMode`, with this change we remove all internal usages of `isDevMode`.

PR Close angular#47475
Comment on lines 20 to 22
export function isDevMode(): boolean {
_runModeLocked = true;
return _devMode;
return typeof ngDevMode === 'undefined' || !!ngDevMode;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @alan-agius4. I have a question, so to better understand:
Now isDevMode() explicitly depends on ngDevMode. Does it by any chance help to tree-shake code in custom applications, that is conditionally wrapped with isDevMode()? e.g.

if(isDevMode()){ 
   console.error('Some very long string message in custom app....');
}

If not, would it help to expose ngDevMode in Angular public API, so it could be used it in custom applications?

if(ngDevMode){ 
   console.error('Some very long string message in custom app....');
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested this isDevMode(). It doesn't help tree-shake code.

Screenshot 2022-09-29 at 12 29 55 PM

Screenshot 2022-09-29 at 12 30 09 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this does not aid tree-shaking.

ngDevMode is still considered as a private API, but we do have a project to make this available as a public API.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants