refactor(ngcc): store whether to render legacy i18n message ids in the bundle (#34135)
Placing this configuration in to the bundle avoids having to pass the value around through lots of function calls, but also could enable support for different behaviour per bundle in the future. PR Close #34135
This commit is contained in:
parent
e524322c43
commit
cebe49d3c9
|
@ -16,7 +16,7 @@ import {CompoundMetadataReader, CompoundMetadataRegistry, DtsMetadataReader, Loc
|
||||||
import {PartialEvaluator} from '../../../src/ngtsc/partial_evaluator';
|
import {PartialEvaluator} from '../../../src/ngtsc/partial_evaluator';
|
||||||
import {ClassDeclaration} from '../../../src/ngtsc/reflection';
|
import {ClassDeclaration} from '../../../src/ngtsc/reflection';
|
||||||
import {LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from '../../../src/ngtsc/scope';
|
import {LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from '../../../src/ngtsc/scope';
|
||||||
import {CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence} from '../../../src/ngtsc/transform';
|
import {CompileResult, DecoratorHandler} from '../../../src/ngtsc/transform';
|
||||||
import {NgccClassSymbol, NgccReflectionHost} from '../host/ngcc_host';
|
import {NgccClassSymbol, NgccReflectionHost} from '../host/ngcc_host';
|
||||||
import {Migration} from '../migrations/migration';
|
import {Migration} from '../migrations/migration';
|
||||||
import {MissingInjectableMigration} from '../migrations/missing_injectable_migration';
|
import {MissingInjectableMigration} from '../migrations/missing_injectable_migration';
|
||||||
|
@ -88,8 +88,8 @@ export class DecorationAnalyzer {
|
||||||
this.reflectionHost, this.evaluator, this.fullRegistry, this.fullMetaReader,
|
this.reflectionHost, this.evaluator, this.fullRegistry, this.fullMetaReader,
|
||||||
this.scopeRegistry, this.scopeRegistry, this.isCore, this.resourceManager, this.rootDirs,
|
this.scopeRegistry, this.scopeRegistry, this.isCore, this.resourceManager, this.rootDirs,
|
||||||
/* defaultPreserveWhitespaces */ false,
|
/* defaultPreserveWhitespaces */ false,
|
||||||
/* i18nUseExternalIds */ true, /* i18nLegacyMessageIdFormat */ '', this.moduleResolver,
|
/* i18nUseExternalIds */ true, this.bundle.enableI18nLegacyMessageIdFormat,
|
||||||
this.cycleAnalyzer, this.refEmitter, NOOP_DEFAULT_IMPORT_RECORDER,
|
this.moduleResolver, this.cycleAnalyzer, this.refEmitter, NOOP_DEFAULT_IMPORT_RECORDER,
|
||||||
/* annotateForClosureCompiler */ false),
|
/* annotateForClosureCompiler */ false),
|
||||||
new DirectiveDecoratorHandler(
|
new DirectiveDecoratorHandler(
|
||||||
this.reflectionHost, this.evaluator, this.fullRegistry, NOOP_DEFAULT_IMPORT_RECORDER,
|
this.reflectionHost, this.evaluator, this.fullRegistry, NOOP_DEFAULT_IMPORT_RECORDER,
|
||||||
|
|
|
@ -241,7 +241,8 @@ export function mainNgcc(
|
||||||
}
|
}
|
||||||
|
|
||||||
const bundle = makeEntryPointBundle(
|
const bundle = makeEntryPointBundle(
|
||||||
fileSystem, entryPoint, formatPath, isCore, format, processDts, pathMappings, true);
|
fileSystem, entryPoint, formatPath, isCore, format, processDts, pathMappings, true,
|
||||||
|
false);
|
||||||
|
|
||||||
logger.info(`Compiling ${entryPoint.name} : ${formatProperty} as ${format}`);
|
logger.info(`Compiling ${entryPoint.name} : ${formatProperty} as ${format}`);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ export interface EntryPointBundle {
|
||||||
rootDirs: AbsoluteFsPath[];
|
rootDirs: AbsoluteFsPath[];
|
||||||
src: BundleProgram;
|
src: BundleProgram;
|
||||||
dts: BundleProgram|null;
|
dts: BundleProgram|null;
|
||||||
|
enableI18nLegacyMessageIdFormat: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,11 +38,14 @@ export interface EntryPointBundle {
|
||||||
* @param pathMappings An optional set of mappings to use when compiling files.
|
* @param pathMappings An optional set of mappings to use when compiling files.
|
||||||
* @param mirrorDtsFromSrc If true then the `dts` program will contain additional files that
|
* @param mirrorDtsFromSrc If true then the `dts` program will contain additional files that
|
||||||
* were guessed by mapping the `src` files to `dts` files.
|
* were guessed by mapping the `src` files to `dts` files.
|
||||||
|
* @param enableI18nLegacyMessageIdFormat Whether to render legacy message ids for i18n messages in
|
||||||
|
* component templates.
|
||||||
*/
|
*/
|
||||||
export function makeEntryPointBundle(
|
export function makeEntryPointBundle(
|
||||||
fs: FileSystem, entryPoint: EntryPoint, formatPath: string, isCore: boolean,
|
fs: FileSystem, entryPoint: EntryPoint, formatPath: string, isCore: boolean,
|
||||||
format: EntryPointFormat, transformDts: boolean, pathMappings?: PathMappings,
|
format: EntryPointFormat, transformDts: boolean, pathMappings?: PathMappings,
|
||||||
mirrorDtsFromSrc: boolean = false): EntryPointBundle {
|
mirrorDtsFromSrc: boolean = false,
|
||||||
|
enableI18nLegacyMessageIdFormat: boolean = true): EntryPointBundle {
|
||||||
// Create the TS program and necessary helpers.
|
// Create the TS program and necessary helpers.
|
||||||
const options: ts.CompilerOptions = {
|
const options: ts.CompilerOptions = {
|
||||||
allowJs: true,
|
allowJs: true,
|
||||||
|
@ -67,7 +71,8 @@ export function makeEntryPointBundle(
|
||||||
null;
|
null;
|
||||||
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
||||||
|
|
||||||
return {entryPoint, format, rootDirs, isCore, isFlatCore, src, dts};
|
return {entryPoint, format, rootDirs, isCore,
|
||||||
|
isFlatCore, src, dts, enableI18nLegacyMessageIdFormat};
|
||||||
}
|
}
|
||||||
|
|
||||||
function computePotentialDtsFilesFromJsFiles(
|
function computePotentialDtsFilesFromJsFiles(
|
||||||
|
|
|
@ -39,13 +39,18 @@ export function makeTestEntryPoint(
|
||||||
*/
|
*/
|
||||||
export function makeTestEntryPointBundle(
|
export function makeTestEntryPointBundle(
|
||||||
packageName: string, format: EntryPointFormat, isCore: boolean, srcRootNames: AbsoluteFsPath[],
|
packageName: string, format: EntryPointFormat, isCore: boolean, srcRootNames: AbsoluteFsPath[],
|
||||||
dtsRootNames?: AbsoluteFsPath[], config?: TestConfig): EntryPointBundle {
|
dtsRootNames?: AbsoluteFsPath[], config?: TestConfig,
|
||||||
|
enableI18nLegacyMessageIdFormat = false): EntryPointBundle {
|
||||||
const entryPoint = makeTestEntryPoint(packageName, packageName, config);
|
const entryPoint = makeTestEntryPoint(packageName, packageName, config);
|
||||||
const src = makeTestBundleProgram(srcRootNames[0], isCore);
|
const src = makeTestBundleProgram(srcRootNames[0], isCore);
|
||||||
const dts =
|
const dts =
|
||||||
dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], entryPoint.package, isCore) : null;
|
dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], entryPoint.package, isCore) : null;
|
||||||
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
||||||
return {entryPoint, format, rootDirs: [absoluteFrom('/')], src, dts, isCore, isFlatCore};
|
return {
|
||||||
|
entryPoint,
|
||||||
|
format,
|
||||||
|
rootDirs: [absoluteFrom('/')], src, dts, isCore, isFlatCore, enableI18nLegacyMessageIdFormat
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeTestBundleProgram(
|
export function makeTestBundleProgram(
|
||||||
|
|
Loading…
Reference in New Issue