Skip to content
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

Angular AoT Compilation Support #158

Open
laurentgoudet opened this issue Sep 12, 2016 · 4 comments
Open

Angular AoT Compilation Support #158

laurentgoudet opened this issue Sep 12, 2016 · 4 comments

Comments

@laurentgoudet
Copy link

First, thanks for your awesome work on that plugin! I was wondering how/if support for Angular's AoT Compiler could be added.

As describe at @angular/compiler-cli:

This CLI is intended for demos, prototyping, or for users with simple build systems that run bare tsc.

Users with a build system should expect an Angular 2 template plugin. Such a plugin would be based on the index.ts in this directory, but should share the TypeScript compiler instance with the one already used in the plugin for TypeScript typechecking and emit.

Its high level design being:

At a high level, this program

  • collects static metadata about the sources using the tsc-wrapped package in angular2
  • uses the OfflineCompiler from angular2/src/compiler/compiler to codegen additional .ts files
  • these .ts files are written to the genDir path, then compiled together with the application.

While I guess the TypeScript version could be overridden by tsc-wrapper, the full Angular compilation process is more complex and may be too-specialized for the purpose of that plugin. However, creating another plugin-typescript-angular would mean duplicating efforts.

@fictitious
Copy link

I don't think everyone who uses typescript with SystemJS wants to have a dependency on angular.

However, creating another plugin-typescript-angular would mean duplicating efforts.

Not necessarily - this plugin itself is less than 200 lines of code, everything else seems perfectly reusable.

@aluanhaddad
Copy link
Contributor

I'm still skeptical of tsc-wrapped. I do not like the idea of Angular extending the language independently. I was using TypeScript before Angular 2 and I will keep using it. Of course it is possible that they will not deviate too much from TypeScript but it is tough to say at this point. I fear @script lives on...

@frankwallis
Copy link
Owner

Possibly this could be done by exposing the TypeScript CompilerHost globally so that it could be shared with a separate AoT plugin? It's not really something I would want to take on but if there is something I can do to facilitate it then I am happy to make changes.

@frankwallis
Copy link
Owner

plugin-typescript now exposes a global variable tsfactory which is a Promise<FactoryOutput> and would enable other plugins to access the CompilerHost used by plugin-typescript (along with the Resolver, TypeChecker and Transpiler). This makes it possible for an AOT compiler plugin to uses these objects to compile files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants