diff --git a/packages/compiler-cli/src/ngcc/src/packages/entry_point.ts b/packages/compiler-cli/src/ngcc/src/packages/entry_point.ts index 78465318c9..af2a5e6fc4 100644 --- a/packages/compiler-cli/src/ngcc/src/packages/entry_point.ts +++ b/packages/compiler-cli/src/ngcc/src/packages/entry_point.ts @@ -27,6 +27,8 @@ export type EntryPointPaths = { * to each of the possible entry-point formats. */ export type EntryPoint = EntryPointPaths & { + /** The name of the package (e.g. `@angular/core`). */ + name: string; /** The path to the package that contains this entry-point. */ package: string; /** The path to this entry point. */ @@ -36,6 +38,7 @@ export type EntryPoint = EntryPointPaths & { }; interface EntryPointPackageJson { + name: string; fesm2015?: string; fesm5?: string; esm2015?: string; @@ -59,8 +62,8 @@ export function getEntryPointInfo(pkgPath: string, entryPoint: string): EntryPoi // According to https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html, // `types` and `typings` are interchangeable. - const {fesm2015, fesm5, esm2015, esm5, main, types, typings = types}: EntryPointPackageJson = - JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + const {name, fesm2015, fesm5, esm2015, esm5, main, types, typings = types}: + EntryPointPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); // Minimum requirement is that we have esm2015 format and typings. if (!typings || !esm2015) { @@ -74,6 +77,7 @@ export function getEntryPointInfo(pkgPath: string, entryPoint: string): EntryPoi } const entryPointInfo: EntryPoint = { + name, package: pkgPath, path: entryPoint, typings: path.resolve(entryPoint, typings), diff --git a/packages/compiler-cli/src/ngcc/test/packages/build_marker_spec.ts b/packages/compiler-cli/src/ngcc/test/packages/build_marker_spec.ts index 389906940a..811bb8cfc6 100644 --- a/packages/compiler-cli/src/ngcc/test/packages/build_marker_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/packages/build_marker_spec.ts @@ -94,7 +94,7 @@ function restoreRealFileSystem() { } function createEntryPoint(path: string): EntryPoint { - return {path, package: '', typings: ''}; + return {name: 'some-package', path, package: '', typings: ''}; } describe('Marker files', () => { diff --git a/packages/compiler-cli/src/ngcc/test/packages/entry_point_spec.ts b/packages/compiler-cli/src/ngcc/test/packages/entry_point_spec.ts index e6d8cb9068..61b5178b0d 100644 --- a/packages/compiler-cli/src/ngcc/test/packages/entry_point_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/packages/entry_point_spec.ts @@ -18,6 +18,7 @@ describe('getEntryPointInfo()', () => { () => { const entryPoint = getEntryPointInfo('/some_package', '/some_package/valid_entry_point'); expect(entryPoint).toEqual({ + name: 'some-package', package: '/some_package', path: '/some_package/valid_entry_point', typings: `/some_package/valid_entry_point/valid_entry_point.d.ts`, @@ -83,6 +84,7 @@ function restoreRealFileSystem() { function createPackageJson(packageName: string, {exclude}: {exclude?: string} = {}): string { const packageJson: any = { + name: 'some-package', typings: `./${packageName}.d.ts`, fesm2015: `./fesm2015/${packageName}.js`, esm2015: `./esm2015/${packageName}.js`,