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

AoT Compatibility #39

Closed
taozytroy opened this issue Nov 9, 2016 · 6 comments
Closed

AoT Compatibility #39

taozytroy opened this issue Nov 9, 2016 · 6 comments

Comments

@taozytroy
Copy link

@taozytroy taozytroy commented Nov 9, 2016

The calling of createMetaReducer is prohibited by AoT with error message:

Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol lightningStore in /Users/newAccount/Desktop/.../src/app/store.ts, resolving symbol imports in /Users/newAccount/Desktop/.../src/app/imports.ts, resolving symbol LightningAppModule in /Users/newAccount/Desktop/.../src/app/lightning-app.module.ts, resolving symbol LightningAppModule in /Users/newAccount/Desktop/.../src/app/lightning-app.module.ts
@bennett000
Copy link

@bennett000 bennett000 commented Nov 9, 2016

@watrool do we have a sandbox scenario for this?

@taozytroy
Copy link
Author

@taozytroy taozytroy commented Nov 9, 2016

@bennett000
I tried change the arrow function and it does not work (although arrow-function-exports is indeed an AoT dont).

For the exports, I tried to import createMetaReducer from create-meta-reducer.js directly not through the top level exports, but still does not work.

My idea is that the problem is the nested-function case in the sandbox (mainly because i cannot find a solution for that).

@bennett000
Copy link

@bennett000 bennett000 commented Nov 9, 2016

@watrool I fear it's got to be a static method:

export class MyPointlessContainerClass {
  static myMethodWhichShouldReallyJustBeAPureFunction() {
    // do stuff
  }
  static myOtherMethodWhichShouldBeAFunction() {
    // do stuff
  }
}
@ttmarek
Copy link
Contributor

@ttmarek ttmarek commented Nov 11, 2016

The AoT compiler seems to have an issue with all meta reducers in general. I ran into the same problem with ngrx-store-logger, and created an issue here. From a redux-gtm standpoint there isn't much that can be done.

@taozytroy
Copy link
Author

@taozytroy taozytroy commented Nov 11, 2016

@ttmarek According to the link I found from your issue, I managed to let ngrx-store-logger with compose become AoT-friendly. Please checkout the new ngrx-compose case in the sandbox.

So if the issue related to redux-gtm is only this compose function, maybe we can find a way around it.

@ttmarek
Copy link
Contributor

@ttmarek ttmarek commented Nov 15, 2016

The solution here was to wrap the exported meta reducer in another meta reducer that was defined as a function declaration before exporting it.

import { createMetaReducer } from 'redux-gtm';
import { eventDefinitions } from './somewhere';
import { someOtherReducer } from './somewhere-else';

const gtmReducer = createMetaReducer(eventDefinitions);

// wrap whatever other reducers you've got in the meta reducer
const finalReducer = gtmReducer(someOtherReducer);

export function reducer(state: any, action: any) {
   return finalReducer(state, action);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants