Repository navigation
feat(aot): Support AoT - #223 - #226
Merged
Merged
Conversation
e-schultz
commented
Sep 21, 2016
Member
- Start adding support for AoT
- Add dev dependencies for angular compiler
- Update tsconfig to tell ngc to emit metadata
Member
Author
|
@SethDavenport @dagstuan haven't a chance to test this yet, just starting to get the files generated for AoT |
|
I'm tempted to try this out :) |
Member
|
@bennett000 has been messing around with AoT quite a bit recently, he might have some insight. |
Collaborator
IIRC there is an issue (I think |
* Start adding support for AoT
* Add dev dependencies for angular compiler
* Update tsconfig to tell ngc to emit metadata
Sorry for the delay on this, was hoping to get AoT working for
decorators also - but there seems to be some challenges around that.
* Update build to use ngc - metadata.json is now produced
* Fix `Unexpected value 'NgReduxModule' imported`
* NgReduxModule
```js
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgReduxModule, NgRedux } from 'ng2-redux';
import { IAppState } from './appstate';
import { rootReducer } from './store';
@NgModule({
declarations: [
AppComponent
],
imports: [
NgReduxModule.forRoot(),
BrowserModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(ngRedux: NgRedux<IAppState>) {
ngRedux.configureStore(rootReducer,{});
}
}
```
The DevTools provider is not provider by default with the
`NgReduxModule`, as you may not want to include this for production
builds. To use `DevToolsExtension`, it is the same as before - and still
need to include it in your providers.
```js
import { NgReduxModule, DevToolsExtension }
@NgModule({
providerS: [DevToolsExtension]
})
export class AppModule {
constructor(ngRedux:NgRedux<IAppState>, devTools:DevToolsExtension) {
// config as before
}
}
```
**IMPORTANT NOTE ABOUT AOT**
If using the ngc compiler and AoT compilation - `@select` decorators
will not work. If you want to use the ngc compiler (either directly, or
via angular-cli), and want to use the `@select` - you will need to use
the `--aot false` flag.
If you want to use AoT - the build process will work, but decorators
will silently stop working. If you want to use AoT.
**before**
```js
import { select } from 'ng2-redux';
export class MyComponent {
@select() thing$:Observable<string>;
}
```
**after**
```js
import { NgRedux } from 'ng2-redux';
export class MyComponent {
thing$:Observable<string>;
constructor(private ngRedux:NgRedux<MyAppState>) {
}
ngOnInit() {
this.thing$ = this.ngRedux.select (n => n.thing);
}
}
```
We are big fans of how the `@select` works - and high priority to get
this working, but it seems to possibly be a limitation of the compiler.
Any feedback / help / suggestions to try and get this working with AoT
would be greatly appreciated.
e-schultz
force-pushed
the
feat-support-aot
branch
from
October 19, 2016 02:11
2b9ff44 to
12ec953
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.