diff --git a/packages/@ngtools/webpack/src/angular_compiler_plugin.ts b/packages/@ngtools/webpack/src/angular_compiler_plugin.ts index 10bb8819fe81..1c95c4481226 100644 --- a/packages/@ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/@ngtools/webpack/src/angular_compiler_plugin.ts @@ -816,16 +816,20 @@ export class AngularCompilerPlugin implements Tapable { .map((p) => this._compilerHost.denormalizePath(p)); } } else { - // Check if the TS file exists. - if (fileName.endsWith('.ts') && !this._compilerHost.fileExists(fileName, false)) { - throw new Error(`${fileName} is not part of the compilation. ` - + `Please make sure it is in your tsconfig via the 'files' or 'include' property.`); - } + // Check if the TS input file and the JS output file exist. + if ((fileName.endsWith('.ts') && !this._compilerHost.fileExists(fileName, false)) + || !this._compilerHost.fileExists(outputFile, false)) { + let msg = `${fileName} is missing from the TypeScript compilation. ` + + `Please make sure it is in your tsconfig via the 'files' or 'include' property.`; + + if (/(\\|\/)node_modules(\\|\/)/.test(fileName)) { + msg += '\nThe missing file seems to be part of a third party library. ' + + 'TS files in published libraries are often a sign of a badly packaged library. ' + + 'Please open an issue in the library repository to alert its author and ask them ' + + 'to package the library using the Angular Package Format (https://goo.gl/jB3GVv).'; + } - // Check if the output file exists. - if (!this._compilerHost.fileExists(outputFile, false)) { - throw new Error(`${fileName} is not part of the compilation output. ` - + `Please check the other error messages for details.`); + throw new Error(msg); } outputText = this._compilerHost.readFile(outputFile); diff --git a/tests/e2e/tests/build/build-errors.ts b/tests/e2e/tests/build/build-errors.ts index 32ce0ff98ddb..a5a97af7fb49 100644 --- a/tests/e2e/tests/build/build-errors.ts +++ b/tests/e2e/tests/build/build-errors.ts @@ -39,7 +39,7 @@ export default function () { })) .then(() => expectToFail(() => ng('build'))) .then(({ message }) => { - if (!message.includes('polyfills.ts is not part of the compilation')) { + if (!message.includes('polyfills.ts is missing from the TypeScript compilation')) { throw new Error(`Expected missing TS file error, got this instead:\n${message}`); } if (extraErrors.some((e) => message.includes(e))) {