diff --git a/packages/compiler-cli/ngcc/src/main.ts b/packages/compiler-cli/ngcc/src/main.ts index 9faf4f3c44..8f510da12d 100644 --- a/packages/compiler-cli/ngcc/src/main.ts +++ b/packages/compiler-cli/ngcc/src/main.ts @@ -80,7 +80,7 @@ export function mainNgcc({baseSourcePath, targetEntryPointPath, propertiesToCons compiledFormats.size === 0); if (bundle) { console.warn(`Compiling ${entryPoint.name} : ${property} as ${format}`); - transformer.transform(entryPoint, isCore, bundle); + transformer.transform(bundle); compiledFormats.add(formatPath); } else { console.warn( diff --git a/packages/compiler-cli/ngcc/src/packages/entry_point_bundle.ts b/packages/compiler-cli/ngcc/src/packages/entry_point_bundle.ts index b04dd3e205..a911b39909 100644 --- a/packages/compiler-cli/ngcc/src/packages/entry_point_bundle.ts +++ b/packages/compiler-cli/ngcc/src/packages/entry_point_bundle.ts @@ -20,6 +20,7 @@ import {EntryPointFormat} from './entry_point'; */ export interface EntryPointBundle { format: EntryPointFormat; + isCore: boolean; isFlatCore: boolean; rootDirs: AbsoluteFsPath[]; src: BundleProgram; @@ -56,5 +57,5 @@ export function makeEntryPointBundle( null; const isFlatCore = isCore && src.r3SymbolsFile === null; - return {format, rootDirs, isFlatCore, src, dts}; + return {format, rootDirs, isCore, isFlatCore, src, dts}; } diff --git a/packages/compiler-cli/ngcc/src/packages/transformer.ts b/packages/compiler-cli/ngcc/src/packages/transformer.ts index 587daa994c..2a24ed0759 100644 --- a/packages/compiler-cli/ngcc/src/packages/transformer.ts +++ b/packages/compiler-cli/ngcc/src/packages/transformer.ts @@ -55,7 +55,8 @@ export class Transformer { * Transform the source (and typings) files of a bundle. * @param bundle the bundle to transform. */ - transform(entryPoint: EntryPoint, isCore: boolean, bundle: EntryPointBundle): void { + transform(bundle: EntryPointBundle): void { + const isCore = bundle.isCore; const reflectionHost = this.getHost(isCore, bundle); // Parse and analyze the files. diff --git a/packages/compiler-cli/ngcc/test/helpers/utils.ts b/packages/compiler-cli/ngcc/test/helpers/utils.ts index 464b4af515..4e06fe32dd 100644 --- a/packages/compiler-cli/ngcc/test/helpers/utils.ts +++ b/packages/compiler-cli/ngcc/test/helpers/utils.ts @@ -22,12 +22,13 @@ export {getDeclaration} from '../../../src/ngtsc/testing/in_memory_typescript'; * @param dtsFiles The typings files to include the bundle. */ export function makeTestEntryPointBundle( - format: EntryPointFormat, files: {name: string, contents: string, isRoot?: boolean}[], + format: EntryPointFormat, isCore: boolean, + files: {name: string, contents: string, isRoot?: boolean}[], dtsFiles?: {name: string, contents: string, isRoot?: boolean}[]): EntryPointBundle { const src = makeTestBundleProgram(files); const dts = dtsFiles ? makeTestBundleProgram(dtsFiles) : null; - const isFlatCore = src.r3SymbolsFile === null; - return {format, rootDirs: [AbsoluteFsPath.fromUnchecked('/')], src, dts, isFlatCore}; + const isFlatCore = isCore && src.r3SymbolsFile === null; + return {format, rootDirs: [AbsoluteFsPath.fromUnchecked('/')], src, dts, isCore, isFlatCore}; } /** diff --git a/packages/compiler-cli/ngcc/test/rendering/esm2015_renderer_spec.ts b/packages/compiler-cli/ngcc/test/rendering/esm2015_renderer_spec.ts index 24b0ee0b67..52c35f6af0 100644 --- a/packages/compiler-cli/ngcc/test/rendering/esm2015_renderer_spec.ts +++ b/packages/compiler-cli/ngcc/test/rendering/esm2015_renderer_spec.ts @@ -18,7 +18,7 @@ import {makeTestEntryPointBundle} from '../helpers/utils'; function setup(file: {name: string, contents: string}) { const dir = dirname(file.name); - const bundle = makeTestEntryPointBundle('esm2015', [file]) !; + const bundle = makeTestEntryPointBundle('esm2015', false, [file]) !; const typeChecker = bundle.src.program.getTypeChecker(); const host = new Esm2015ReflectionHost(false, typeChecker); const referencesRegistry = new NgccReferencesRegistry(host); diff --git a/packages/compiler-cli/ngcc/test/rendering/esm5_renderer_spec.ts b/packages/compiler-cli/ngcc/test/rendering/esm5_renderer_spec.ts index 338fd2e21a..b87ef4e3f9 100644 --- a/packages/compiler-cli/ngcc/test/rendering/esm5_renderer_spec.ts +++ b/packages/compiler-cli/ngcc/test/rendering/esm5_renderer_spec.ts @@ -18,7 +18,7 @@ import {makeTestEntryPointBundle, getDeclaration} from '../helpers/utils'; function setup(file: {name: string, contents: string}) { const dir = dirname(file.name); - const bundle = makeTestEntryPointBundle('esm5', [file]); + const bundle = makeTestEntryPointBundle('esm5', false, [file]); const typeChecker = bundle.src.program.getTypeChecker(); const host = new Esm5ReflectionHost(false, typeChecker); const referencesRegistry = new NgccReferencesRegistry(host); diff --git a/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts b/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts index dd03dee87b..dd68f21e6f 100644 --- a/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts +++ b/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts @@ -50,7 +50,7 @@ function createTestRenderer( packageName: string, files: {name: string, contents: string}[], dtsFiles?: {name: string, contents: string}[]) { const isCore = packageName === '@angular/core'; - const bundle = makeTestEntryPointBundle('esm2015', files, dtsFiles); + const bundle = makeTestEntryPointBundle('esm2015', isCore, files, dtsFiles); const typeChecker = bundle.src.program.getTypeChecker(); const host = new Esm2015ReflectionHost(isCore, typeChecker, bundle.dts); const referencesRegistry = new NgccReferencesRegistry(host);