Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
The console log is printed only once, unless alwaysTransient is set to true.
// my-custom-module.ts
import { Inject, Module } from '@nestjs/common';
import { ConfigurableModuleBuilder } from '@nestjs/common';
export const {
ConfigurableModuleClass,
MODULE_OPTIONS_TOKEN: MY_CUSTOM_MODULE_OPTIONS,
} = new ConfigurableModuleBuilder<{
baseUrl?: string;
}>().build();
@Module({})
export class MyCustomModule extends ConfigurableModuleClass {
constructor(
@Inject(MY_CUSTOM_MODULE_OPTIONS)
private readonly options,
) {
console.log(options);
super();
}
}
// app.module.ts
@Module({
imports: [
MyCustomModule.register({ baseUrl: 'https://google.com' }),
MyCustomModule.register({ baseUrl: 'https://google1.com' }),
MyCustomModule.register({ baseUrl: 'https://google2.com' }),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Steps to reproduce
No response
Expected behavior
Expecting the console log to run 3 times because the options are different in the providers array (as stated in the official nestjs advanced concepts course).
Package
- I don't know. Or some 3rd-party package
-
@nestjs/common
-
@nestjs/core
-
@nestjs/microservices
-
@nestjs/platform-express
-
@nestjs/platform-fastify
-
@nestjs/platform-socket.io
-
@nestjs/platform-ws
-
@nestjs/testing
-
@nestjs/websockets
- Other (see below)
Other package
No response
NestJS version
10.3.0
Packages versions
[System Information]
OS Version : Linux 6.1.69-1-MANJARO
NodeJS Version : v20.8.0
NPM Version : 10.1.0
[Nest CLI]
Nest CLI Version : 10.3.0
[Nest Platform Information]
platform-express version : 10.3.0
mapped-types version : 2.0.4
schematics version : 10.1.0
testing version : 10.3.0
common version : 10.3.0
core version : 10.3.0
cli version : 10.3.0
[Warnings]
The following packages are not in the same minor version
This could lead to runtime errors
* Under version 10.3
- @nestjs/platform-express 10.3.0
- @nestjs/common 10.3.0
- @nestjs/core 10.3.0
* Under version 10.1
- @nestjs/schematics 10.1.0
Node.js version
v20.8.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response