fix(compiler): add an empty content for source file of non mapped code. (#15246)

Before this when using ngc, tools tried to load `ng://…<component>.ts`
if `…<component>.ts` was the source file of a template.

PR Close #15246
This commit is contained in:
Tobias Bosch
2017-03-17 09:44:27 -07:00
committed by Miško Hevery
parent 5486e5417b
commit 8415910375
5 changed files with 8 additions and 5 deletions

View File

@ -98,7 +98,10 @@ export class EmitterVisitorContext {
let firstOffsetMapped = false;
const mapFirstOffsetIfNeeded = () => {
if (!firstOffsetMapped) {
map.addSource(sourceFilePath).addMapping(0, sourceFilePath, 0, 0);
// Add a single space so that tools won't try to load the file from disk.
// Note: We are using virtual urls like `ng:///`, so we have to
// provide a content here.
map.addSource(sourceFilePath, ' ').addMapping(0, sourceFilePath, 0, 0);
firstOffsetMapped = true;
}
};