@eggjs/core
Advanced tools
@@ -39,2 +39,3 @@ import { Timing } from "../utils/timing.js"; | ||
| readonly appInfo: EggAppInfo; | ||
| readonly outDir?: string; | ||
| dirs?: EggDirInfo[]; | ||
@@ -41,0 +42,0 @@ /** |
@@ -37,2 +37,3 @@ import utils_default from "../utils/index.js"; | ||
| appInfo; | ||
| outDir; | ||
| dirs; | ||
@@ -60,2 +61,3 @@ /** | ||
| this.pkg = readJSONSync(path.join(this.options.baseDir, "package.json")); | ||
| this.outDir = this.#resolveOutDir(); | ||
| if (process.env.EGG_TYPESCRIPT === "true" || this.pkg.egg && this.pkg.egg.typescript) { | ||
@@ -1096,7 +1098,33 @@ const tsConfigFile = path.join(this.options.baseDir, "tsconfig.json"); | ||
| fullPath = utils_default.resolvePath(filepath); | ||
| } catch { | ||
| return; | ||
| } | ||
| } catch {} | ||
| if (!fullPath) fullPath = this.#resolveFromOutDir(filepath); | ||
| return fullPath; | ||
| } | ||
| #resolveOutDir() { | ||
| if (this.pkg.egg?.outDir) { | ||
| debug("[resolveOutDir] use pkg.egg.outDir: %o", this.pkg.egg.outDir); | ||
| return this.pkg.egg.outDir; | ||
| } | ||
| const tsConfigFile = path.join(this.options.baseDir, "tsconfig.json"); | ||
| if (fs.existsSync(tsConfigFile)) try { | ||
| const tsConfig = JSON.parse(fs.readFileSync(tsConfigFile, "utf-8")); | ||
| if (tsConfig.compilerOptions?.outDir) { | ||
| debug("[resolveOutDir] use tsconfig.json compilerOptions.outDir: %o", tsConfig.compilerOptions.outDir); | ||
| return tsConfig.compilerOptions.outDir; | ||
| } | ||
| } catch {} | ||
| } | ||
| #resolveFromOutDir(filepath) { | ||
| if (!this.outDir) return; | ||
| const baseDir = this.options.baseDir; | ||
| if (!filepath.startsWith(baseDir + path.sep)) return; | ||
| const relativePath = path.relative(baseDir, filepath); | ||
| for (const ext of [".js", ".mjs"]) { | ||
| const outDirPath = path.join(baseDir, this.outDir, relativePath + ext); | ||
| if (fs.existsSync(outDirPath)) { | ||
| debug("[resolveModule:outDir] %o => %o", filepath, outDirPath); | ||
| return outDirPath; | ||
| } | ||
| } | ||
| } | ||
| }; | ||
@@ -1103,0 +1131,0 @@ function depCompatible(plugin) { |
+9
-9
| { | ||
| "name": "@eggjs/core", | ||
| "version": "7.0.2-beta.4", | ||
| "version": "7.0.2-beta.5", | ||
| "description": "A core plugin framework based on @eggjs/koa", | ||
@@ -44,7 +44,7 @@ "keywords": [ | ||
| "utility": "^2.5.0", | ||
| "@eggjs/extend2": "5.0.2-beta.4", | ||
| "@eggjs/koa": "3.1.2-beta.4", | ||
| "@eggjs/router": "4.0.2-beta.4", | ||
| "@eggjs/utils": "5.0.2-beta.4", | ||
| "@eggjs/path-matching": "3.0.2-beta.4" | ||
| "@eggjs/extend2": "5.0.2-beta.5", | ||
| "@eggjs/koa": "3.1.2-beta.5", | ||
| "@eggjs/router": "4.0.2-beta.5", | ||
| "@eggjs/utils": "5.0.2-beta.5", | ||
| "@eggjs/path-matching": "3.0.2-beta.5" | ||
| }, | ||
@@ -61,5 +61,5 @@ "devDependencies": { | ||
| "urllib": "^4.8.2", | ||
| "@eggjs/supertest": "9.0.2-beta.4", | ||
| "@eggjs/tsconfig": "3.1.2-beta.4", | ||
| "@eggjs/mock": "7.0.2-beta.4" | ||
| "@eggjs/mock": "7.0.2-beta.5", | ||
| "@eggjs/tsconfig": "3.1.2-beta.5", | ||
| "@eggjs/supertest": "9.0.2-beta.5" | ||
| }, | ||
@@ -66,0 +66,0 @@ "engines": { |
132370
0.88%3579
0.82%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated