@nestjs/core 10.2.8 → 10.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { Type } from '@nestjs/common/interfaces/type.interface';
3
3
  export declare class ModuleTokenFactory {
4
4
  private readonly moduleTokenCache;
5
5
  private readonly moduleIdsCache;
6
+ private readonly logger;
6
7
  create(metatype: Type<unknown>, dynamicModuleMetadata?: Partial<DynamicModule> | undefined): string;
7
8
  getStaticModuleToken(moduleId: string, moduleName: string): string;
8
9
  getStringifiedOpaqueToken(opaqueToken: object | undefined): string;
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModuleTokenFactory = void 0;
4
+ const common_1 = require("@nestjs/common");
4
5
  const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
5
6
  const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
7
  const crypto_1 = require("crypto");
7
8
  const fast_safe_stringify_1 = require("fast-safe-stringify");
9
+ const perf_hooks_1 = require("perf_hooks");
8
10
  const CLASS_STR = 'class ';
9
11
  const CLASS_STR_LEN = CLASS_STR.length;
10
12
  class ModuleTokenFactory {
11
13
  constructor() {
12
14
  this.moduleTokenCache = new Map();
13
15
  this.moduleIdsCache = new WeakMap();
16
+ this.logger = new common_1.Logger(ModuleTokenFactory.name, {
17
+ timestamp: true,
18
+ });
14
19
  }
15
20
  create(metatype, dynamicModuleMetadata) {
16
21
  const moduleId = this.getModuleId(metatype);
@@ -22,7 +27,13 @@ class ModuleTokenFactory {
22
27
  module: this.getModuleName(metatype),
23
28
  dynamic: dynamicModuleMetadata,
24
29
  };
30
+ const start = perf_hooks_1.performance.now();
25
31
  const opaqueTokenString = this.getStringifiedOpaqueToken(opaqueToken);
32
+ const timeSpentInMs = perf_hooks_1.performance.now() - start;
33
+ if (timeSpentInMs > 10) {
34
+ const formattedTimeSpent = timeSpentInMs.toFixed(2);
35
+ this.logger.warn(`The module "${opaqueToken.module}" is taking ${formattedTimeSpent}ms to serialize, this may be caused by larger objects statically assigned to the module. More details: https://github.com/nestjs/nest/issues/12738`);
36
+ }
26
37
  return this.hashString(opaqueTokenString);
27
38
  }
28
39
  getStaticModuleToken(moduleId, moduleName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/core",
3
- "version": "10.2.8",
3
+ "version": "10.2.9",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@core)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "uid": "2.0.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@nestjs/common": "10.2.8"
39
+ "@nestjs/common": "10.2.9"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@nestjs/common": "^10.0.0",
@@ -2,6 +2,6 @@ import { Type } from '@nestjs/common';
2
2
  export interface RouteTree {
3
3
  path: string;
4
4
  module?: Type<any>;
5
- children?: Routes | Type<any>[];
5
+ children?: (RouteTree | Type<any>)[];
6
6
  }
7
7
  export type Routes = RouteTree[];