@midwayjs/core 4.0.0-beta.8 → 4.0.0-beta.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.
@@ -8,7 +8,7 @@ const pathFileUtil_1 = require("../util/pathFileUtil");
8
8
  const metadataManager_1 = require("./metadataManager");
9
9
  const types_1 = require("../util/types");
10
10
  const error_1 = require("../error");
11
- const debug = require('util').debuglog('midway:core');
11
+ const debug = require('util').debuglog('midway:debug');
12
12
  /**
13
13
  * This class is used to manage the decorator data of the class
14
14
  *
@@ -54,7 +54,7 @@ class DecoratorManager {
54
54
  meta.id = identifier;
55
55
  // save class id and uuid
56
56
  metadataManager_1.MetadataManager.defineMetadata(constant_1.PROVIDE_KEY, meta, target);
57
- debug(`update provide: ${target.name} -> ${meta.uuid}`);
57
+ debug(`[core]: Update provide: ${target.name} -> ${meta.uuid}`);
58
58
  }
59
59
  }
60
60
  }
@@ -68,7 +68,7 @@ class DecoratorManager {
68
68
  uuid,
69
69
  name: (0, camelCase_1.camelCase)(target.name),
70
70
  }, target);
71
- debug(`save provide: ${target.name} -> ${uuid}`);
71
+ debug(`[core]: Save provide: ${target.name} -> ${uuid}`);
72
72
  }
73
73
  return target;
74
74
  }
@@ -28,6 +28,7 @@ export declare const loadModule: (p: string, options?: {
28
28
  loadMode?: "commonjs" | "esm";
29
29
  safeLoad?: boolean;
30
30
  warnOnLoadError?: boolean;
31
+ extraModuleRoot?: string[];
31
32
  }) => Promise<any>;
32
33
  /**
33
34
  * load module sync, and it must be commonjs mode
@@ -96,7 +96,22 @@ const loadModule = async (p, options = {}) => {
96
96
  try {
97
97
  if (options.enableCache) {
98
98
  if (options.loadMode === 'commonjs') {
99
- return require(p);
99
+ try {
100
+ return require(p);
101
+ }
102
+ catch (_) {
103
+ for (const extraPath of [
104
+ process.cwd(),
105
+ ...(options.extraModuleRoot || []),
106
+ ]) {
107
+ try {
108
+ return require(require.resolve(p, { paths: [extraPath] }));
109
+ }
110
+ catch (_) {
111
+ // do nothing
112
+ }
113
+ }
114
+ }
100
115
  }
101
116
  else {
102
117
  // if json file, import need add options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0-beta.9",
4
4
  "description": "midway core",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "license": "MIT",
24
24
  "devDependencies": {
25
- "@midwayjs/logger": "^3.0.0",
25
+ "@midwayjs/logger": "^4.0.0",
26
26
  "eventsource": "2.0.2",
27
27
  "koa": "3.0.3",
28
28
  "mm": "3.4.0",
@@ -61,5 +61,5 @@
61
61
  "types": "./dist/functional/index.d.ts"
62
62
  }
63
63
  },
64
- "gitHead": "355e55949fdd132b0bdcb4830222a0a027e92ded"
64
+ "gitHead": "771e83974ef9f3d78c296e4ee0c8c68db44f6b31"
65
65
  }