diff --git a/packages/compiler/src/output/abstract_emitter.ts b/packages/compiler/src/output/abstract_emitter.ts index f7082d6f6b..28918302f5 100644 --- a/packages/compiler/src/output/abstract_emitter.ts +++ b/packages/compiler/src/output/abstract_emitter.ts @@ -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; } }; diff --git a/packages/compiler/test/aot/compiler_spec.ts b/packages/compiler/test/aot/compiler_spec.ts index 11e526e935..aa4d4fa33d 100644 --- a/packages/compiler/test/aot/compiler_spec.ts +++ b/packages/compiler/test/aot/compiler_spec.ts @@ -188,7 +188,7 @@ describe('compiler (unbundled Angular)', () => { // for the mapping to the original source file we don't store the source code // as we want to keep whatever TypeScript / ... produced for them. const sourceIndex = sourceMap.sources.indexOf(ngComponentPath); - expect(sourceMap.sourcesContent[sourceIndex]).toBe(null); + expect(sourceMap.sourcesContent[sourceIndex]).toBe(' '); }); })); diff --git a/packages/compiler/test/output/js_emitter_node_only_spec.ts b/packages/compiler/test/output/js_emitter_node_only_spec.ts index c5bcf79ac2..111364d8b0 100644 --- a/packages/compiler/test/output/js_emitter_node_only_spec.ts +++ b/packages/compiler/test/output/js_emitter_node_only_spec.ts @@ -57,7 +57,7 @@ export function main() { const sm = emitSourceMap(someVar.toStmt(), [], '/* MyPreamble \n */'); expect(sm.sources).toEqual([someSourceFilePath, 'in.js']); - expect(sm.sourcesContent).toEqual([null, ';;;var']); + expect(sm.sourcesContent).toEqual([' ', ';;;var']); expect(originalPositionFor(sm, {line: 3, column: 0})) .toEqual({line: 1, column: 3, source: 'in.js'}); }); diff --git a/packages/compiler/test/output/ts_emitter_node_only_spec.ts b/packages/compiler/test/output/ts_emitter_node_only_spec.ts index 2c1a2869b8..d728f23426 100644 --- a/packages/compiler/test/output/ts_emitter_node_only_spec.ts +++ b/packages/compiler/test/output/ts_emitter_node_only_spec.ts @@ -62,7 +62,7 @@ export function main() { const sm = emitSourceMap(someVar.toStmt(), [], '/* MyPreamble \n */'); expect(sm.sources).toEqual([someSourceFilePath, 'in.js']); - expect(sm.sourcesContent).toEqual([null, ';;;var']); + expect(sm.sourcesContent).toEqual([' ', ';;;var']); expect(originalPositionFor(sm, {line: 3, column: 0})) .toEqual({line: 1, column: 3, source: 'in.js'}); }); diff --git a/packages/core/test/linker/source_map_integration_node_only_spec.ts b/packages/core/test/linker/source_map_integration_node_only_spec.ts index b6f0afacfc..9c3cb368cb 100644 --- a/packages/core/test/linker/source_map_integration_node_only_spec.ts +++ b/packages/core/test/linker/source_map_integration_node_only_spec.ts @@ -128,7 +128,7 @@ export function main() { expect(sourceMap.sources).toEqual([ 'ng:///DynamicTestModule/MyComp.ngfactory.js', ngUrl ]); - expect(sourceMap.sourcesContent).toEqual([null, template]); + expect(sourceMap.sourcesContent).toEqual([' ', template]); }));