-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(ivy): ngtsc template sourcemaps #28055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
petebacondarwin
wants to merge
17
commits into
angular:master
from
petebacondarwin:ngtsc-template-sourcemaps
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8d0eaac
build: show no warning for large git repos
petebacondarwin 5edfe0d
refactor(compiler): use `options` argument for parsers
petebacondarwin e9cf9c7
refactor(compiler): remove unnecessary `!` operators from lexer
petebacondarwin 7d185b3
feat(compiler): support tokenizing a sub-section of an input string
petebacondarwin cbf83fa
feat(compiler): support tokenizing escaped strings
petebacondarwin 7a16a49
docs(core): tidy up the description of `resolveComponentResources()`
petebacondarwin d559db5
refactor(core): do not remove `templateUrl` when resolving
petebacondarwin 876d79a
refactor(compiler): wrap the jit evaluation in an injectable class
petebacondarwin 0fae41e
fix(compiler): support `sourceMappingURL` comments that have trailing…
petebacondarwin e4922ba
fix(core): use the correct template URL in render3 JIT compilation
petebacondarwin c1e24a6
fix(core): use the correct generated URL for JIT compiled components
petebacondarwin 3c7dd61
test(core): update JIT source mapping tests for ivy
petebacondarwin e48f638
fix(compiler): markup lexer should not capture quotes in attribute value
petebacondarwin 83817d8
refactor(compiler): capture `sourceSpan` when converting action bindi…
petebacondarwin deae660
fix(compiler): ensure that event handlers have the correct source spans
petebacondarwin 21720d7
feat(ivy): add source mappings to compiled Angular templates
petebacondarwin 61d550c
test(ivy): add template source mapping tests
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,5 @@ | |
| "**/bazel-out": true, | ||
| "**/dist": true, | ||
| }, | ||
| "git.ignoreLimitWarning": true, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/compiler-cli/src/ngtsc/util/src/ts_source_map_bug_29300.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google Inc. All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.io/license | ||
| */ | ||
| import * as ts from 'typescript'; | ||
|
|
||
| let _tsSourceMapBug29300Fixed: boolean|undefined; | ||
|
|
||
| /** | ||
| * Test the current version of TypeScript to see if it has fixed the external SourceMap | ||
| * file bug: https://github.com/Microsoft/TypeScript/issues/29300. | ||
| * | ||
| * The bug is fixed in TS 3.3+ but this check avoid us having to rely upon the version number, | ||
| * and allows us to gracefully fail if the TS version still has the bug. | ||
| * | ||
| * We check for the bug by compiling a very small program `a;` and transforming it to `b;`, | ||
| * where we map the new `b` identifier to an external source file, which has different lines to | ||
| * the original source file. If the bug is fixed then the output SourceMap should contain | ||
| * mappings that correspond ot the correct line/col pairs for this transformed node. | ||
| * | ||
| * @returns true if the bug is fixed. | ||
| */ | ||
| export function tsSourceMapBug29300Fixed() { | ||
| if (_tsSourceMapBug29300Fixed === undefined) { | ||
| let writtenFiles: {[filename: string]: string} = {}; | ||
| const sourceFile = | ||
| ts.createSourceFile('test.ts', 'a;', ts.ScriptTarget.ES2015, true, ts.ScriptKind.TS); | ||
| const host = { | ||
| getSourceFile(): ts.SourceFile | undefined{return sourceFile;}, | ||
| fileExists(): boolean{return true;}, | ||
| readFile(): string | undefined{return '';}, | ||
| writeFile(fileName: string, data: string) { writtenFiles[fileName] = data; }, | ||
| getDefaultLibFileName(): string{return '';}, | ||
| getCurrentDirectory(): string{return '';}, | ||
| getDirectories(): string[]{return [];}, | ||
| getCanonicalFileName(): string{return '';}, | ||
| useCaseSensitiveFileNames(): boolean{return true;}, | ||
| getNewLine(): string{return '\n';}, | ||
| }; | ||
|
|
||
| const transform = (context: ts.TransformationContext) => { | ||
| return (node: ts.SourceFile) => ts.visitNode(node, visitor); | ||
| function visitor(node: ts.Node): ts.Node { | ||
| if (ts.isIdentifier(node) && node.text === 'a') { | ||
| const newNode = ts.createIdentifier('b'); | ||
| ts.setSourceMapRange(newNode, { | ||
| pos: 16, | ||
| end: 16, | ||
| source: ts.createSourceMapSource('test.html', 'abc\ndef\nghi\njkl\nmno\npqr') | ||
| }); | ||
| return newNode; | ||
| } | ||
| return ts.visitEachChild(node, visitor, context); | ||
| } | ||
| }; | ||
|
|
||
| const program = ts.createProgram(['test.ts'], {sourceMap: true}, host); | ||
| program.emit(sourceFile, undefined, undefined, undefined, {after: [transform]}); | ||
| // The first two mappings in the source map should look like: | ||
| // [0,1,4,0] col 0 => source file 1, row 4, column 0) | ||
| // [1,0,0,0] col 1 => source file 1, row 4, column 0) | ||
| _tsSourceMapBug29300Fixed = /ACIA,CAAA/.test(writtenFiles['test.js.map']); | ||
| } | ||
| return _tsSourceMapBug29300Fixed; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it come up? Which files are generated that are not ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When debugging a Bazel node test, VS code notices that the whole Bazel test output code, through whose source you are debugging has a git repository of its own - but it seems to think that there are thousands of changes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.