-
Notifications
You must be signed in to change notification settings - Fork 205
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
Missing metadata.json files for AoT compilation #223
Comments
Looking into getting AoT support in soon, and how this works with the Thanks for letting us know about the metadata.json / links to other issues - will try and get this resolved soon. |
* Start adding support for AoT * Add dev dependencies for angular compiler * Update tsconfig to tell ngc to emit metadata
Thanks for looking into this! In the meantime, is there any workaround for this issue? |
Hi, did anyone fix this issue ? |
Been busy traveling for work lately and haven't had as much time to work on this, but have a test module published at One error once I've gotten past the NgModule error, is how it behaves when you pass functions into selectors.
If anyone has a demo repo with an AoT app working that they could point me at to help play around with as a test bed, that would be great. |
Some update/progress: Working on a repo with master of angular-cli. e-schultz/ng2-redux-aot-example#1 Have it so things don't throw errors, however the |
i had this problem with ngc over NgRedux error which could be handle like this
|
also there must be another work around for combineReducers function . this style ditch the error of re-exporting Reducer over ngc compilation |
also there is a problem with redux library which throws an error on NODE_ENV === "productions". no way to handle this ... |
* 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.
* 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.
@hasangilak regarding the NODE_ENV === "production" error - are you using angular-cli or webpack by any chance? |
If you're using angular-cli I believe they've fixed this in beta-18. If you're using webpack, you'll need to use new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}) |
@dagstuan have you tried the latest ng2-redux 4.0.0 beta 7? I believe it resolves a number of AoT issues. |
Closing for now. If you're still having AoT issues, be sure to reference #234 for the latest discussion. |
Hey, sorry about the late reply. I havent had issues with it lately as I've been waiting a while to try and implement it again :) But it looks like you guys have it under control. Thank you! :) |
Currently the library does not support AoT compilation due to missing metadata.json files that need to be included along with d.ts-files.
See:
https://github.com/orizens/angular2-infinite-scroll/issues/77#issuecomment-245027350
angular/angular#11262 (comment)
angular/angular#11262 (comment)
The text was updated successfully, but these errors were encountered: