fix(ngcc): handle mappings outside the content when flattening source… · angular/angular@73cf7d5 · GitHub
Skip to content

Commit 73cf7d5

Browse files
petebacondarwinmatsko
authored andcommitted
fix(ngcc): handle mappings outside the content when flattening source-maps (#35718)
Previously when rendering flattened source-maps, it was assumed that no mapping would come from a line that is outside the lines of the actual source content. It turns out this is not a valid assumption. Now the code that renders flattened source-maps will handle such mappings, with the additional benefit that the rendered source-map will only contain mapping lines up to the last mapping, rather than a mapping line for every content line. Fixes #35709 PR Close #35718
1 parent 72c4fda commit 73cf7d5

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

‎packages/compiler-cli/ngcc/src/sourcemaps/source_file.ts‎

Lines changed: 9 additions & 4 deletions

‎packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ runInEachFileSystem(() => {
174174
[5, 0, 1, 20], [7, 0, 1, 22], [12, 0, 1, 27], [14, 0, 1, 28], [15, 0, 1, 29],
175175
[9, 0, 2, 13], [10, 0, 2, 14]
176176
],
177-
[],
178177
];
179178

180179
JS_CONTENT_MAP = fromObject({
@@ -196,15 +195,12 @@ runInEachFileSystem(() => {
196195
'file': 'file.js',
197196
'sources': ['file.js'],
198197
'names': [],
199-
'mappings': encode([
200-
[], [], [], [], [], [], [], [], [], [], [], [], [[0, 0, 0, 0]],
201-
[], [], [], [], [], [], [], [], []
202-
]),
198+
'mappings': encode([[], [], [], [], [], [], [], [], [], [], [], [], [[0, 0, 0, 0]]]),
203199
'sourcesContent': [JS_CONTENT.contents],
204200
});
205201

206202
const MERGED_OUTPUT_PROGRAM_MAPPINGS: SourceMapMappings =
207-
[[], [], [], [], [], [], [], [], [], [], [], [], ...JS_CONTENT_MAPPINGS, []];
203+
[[], [], [], [], [], [], [], [], [], [], [], [], ...JS_CONTENT_MAPPINGS];
208204

209205
MERGED_OUTPUT_PROGRAM_MAP = fromObject({
210206
'version': 3,

‎packages/compiler-cli/ngcc/test/sourcemaps/source_file_spec.ts‎

Lines changed: 26 additions & 0 deletions

0 commit comments

Comments
 (0)