From 2484ba4f0561bf337611f5f4aa28e262bf3fb5e0 Mon Sep 17 00:00:00 2001 From: JoostK Date: Mon, 16 Nov 2020 18:10:29 +0100 Subject: [PATCH] refactor(compiler-cli): prepare linker options for compilation of components (#39707) This commit adds the `i18nUseExternalIds` option to the linker options, as the compliance tests exercise compilation results with and without this flag enabled. We therefore need to configure the linker to take this option into account, as otherwise the compliance test output would not be identical. Additionally, this commit switches away from spread syntax to set the default options. This introduced a problem when the user-provided options object did specify the keys, but with an undefined value. This would have prevented the default options from being applied. PR Close #39707 --- .../linker/src/file_linker/linker_environment.ts | 8 +++++++- .../compiler-cli/linker/src/file_linker/linker_options.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/compiler-cli/linker/src/file_linker/linker_environment.ts b/packages/compiler-cli/linker/src/file_linker/linker_environment.ts index c8024dc8a1..ff1401b028 100644 --- a/packages/compiler-cli/linker/src/file_linker/linker_environment.ts +++ b/packages/compiler-cli/linker/src/file_linker/linker_environment.ts @@ -20,6 +20,12 @@ export class LinkerEnvironment { static create( host: AstHost, factory: AstFactory, options: Partial): LinkerEnvironment { - return new LinkerEnvironment(host, factory, {...DEFAULT_LINKER_OPTIONS, ...options}); + return new LinkerEnvironment(host, factory, { + enableI18nLegacyMessageIdFormat: options.enableI18nLegacyMessageIdFormat ?? + DEFAULT_LINKER_OPTIONS.enableI18nLegacyMessageIdFormat, + i18nNormalizeLineEndingsInICUs: options.i18nNormalizeLineEndingsInICUs ?? + DEFAULT_LINKER_OPTIONS.i18nNormalizeLineEndingsInICUs, + i18nUseExternalIds: options.i18nUseExternalIds ?? DEFAULT_LINKER_OPTIONS.i18nUseExternalIds, + }); } } diff --git a/packages/compiler-cli/linker/src/file_linker/linker_options.ts b/packages/compiler-cli/linker/src/file_linker/linker_options.ts index d76de5b577..9c4d8feed0 100644 --- a/packages/compiler-cli/linker/src/file_linker/linker_options.ts +++ b/packages/compiler-cli/linker/src/file_linker/linker_options.ts @@ -20,6 +20,13 @@ export interface LinkerOptions { * The default is `false`. */ i18nNormalizeLineEndingsInICUs: boolean; + + /** + * Whether translation variable name should contain external message id + * (used by Closure Compiler's output of `goog.getMsg` for transition period) + * The default is `false`. + */ + i18nUseExternalIds: boolean; } /** @@ -28,4 +35,5 @@ export interface LinkerOptions { export const DEFAULT_LINKER_OPTIONS: LinkerOptions = { enableI18nLegacyMessageIdFormat: true, i18nNormalizeLineEndingsInICUs: false, + i18nUseExternalIds: false, };