@eggjs/core 7.0.2-beta.3 → 7.0.2-beta.5

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.
@@ -36,6 +36,7 @@ declare class EggLoader {
36
36
  readonly serverEnv: string;
37
37
  readonly serverScope: string;
38
38
  readonly appInfo: EggAppInfo;
39
+ readonly outDir?: string;
39
40
  dirs?: EggDirInfo[];
40
41
  /**
41
42
  * @class
@@ -34,6 +34,7 @@ var EggLoader = class {
34
34
  serverEnv;
35
35
  serverScope;
36
36
  appInfo;
37
+ outDir;
37
38
  dirs;
38
39
  /**
39
40
  * @class
@@ -56,6 +57,7 @@ var EggLoader = class {
56
57
  * @since 1.0.0
57
58
  */
58
59
  this.pkg = readJSONSync(path.join(this.options.baseDir, "package.json"));
60
+ this.outDir = this.#resolveOutDir();
59
61
  if (process.env.EGG_TYPESCRIPT === "true" || this.pkg.egg && this.pkg.egg.typescript) {
60
62
  const tsConfigFile = path.join(this.options.baseDir, "tsconfig.json");
61
63
  if (fs.existsSync(tsConfigFile)) register({ cwd: this.options.baseDir });
@@ -1091,11 +1093,37 @@ var EggLoader = class {
1091
1093
  let fullPath;
1092
1094
  try {
1093
1095
  fullPath = utils_default.resolvePath(filepath);
1094
- } catch {
1095
- return;
1096
- }
1096
+ } catch {}
1097
+ if (!fullPath) fullPath = this.#resolveFromOutDir(filepath);
1097
1098
  return fullPath;
1098
1099
  }
1100
+ #resolveOutDir() {
1101
+ if (this.pkg.egg?.outDir) {
1102
+ debug("[resolveOutDir] use pkg.egg.outDir: %o", this.pkg.egg.outDir);
1103
+ return this.pkg.egg.outDir;
1104
+ }
1105
+ const tsConfigFile = path.join(this.options.baseDir, "tsconfig.json");
1106
+ if (fs.existsSync(tsConfigFile)) try {
1107
+ const tsConfig = JSON.parse(fs.readFileSync(tsConfigFile, "utf-8"));
1108
+ if (tsConfig.compilerOptions?.outDir) {
1109
+ debug("[resolveOutDir] use tsconfig.json compilerOptions.outDir: %o", tsConfig.compilerOptions.outDir);
1110
+ return tsConfig.compilerOptions.outDir;
1111
+ }
1112
+ } catch {}
1113
+ }
1114
+ #resolveFromOutDir(filepath) {
1115
+ if (!this.outDir) return;
1116
+ const baseDir = this.options.baseDir;
1117
+ if (!filepath.startsWith(baseDir + path.sep)) return;
1118
+ const relativePath = path.relative(baseDir, filepath);
1119
+ for (const ext of [".js", ".mjs"]) {
1120
+ const outDirPath = path.join(baseDir, this.outDir, relativePath + ext);
1121
+ if (fs.existsSync(outDirPath)) {
1122
+ debug("[resolveModule:outDir] %o => %o", filepath, outDirPath);
1123
+ return outDirPath;
1124
+ }
1125
+ }
1126
+ }
1099
1127
  };
1100
1128
  function depCompatible(plugin) {
1101
1129
  if (plugin.dep && !(Array.isArray(plugin.dependencies) && plugin.dependencies.length > 0)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/core",
3
- "version": "7.0.2-beta.3",
3
+ "version": "7.0.2-beta.5",
4
4
  "description": "A core plugin framework based on @eggjs/koa",
5
5
  "keywords": [
6
6
  "egg",
@@ -41,11 +41,11 @@
41
41
  "ready-callback": "^4.0.0",
42
42
  "tsconfig-paths": "^4.2.0",
43
43
  "utility": "^2.5.0",
44
- "@eggjs/koa": "3.1.2-beta.3",
45
- "@eggjs/extend2": "5.0.2-beta.3",
46
- "@eggjs/router": "4.0.2-beta.3",
47
- "@eggjs/path-matching": "3.0.2-beta.3",
48
- "@eggjs/utils": "5.0.2-beta.3"
44
+ "@eggjs/extend2": "5.0.2-beta.5",
45
+ "@eggjs/koa": "3.1.2-beta.5",
46
+ "@eggjs/router": "4.0.2-beta.5",
47
+ "@eggjs/utils": "5.0.2-beta.5",
48
+ "@eggjs/path-matching": "3.0.2-beta.5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/js-yaml": "^4.0.9",
@@ -57,9 +57,9 @@
57
57
  "mm": "^4.0.2",
58
58
  "typescript": "^5.9.3",
59
59
  "urllib": "^4.8.2",
60
- "@eggjs/mock": "7.0.2-beta.3",
61
- "@eggjs/supertest": "9.0.2-beta.3",
62
- "@eggjs/tsconfig": "3.1.2-beta.3"
60
+ "@eggjs/mock": "7.0.2-beta.5",
61
+ "@eggjs/tsconfig": "3.1.2-beta.5",
62
+ "@eggjs/supertest": "9.0.2-beta.5"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=22.18.0"