Repository navigation
feat(@angular-devkit/build-angular): remove Closure compiler i18n code for ivy - #13905
Conversation
…e for ivy For runtime i18n with ivy we generate code for both Closure compiler (used at Google) and for external people that don't use Closure compiler. We added a new global flag named `ngI18nClosureMode` that allows uglify (and Closure compiler) to effectively tree-shake all of the code that isn't used in the current setup. By default we remove all of the Closure compiler code because we assume that it won't be used.
| compress: (buildOptions.platform == 'server' ? { | ||
| global_defs: { | ||
| ngDevMode: false, | ||
| ngI18nClosureMode: false, |
There was a problem hiding this comment.
What happens if this isn't added? Are bundles bigger or are they broken?
There was a problem hiding this comment.
just bigger (it breaks the integration test on angular right now because the size diff is >1%, but other than that everything works)
There was a problem hiding this comment.
For how long is this flag expected to be around? Is it part of the necessary tooling for Ivy in general, or is it expected to not be necessary after a certain version?
There was a problem hiding this comment.
@filipesilva ngI18nClosureMode will be around for as long as we want to support goog.getMsg. The reason we need this is because we generate
let greeting;
if (ngI18nClosureMode) {
const MSG_greeting = goog.getMsg('Hello');
} else {
greeting = localize`Hello`;
}
We need to generate the above because we need to ship the code in the above format to NPM so that developers which download a 3P library can choose to compile it with closure or without.
Come to think of it both ngDevMode and ngI18nClosureMode need to be defined only for the final application but NOT for library compilations. We want to make sure that when we ship things into NPM ngDevMode and ngI18nClosureMode are preserved in the source code, because it is only the application developer who can make a choice if they are building a debug build or production and if they are using goog.getMsg or something else.
What is the current best practice for building an angular library? Would the above settings apply? If so can we have a different pass for libraries which do not set these values?
There was a problem hiding this comment.
Libraries use a separate pipeline. This one is just for apps.
| compress: (buildOptions.platform == 'server' ? { | ||
| global_defs: { | ||
| ngDevMode: false, | ||
| ngI18nClosureMode: false, |
There was a problem hiding this comment.
@filipesilva ngI18nClosureMode will be around for as long as we want to support goog.getMsg. The reason we need this is because we generate
let greeting;
if (ngI18nClosureMode) {
const MSG_greeting = goog.getMsg('Hello');
} else {
greeting = localize`Hello`;
}
We need to generate the above because we need to ship the code in the above format to NPM so that developers which download a 3P library can choose to compile it with closure or without.
Come to think of it both ngDevMode and ngI18nClosureMode need to be defined only for the final application but NOT for library compilations. We want to make sure that when we ship things into NPM ngDevMode and ngI18nClosureMode are preserved in the source code, because it is only the application developer who can make a choice if they are building a debug build or production and if they are using goog.getMsg or something else.
What is the current best practice for building an angular library? Would the above settings apply? If so can we have a different pass for libraries which do not set these values?
|
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. |
For runtime i18n with ivy we generate code for both Closure compiler (used at Google) and for external people that don't use Closure compiler.
We added a new global flag named
ngI18nClosureModethat allows uglify (and Closure compiler) to effectively tree-shake all of the code that isn't used in the current setup.By default we remove all of the Closure compiler code because we assume that it won't be used.
Required for angular/angular#28689.