-
Notifications
You must be signed in to change notification settings - Fork 718
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
Confusing issue with resolving class if module is called from separate module #262
Comments
When you say a module are you talking about an ES6 module or an npm module? Does RouteBuilder extend a class? Can I find the full source code on github? Thanks |
I'm not fully sure but my guess is the following... I'm assuming that you have 2 npm modules. The If you are using multiple npm modules maybe what is happening is that you have 2 instances of Reflect (one per module):
The problem is that if there are two Reflect objects the second will fail. I have never encounter this problem so it would be great if you could debug and find it. Invoking the following: Reflect.getMetadata("inversify:paramtypes", RouteBuilder); Should return an empty array in both npm modules. The solution to this problem would be to ensure that Reflect is accessed as a singleton global. |
On 06/21/2016 06:40 PM, Remo H. Jansen wrote:
|
When it returns If you are going to distribute the npm modules as librarires then they shouldn't import You need to remove the following from your code: import "reflect-metadata"; This line should be be used only once by the consumers. The consumers are the ones that need to import it. For example, InversifyJS uses Reflect but you as a consumer need to import it. We do import reflect when we run the unit test because the unit test can be considered as a consumer. |
On 06/21/2016 07:37 PM, Remo H. Jansen wrote:
|
No problem. Can this issue be closed then? |
@tenowg can you please confirm if this issue be closed? Thanks! |
Yes, this issue is closed... thanks again |
I know this is a closed issue, but @remojansen and @tenowg thank you for working through this in public — just saved me from pulling out the last of my hair! |
No problem :) Feel free to create issues instead of using the chat if you have any questions. Issues can help other users and at the moment we don't get a crazy number of issues. If it scales to too many issues per day we will change the rules but for the moment is fine to create issues 😉 |
Maybe you can help me resolve this issue. This is likely behavior that I didn't account for in my code.
When this code is called from identical code from within the module, it works without an issue, when I seperate the test code (just a simple module that is supposed to run the server) the getRouter() function will error with `Missing required @Injectable annotation in: RouteBuilder.
The getRouter() is used in functions as such:
which are annotations on methods in controller classes.
The main code that is run to start the application is:
If this is in the @demgel/mvc module it will work When I separate this code to a new module, I get the error.
additionaly, if I remove any controllers from the startup, RouteBuilder is injected into ExpressMvc when it is resolved at the end of the expressMvc function.
The text was updated successfully, but these errors were encountered: