Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Exception during NgModule config parsing with AoT apps #1070

Closed
stevenkampen opened this issue Apr 18, 2017 · 4 comments
Closed

Exception during NgModule config parsing with AoT apps #1070

stevenkampen opened this issue Apr 18, 2017 · 4 comments

Comments

@stevenkampen
Copy link
Contributor

@thaoula reported on #1063 that an exception occurs while initializing Augury for AoT apps.

ddc9f05c-248a-11e7-9e09-6a177343f7f1

@dansomething
Copy link

dansomething commented May 12, 2017

Is this possibly related to #733? I got the same error until I followed the readme to update angularCompilerOptions.debug in tsconfig.json to disable AoT compilation.

@igor-ka igor-ka added investigation and removed bug labels May 23, 2017
@riavalon riavalon self-assigned this May 24, 2017
@riavalon
Copy link
Contributor

riavalon commented May 29, 2017

The error is cause because of this code in src/backend/utils/parse-modules.ts:

const resolveNgModuleDecoratorConfig = (m) => {
  if (m.decorators) {
    return m.decorators.reduce((prev, curr, idx, decorators) =>
      prev ? prev : decorators[idx].type.prototype.toString() === '@NgModule' ?
        (decorators[idx].args || [])[0] : null, null);
  }

  // problem occurs on this line
  return Reflect.getMetadata('annotations', m).find(decorator => decorator.toString() === '@NgModule'); 
};

When an app is compiled with AoT, Reflect.getMetadata(...) will return undefined. I believe this is because the metadata files are put into metadata.json files when the app is compiled in AoT, though I'm not sure how we would go about grabbing that metadata in augury.

@riavalon riavalon removed their assignment May 29, 2017
@stevenkampen
Copy link
Contributor Author

@riavalon I made a change just yesterday to stop that undefined reference error, so at least that won't happen anymore :)

https://github.com/rangle/augury/pull/1134/files#diff-d55af29576cfd559bea03764b5c7fc9bR23

@riavalon
Copy link
Contributor

Great, sounds good @stevenkampen

We talked about this one a bit more offline: As there is no way currently for us to get access to metadata when an app is compiled in AoT, we're going to instead show an informative error message in the NgModules tab and improve the documentation around it.

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

No branches or pull requests

4 participants