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

I cannot have two modules with same name in application. Is this a bug or a feature? #3362

Closed
mikeconley12 opened this issue Nov 8, 2019 · 8 comments

Comments

@mikeconley12
Copy link

mikeconley12 commented Nov 8, 2019

Current behavior

I cannot have two modules with same name in application. Only the first module will be available in the application. In my case, this is the AModule from "./my-a-module".

Input Code

Third party library

@Module({
    providers: [AService]
    exports: [AService]
})
export class AModule {
}

@Module({
    imports: [AModule],
    providers: [BService]
    exports: [BService]
})
export class BModule {
}

My code

import { BModule } from "third-party-library";
import { AModule } from "./my-a-module";

@Module({
    imports: [
    	AModule,
    	BModule
    ]
})
export class CModule {
}

Expected behavior

I am not sure if this is a bug. But I was expecting that I could have two separate Nest modules with same name.

Environment

"@nestjs/common": "^6.9.0",
"@nestjs/core": "^6.9.0"
 
For Tooling issues:
- Node version: v10.16.0
- Platform: Linux
@mikeconley12 mikeconley12 added the needs triage This issue has not been looked into label Nov 8, 2019
@mikeconley12
Copy link
Author

For example, I can have two variables in different Node.js modules. Or even in different NPM packages. I want to have different Nest.js modules with same name, but in different NPM packages.

And what are benefits of this limitation? Maybe I can override any module in an application? This is not obvious.

And I can have two or more DYNAMIC modules with same name in application.
How should I override dynamic modules?

@kamilmysliwiec
Copy link
Member

See #3363

@mikeconley12
Copy link
Author

mikeconley12 commented Nov 8, 2019

@kamilmysliwiec
Thanks for the quick response! :) Does it fix my problem? When can it be merged to master?

@kamilmysliwiec
Copy link
Member

It should fix your problem :) We'll merge it shortly.

@kamilmysliwiec kamilmysliwiec added status: done 👏 and removed needs triage This issue has not been looked into labels Nov 8, 2019
@mikeconley12
Copy link
Author

Awesome! Thank you!

@Superd22
Copy link

I actually encountered the same problem with providers sharing the same name instead of modules.
Thanks for such a quick PR @kamilmysliwiec !

@kamilmysliwiec
Copy link
Member

Fixed in the latest release (modules with the same name)

@lock
Copy link

lock bot commented Feb 17, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 17, 2020
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

3 participants