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

Nested Modules do not expose services from other modules correctly #208

Open
DaSchTour opened this issue Sep 15, 2017 · 6 comments
Open

Comments

@DaSchTour
Copy link

I made a small example here https://plnkr.co/edit/ER3t3jLJAhN2myR9FIXY

The hierarchy of modules doesn't work because the service imported through a module in a child module is lost when bootstraping the parent module. So there is not possibility to inherit services from submodules correctly.

@aciccarello
Copy link
Collaborator

I've been getting that InvalidProviderError(undefined) a lot lately. I think it is more of a TypeScript issue. The modules provided to NgMetadata are undefined if there is a cycle in the imports or the modules are defined in the wrong order. Since the modules aren't defined independently the symbols need to be defined at boot time so NgMetadata can bundle them.

I reorganized the app.module.ts in your plunker and changed the bootstrap to the AppModule to get things working. https://plnkr.co/edit/9FCvm9zbpxu05CLiKbhR?p=preview

@DaSchTour
Copy link
Author

@aciccarello okay, well. That makes my problem even worse. I've separated NPM Packages using ng-metadata ngModule definition. So the best way would be to import all dependencies needed in the base module and don't depend on resolving imports of submodules.
Or may it be possible use ngmodules export property to add the submodules so that the import is expanded to also importing all submodules.

@aciccarello
Copy link
Collaborator

I'm not sure I understand what issue you are referring to. Can you create another plunker?

You should be able to import modules in the dependencies. The difficulty is when you bundle the NgMetadata modules separately or have a circular dependency.

@DaSchTour
Copy link
Author

@aciccarello yes that's exactly what I'm doing. The punklr I made is just an example of seperate NPM packages using NgMetadata modules. But the point with circular dependencies is a point I have to check, although the structure of our packages should be hierarchical.

@DaSchTour
Copy link
Author

@aciccarello Is it possible to extend the error message of InvalidProviderError(undefined) to get some kind of stacktrace? Some information about the module, component or module where this happend would be very helpful.

@aciccarello
Copy link
Collaborator

👍 Yeah, I think the error message could be improved. I would like for the error message to include something about the module where undefined was found. Maybe if the type is undefined there could be a special error message suggesting that there was a cycle in the imports.

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

2 participants