angular-docs-cn/packages/compiler/src
Pete Bacon Darwin 70dd27ffd8 fix(compiler): normalize line endings in ICU expansions (#36741)
The html parser already normalizes line endings (converting `\r\n` to `\n`)
for most text in templates but it was missing the expressions of ICU expansions.

In ViewEngine backticked literal strings, used to define inline templates,
were already normalized by the TypeScript parser.
In Ivy we are parsing the raw text of the source file directly so the line
endings need to be manually normalized.

This change ensures that inline templates have the line endings of ICU
expression normalized correctly, which matches the ViewEngine.

In ViewEngine external templates, defined in HTML files, the behavior was
different, since TypeScript was not normalizing the line endings.
Specifically, ICU expansion "expressions" are not being normalized.
This is a problem because it means that i18n message ids can be different on
different machines that are setup with different line ending handling,
or if the developer moves a template from inline to external or vice versa.

The goal is always to normalize line endings, whether inline or external.
But this would be a breaking change since it would change i18n message ids
that have been previously computed. Therefore this commit aligns the ivy
template parsing to have the same "buggy" behavior for external templates.

There is now a compiler option `i18nNormalizeLineEndingsInICUs`, which
if set to `true` will ensure the correct non-buggy behavior. For the time
being this option defaults to `false` to ensure backward compatibility while
allowing opt-in to the desired behavior. This option's default will be
flipped in a future breaking change release.

Further, when this option is set to `false`, any ICU expression tokens,
which have not been normalized, are added to the `ParseResult` from the
`HtmlParser.parse()` method. In the future, this collection of tokens could
be used to diagnose and encourage developers to migrate their i18n message
ids. See FW-2106.

Closes #36725

PR Close #36741
2020-04-28 12:22:40 -07:00
..
aot style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
compiler_util style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
css_parser style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
expression_parser style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
i18n style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
jit style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
ml_parser fix(compiler): normalize line endings in ICU expansions (#36741) 2020-04-28 12:22:40 -07:00
output style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
render3 fix(compiler): normalize line endings in ICU expansions (#36741) 2020-04-28 12:22:40 -07:00
schema style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
template_parser refactor(compiler): tighten type of `TemplateParser._console` (#36741) 2020-04-28 12:22:39 -07:00
view_compiler style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
assertions.ts refactor(compiler): rename INTERPOLATION_BLACKLIST_REGEXPS (#29593) 2019-04-02 10:36:26 -07:00
ast_path.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
chars.ts feat(compiler): support tokenizing escaped strings (#28055) 2019-02-12 20:58:27 -08:00
compile_metadata.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
compile_reflector.ts feat(ivy): @NgModule -> ngInjectorDef compilation (#22458) 2018-03-16 12:57:11 -07:00
compiler.ts fix(ivy): move setClassMetadata calls into a pure iife (#33337) 2019-11-20 12:55:58 -08:00
compiler_facade_interface.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
config.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
constant_pool.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
core.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
directive_normalizer.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
directive_resolver.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
identifiers.ts refactor(ivy): generate ngFactoryDef for injectables (#32433) 2019-10-02 13:04:26 -07:00
injectable_compiler.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
injectable_compiler_2.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
jit_compiler_facade.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
lifecycle_reflector.ts feat(ivy): implement TestBed (#25369) 2018-08-14 11:58:47 -07:00
metadata_resolver.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
ng_module_compiler.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
ng_module_resolver.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
parse_util.ts fix(compiler-cli): pass real source spans where they are empty (#31805) 2020-04-06 09:28:27 -07:00
pipe_resolver.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
provider_analyzer.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
resource_loader.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
selector.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
shadow_css.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
style_compiler.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
style_url_resolver.ts fix(compiler): Don't strip CSS source maps 2017-08-15 16:30:09 -07:00
summary_resolver.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
url_resolver.ts style(compiler): reformat of codebase with new clang-format version (#36520) 2020-04-08 14:51:08 -07:00
util.ts fix(compiler): avoid generating i18n attributes in plain form (#36422) 2020-04-16 09:44:10 -07:00
version.ts style: remove empty comments (#23404) 2018-05-10 15:48:13 -07:00