fix(bazel): improve error message for missing assets (#22096)
fixes #22095 PR Close #22096
This commit is contained in:
parent
a9545aba4d
commit
dcf64a0d01
|
@ -202,6 +202,12 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
|
|||
return path.resolve(bazelBin, workspaceRelative) + '.d.ts';
|
||||
};
|
||||
}
|
||||
// Patch a property on the ngHost that allows the resourceNameToModuleName function to
|
||||
// report better errors.
|
||||
(ngHost as any).reportMissingResource = (resourceName: string) => {
|
||||
console.error(`\nAsset not found:\n ${resourceName}`);
|
||||
console.error('Check that it\'s included in the `assets` attribute of the `ng_module` rule.\n');
|
||||
};
|
||||
|
||||
const emitCallback: ng.TsEmitCallback = ({
|
||||
program,
|
||||
|
|
|
@ -231,7 +231,12 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
|||
}
|
||||
const filePathWithNgResource =
|
||||
this.moduleNameToFileName(addNgResourceSuffix(resourceName), containingFile);
|
||||
return filePathWithNgResource ? stripNgResourceSuffix(filePathWithNgResource) : null;
|
||||
const result = filePathWithNgResource ? stripNgResourceSuffix(filePathWithNgResource) : null;
|
||||
// Used under Bazel to report more specific error with remediation advice
|
||||
if (!result && (this.context as any).reportMissingResource) {
|
||||
(this.context as any).reportMissingResource(resourceName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
toSummaryFileName(fileName: string, referringSrcFileName: string): string {
|
||||
|
|
Loading…
Reference in New Issue