diff --git a/packages/compiler-cli/ngcc/src/main.ts b/packages/compiler-cli/ngcc/src/main.ts index 544b265c4d..4868c0bb8c 100644 --- a/packages/compiler-cli/ngcc/src/main.ts +++ b/packages/compiler-cli/ngcc/src/main.ts @@ -193,6 +193,13 @@ function getTargetedEntryPoints( const finder = new TargetedEntryPointFinder( fs, config, logger, resolver, basePath, absoluteTargetEntryPointPath, pathMappings); const entryPointInfo = finder.findEntryPoints(); + const invalidTarget = entryPointInfo.invalidEntryPoints.find( + i => i.entryPoint.path === absoluteTargetEntryPointPath); + if (invalidTarget !== undefined) { + throw new Error( + `The target entry-point "${invalidTarget.entryPoint.name}" has missing dependencies:\n` + + invalidTarget.missingDependencies.map(dep => ` - ${dep}\n`)); + } if (entryPointInfo.entryPoints.length === 0) { markNonAngularPackageAsProcessed(fs, absoluteTargetEntryPointPath); } diff --git a/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts b/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts index 6357078a1b..18827a89fd 100644 --- a/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts +++ b/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts @@ -98,6 +98,14 @@ runInEachFileSystem(() => { // was not processed. expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toBeUndefined(); }); + + it('should report an error if a dependency of the target does not exist', () => { + expect(() => { + mainNgcc({basePath: '/node_modules', targetEntryPointPath: 'invalid-package'}); + }) + .toThrowError( + 'The target entry-point "invalid-package" has missing dependencies:\n - @angular/missing\n'); + }); }); describe('early skipping of target entry-point', () => { @@ -536,6 +544,30 @@ runInEachFileSystem(() => { contents: `export declare class AppComponent {};` }, ]); + + // An Angular package that has a missing dependency + loadTestFiles([ + { + name: _('/node_modules/invalid-package/package.json'), + contents: '{"name": "invalid-package", "es2015": "./index.js", "typings": "./index.d.ts"}' + }, + { + name: _('/node_modules/invalid-package/index.js'), + contents: ` + import {AppModule} from "@angular/missing"; + import {Component} from '@angular/core'; + export class AppComponent {}; + AppComponent.decorators = [ + { type: Component, args: [{selector: 'app', template: '