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

WIP: ngtsc template sourcemaps #28055

Open
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@petebacondarwin
Copy link
Member

petebacondarwin commented Jan 10, 2019

This is still a WIP, but I thought it would be good to get it off my laptop and into the cloud.

The basic approach is in place.

There is a bug in TypeScript Microsoft/TypeScript#29300 that prevents the templateUrl URL from working correctly.

For inline templates, only string literals are supported.

The actual mapping from the generated ivy code to the templates needs some work.

@petebacondarwin petebacondarwin requested review from angular/fw-compiler as code owners Jan 10, 2019

@googlebot googlebot added the cla: yes label Jan 10, 2019

@ngbot ngbot bot added this to the needsTriage milestone Jan 10, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:ngtsc-template-sourcemaps branch from d2a34f1 to 23fb85f Jan 10, 2019

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 10, 2019

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 10, 2019

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:ngtsc-template-sourcemaps branch 2 times, most recently from 62f08cd to 8ed8779 Jan 11, 2019

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 11, 2019

@petebacondarwin petebacondarwin requested review from IgorMinar and angular/docs-infra as code owners Jan 14, 2019

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 14, 2019

@petebacondarwin petebacondarwin removed request for angular/tools-bazel and IgorMinar Jan 14, 2019

petebacondarwin added some commits Jan 16, 2019

refactor(ivy): expose resolving URLs in the `ResourceLoader`
Resources can be loaded in the context of another file, which
means that the path to the resource file must be resolved
before it can be loaded.

Previously the API of this interface did not allow the client
code to get access to the resolved URL which is used to load
the resource.

Now this API has been refactored so that you must do the
resource URL resolving first and the loading expects a
resolved URL.
refactor(compiler): use `options` argument for parsers
This commit consolidates the options that can modify the
parsing of text (e.g. HTML, Angular templates, CSS, i18n)
into an AST for further processing into a single `options`
hash.

This makes the code cleaner and more readable, but also
enables us to support further options to parsing without
triggering wide ranging changes to code that should not
be affected by these new options.  Specifically, it will let
us pass information about the placement of a template
that is being parsed in its containing file, which is essential
for accurate SourceMap processing.
feat(compiler): support tokenizing a sub-section of an input string
The lexer that does the tokenizing can now process only a part the source
string, by passing a `range` property in the `options` argument. The
locations of the nodes that are tokenized will now take into account the
position of the span in the context of the original source string.

This `range` option is, in turn, exposed from the template parser as well.

Being able to process parts of files helps to enable SourceMap support
when compiling inline component templates.
feat(ivy): pass component template source information to template parser
During analysis, the `ComponentDecoratorHandler` passes the component
template to the `parseTemplate()` function. Previously, there was little or
no information about the origjnal source file, where the template is found,
passed when calling this function.

Now, we correctly compute the URL of the source of the template, both
for external `templateUrl` and inline `template` cases. Further in the
inline template case we compute the character range of the template
in its containing source file; but only in the case that the template is
a simple string literal. If the template is actually a dyamic value like
an interpolated string or a function call, then we do not try to add the
originating source file information.

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:ngtsc-template-sourcemaps branch from 30c5bd5 to 329e0eb Jan 17, 2019

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 17, 2019

feat(ivy): add source mappings to compiled Angular templates
The translator that converts Ivy AST nodes to TypeScript now adds
template specific source mappings, which account for the file where
the template was found and is fine grained enough to allow break
points to be added to the templates for stepping through the
template creation and update code.

@petebacondarwin petebacondarwin force-pushed the petebacondarwin:ngtsc-template-sourcemaps branch from 329e0eb to 4e4d6de Jan 17, 2019

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Jan 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment