From 31a0b18232fdef0b7de06e70dc40d59f658e9a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Louren=C3=A7o?= Date: Fri, 17 Nov 2023 10:11:59 -0300 Subject: [PATCH] fixup! perf: prefer use factory instead of use value when possible --- .../inspector/e2e/fixtures/post-init-graph.json | 16 ++++++++-------- .../inspector/e2e/fixtures/pre-init-graph.json | 16 ++++++++-------- package.json | 2 +- packages/core/router/router-module.ts | 2 +- packages/microservices/module/clients.module.ts | 12 +++++++----- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/integration/inspector/e2e/fixtures/post-init-graph.json b/integration/inspector/e2e/fixtures/post-init-graph.json index 9e384a127e5..be476d57e32 100644 --- a/integration/inspector/e2e/fixtures/post-init-graph.json +++ b/integration/inspector/e2e/fixtures/post-init-graph.json @@ -60,10 +60,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "ExternalContextCreator" + "token": "ExternalContextCreator", + "initTime": 0 } }, "208171089": { @@ -800,10 +800,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "ModulesContainer" + "token": "ModulesContainer", + "initTime": 0 } }, "-326832201": { @@ -816,10 +816,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "HttpAdapterHost" + "token": "HttpAdapterHost", + "initTime": 0 } }, "-702581189": { @@ -848,10 +848,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "SerializedGraph" + "token": "SerializedGraph", + "initTime": 0 } }, "-1251270035": { diff --git a/integration/inspector/e2e/fixtures/pre-init-graph.json b/integration/inspector/e2e/fixtures/pre-init-graph.json index 2152f9a5e87..7f35f11538f 100644 --- a/integration/inspector/e2e/fixtures/pre-init-graph.json +++ b/integration/inspector/e2e/fixtures/pre-init-graph.json @@ -60,10 +60,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "ExternalContextCreator" + "token": "ExternalContextCreator", + "initTime": 0 } }, "208171089": { @@ -784,10 +784,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "ModulesContainer" + "token": "ModulesContainer", + "initTime": 0 } }, "-326832201": { @@ -800,10 +800,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "HttpAdapterHost" + "token": "HttpAdapterHost", + "initTime": 0 } }, "-702581189": { @@ -832,10 +832,10 @@ "sourceModuleName": "InternalCoreModule", "durable": false, "static": true, - "scope": 0, "transient": false, "exported": true, - "token": "SerializedGraph" + "token": "SerializedGraph", + "initTime": 0 } }, "-1251270035": { diff --git a/package.json b/package.json index 5a622352be1..c4c3e6a492d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "test:dev": "mocha -w --watch-files \"packages\" packages/**/*.spec.ts", "pretest:cov": "npm run clean", "test:cov": "nyc mocha packages/**/*.spec.ts --reporter spec", - "test:integration": "mocha \"integration/*/{,!(node_modules)/**/}/*.spec.ts\"", + "test:integration": "mocha --reporter-option maxDiffSize=0 \"integration/*/{,!(node_modules)/**/}/*.spec.ts\"", "test:docker:up": "docker-compose -f integration/docker-compose.yml up -d", "test:docker:down": "docker-compose -f integration/docker-compose.yml down", "lint": "concurrently 'npm run lint:packages' 'npm run lint:integration' 'npm run lint:spec'", diff --git a/packages/core/router/router-module.ts b/packages/core/router/router-module.ts index c21b7c0762b..333ef41aefd 100644 --- a/packages/core/router/router-module.ts +++ b/packages/core/router/router-module.ts @@ -32,7 +32,7 @@ export class RouterModule { providers: [ { provide: ROUTES, - useFactory: () => routes, + useValue: routes, }, ], }; diff --git a/packages/microservices/module/clients.module.ts b/packages/microservices/module/clients.module.ts index cbb053b388f..dad7c69f231 100644 --- a/packages/microservices/module/clients.module.ts +++ b/packages/microservices/module/clients.module.ts @@ -17,11 +17,13 @@ import { export class ClientsModule { static register(options: ClientsModuleOptions): DynamicModule { const clientsOptions = !Array.isArray(options) ? options.clients : options; - const clients = (clientsOptions || []).map(item => ({ - provide: item.name, - useFactory: () => - this.assignOnAppShutdownHook(ClientProxyFactory.create(item)), - })); + const clients = (clientsOptions || []).map(item => { + return { + provide: item.name, + useFactory: () => + this.assignOnAppShutdownHook(ClientProxyFactory.create(item)), + }; + }); return { module: ClientsModule, global: !Array.isArray(options) && options.isGlobal,