-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@ngtools/webpack): expose TS TypeChecker from ng compiler plugin #11786
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
Conversation
@alexeagle @hansl @clydin I'm ok with this change, which is needed for the NativeScript team to get the TS type checker during their transforms. WDYT? |
I'd prefer if the For example,
And then the plugin options:
|
@clydin I like your suggestion, because it leaves the door open for further extensibility. What is not clear to me is whether you have control over what context is passed to the transformers. |
Actually, in AOT case the AngularCompilerProgram is used, but at the end of the day it calls the One other approach might be to pass in a platformTransfromersFactory (similar to the actual |
Replacing here with something similar to the following may work:
|
Hey @clydin I've tried this approach and as far the API goes - it works. We get the extended context. However, this leaves us a little further form the the original goal of implementing In reality there are only small differences in the NativeScript bootstrap (the name of the platform and the module form where it is imported). That's why we are hopping to reuse most of the APIs so that there is less code to keep in sync. |
The transformers are due for a general refactoring. As a result, I wouldn't be overly concerned about reuse. The current setup performs multiple full AST walks which has potential performance concerns. The need to pass |
@@ -174,6 +174,10 @@ export class AngularCompilerPlugin { | |||
return { path, className }; | |||
} | |||
|
|||
get typescriptProgram(): ts.Program { | |||
return this._getTsProgram(); |
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.
return just the typechecker here
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.
this can also be unavailable during certain points in the compilation lifecycle so should also return null in those cases.
Let's keep the simple code you have, with one comment. |
55893cc
to
6078b8b
Compare
6078b8b
to
e4310fa
Compare
…ugin Expose the TypeScript Program created by the plugin, so that it can be used in custom platform transformers.
e4310fa
to
a27f63d
Compare
The bootstrap transformer will automatically replace the platform and bootstrap calls inside `main.ts` when building with AOT. This will eliminate the need for `main.aot.ts` and `app.module.ngfactory.d.ts` files in templates. This depends on angular/angular-cli#11786 going public
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Expose the TypeScript Program created by the plugin, so that it can be used in custom platform transformers.This will allow to define custom
platformTransformers
similar toreplace_bootstrap
. They will need some way to get access to the TS program created by the plugin to make transformations.We discussed this with @filipesilva in slack and he suggested to open a proper PR exposing the TS program and continue any discussions here.