angular-cn/packages/compiler-cli/test/compliance
Andrew Kushnir cb05c0102f fix(core): move generated i18n statements to the `consts` field of ComponentDef (#38404)
This commit updates the code to move generated i18n statements into the `consts` field of
ComponentDef to avoid invoking `$localize` function before component initialization (to better
support runtime translations) and also avoid problems with lazy-loading when i18n defs may not
be present in a chunk where it's referenced.

Prior to this change the i18n statements were generated at the top leve:

```
var I18N_0;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
    var MSG_X = goog.getMsg(“…”);
    I18N_0 = MSG_X;
} else {
    I18N_0 = $localize('...');
}

defineComponent({
    // ...
    template: function App_Template(rf, ctx) {
        i0.ɵɵi18n(2, I18N_0);
    }
});
```

This commit updates the logic to generate the following code instead:

```
defineComponent({
    // ...
    consts: function() {
        var I18N_0;
        if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            var MSG_X = goog.getMsg(“…”);
            I18N_0 = MSG_X;
        } else {
            I18N_0 = $localize('...');
        }
        return [
            I18N_0
        ];
    },
    template: function App_Template(rf, ctx) {
        i0.ɵɵi18n(2, 0);
    }
});
```

Also note that i18n template instructions now refer to the `consts` array using an index
(similar to other template instructions).

PR Close #38404
2020-08-17 10:13:57 -07:00
..
BUILD.bazel test: handle bootstrap templated_args in jasmine_node_test defaults.bzl (#34736) 2020-01-15 14:58:07 -05:00
README.md build: migrate references and scripts that set to build with ivy via compile=aot to use config=ivy (#33983) 2019-11-26 16:38:40 -05:00
mock_compile.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
mock_compiler_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_compiler_compliance_spec.ts refactor(core): rename synthetic host property and listener instructions (#37145) 2020-07-21 09:09:24 -07:00
r3_view_compiler_binding_spec.ts fix(compiler): evaluate safe navigation expressions in correct binding order (#37911) 2020-08-11 09:51:10 -07:00
r3_view_compiler_di_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_view_compiler_directives_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_view_compiler_i18n_spec.ts fix(core): move generated i18n statements to the `consts` field of ComponentDef (#38404) 2020-08-17 10:13:57 -07:00
r3_view_compiler_input_outputs_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_view_compiler_listener_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_view_compiler_providers_spec.ts build: update to typescript 3.9.5 (#37456) 2020-06-11 12:05:33 -07:00
r3_view_compiler_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_view_compiler_styling_spec.ts refactor(core): rename synthetic host property and listener instructions (#37145) 2020-07-21 09:09:24 -07:00
r3_view_compiler_template_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00

README.md

Tests in this directory should be run with:

yarn bazel test --config=ivy  packages/compiler-cli/test/compliance:compliance