fix(bazel): improve error message for missing assets (#22096)
fixes #22095 PR Close #22096
This commit is contained in:
parent
de561f36e1
commit
c5ec8d952a
@ -202,6 +202,12 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
|
|||||||
return path.resolve(bazelBin, workspaceRelative) + '.d.ts';
|
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 = ({
|
const emitCallback: ng.TsEmitCallback = ({
|
||||||
program,
|
program,
|
||||||
|
@ -231,7 +231,12 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
|||||||
}
|
}
|
||||||
const filePathWithNgResource =
|
const filePathWithNgResource =
|
||||||
this.moduleNameToFileName(addNgResourceSuffix(resourceName), containingFile);
|
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 {
|
toSummaryFileName(fileName: string, referringSrcFileName: string): string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user