Uri Shaked
1 min readMay 18, 2018

--

Hi Manish,

This is true — starting with Angular 5, ngc is implemented as TS Transform, which means there is no longer an intermediate step where the .ngfactory.ts files are emitted. Instead, the files are transpiled right after being transformed in-memory, so all you can get is the transpiled JavaScript output.

I believe there is a way to plug into this process and get the AST representation of the transformed source code just before it is transpiled to JavaScript, and then dump it to disk as a TypeScript source file. You can find a code snippet that does something similar here.

If you are interested in exploring this, I’d start by looking at the unit tests for the compiler, where there is a good chance to find a similar mechanism. If you do figure out something, please share it — I’d love to learn as well :-)

--

--

Uri Shaked
Uri Shaked

Written by Uri Shaked

Google Developer Expert for Web Technologies, Maker and Public Speaker

Responses (1)