@eggjs/tegg-config 4.0.2-beta.3 → 4.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.
package/dist/app.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Application, ILifecycleBoot } from "egg";
2
2
 
3
3
  //#region src/app.d.ts
4
4
  declare class App implements ILifecycleBoot {
5
+ #private;
5
6
  private readonly app;
6
7
  constructor(app: Application);
7
8
  configWillLoad(): void;
package/dist/app.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { ModuleScanner } from "./lib/ModuleScanner.js";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
2
4
  import { debuglog } from "node:util";
3
5
  import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
4
6
 
@@ -13,8 +15,15 @@ var App = class {
13
15
  }
14
16
  configWillLoad() {
15
17
  const { readModuleOptions } = this.app.config.tegg;
16
- const moduleScanner = new ModuleScanner(this.app.baseDir, readModuleOptions);
17
- this.app.moduleReferences = moduleScanner.loadModuleReferences();
18
+ const outDir = this.app.loader.outDir;
19
+ if (outDir) {
20
+ const extraFilePattern = readModuleOptions.extraFilePattern || [];
21
+ const excludePattern = `!**/${outDir}`;
22
+ if (!extraFilePattern.includes(excludePattern)) readModuleOptions.extraFilePattern = [...extraFilePattern, excludePattern];
23
+ }
24
+ let moduleReferences = new ModuleScanner(this.app.baseDir, readModuleOptions).loadModuleReferences();
25
+ if (outDir) moduleReferences = this.#rewriteModulePaths(moduleReferences, outDir);
26
+ this.app.moduleReferences = moduleReferences;
18
27
  debug("load moduleReferences: %o", this.app.moduleReferences);
19
28
  this.app.moduleConfigs = {};
20
29
  for (const reference of this.app.moduleReferences) {
@@ -32,6 +41,23 @@ var App = class {
32
41
  }
33
42
  debug("load moduleConfigs: %o", this.app.moduleConfigs);
34
43
  }
44
+ #rewriteModulePaths(refs, outDir) {
45
+ const baseDir = this.app.baseDir;
46
+ return refs.map((ref) => {
47
+ if (!ref.path.startsWith(baseDir + path.sep)) return ref;
48
+ const relativePath = path.relative(baseDir, ref.path);
49
+ if (relativePath.startsWith(outDir + path.sep)) return ref;
50
+ const outDirPath = path.join(baseDir, outDir, relativePath);
51
+ if (fs.existsSync(outDirPath)) {
52
+ debug("rewrite module path: %o => %o", ref.path, outDirPath);
53
+ return {
54
+ ...ref,
55
+ path: outDirPath
56
+ };
57
+ }
58
+ return ref;
59
+ });
60
+ }
35
61
  async beforeClose() {
36
62
  ModuleConfigUtil.setConfigNames(void 0);
37
63
  }
@@ -1,7 +1,7 @@
1
- import { debuglog } from "node:util";
2
- import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
3
1
  import { readFileSync } from "node:fs";
4
2
  import path from "node:path";
3
+ import { debuglog } from "node:util";
4
+ import { ModuleConfigUtil } from "@eggjs/tegg-common-util";
5
5
  import { importResolve } from "@eggjs/utils";
6
6
 
7
7
  //#region src/lib/ModuleScanner.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/tegg-config",
3
- "version": "4.0.2-beta.3",
3
+ "version": "4.0.2-beta.5",
4
4
  "description": "module config plugin for egg",
5
5
  "keywords": [
6
6
  "config",
@@ -39,17 +39,17 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@eggjs/tegg-common-util": "4.0.2-beta.3",
43
- "@eggjs/utils": "5.0.2-beta.3"
42
+ "@eggjs/tegg-common-util": "4.0.2-beta.5",
43
+ "@eggjs/utils": "5.0.2-beta.5"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^24.10.2",
47
47
  "typescript": "^5.9.3",
48
- "egg": "4.1.2-beta.3",
49
- "@eggjs/mock": "7.0.2-beta.3"
48
+ "egg": "4.1.2-beta.5",
49
+ "@eggjs/mock": "7.0.2-beta.5"
50
50
  },
51
51
  "peerDependencies": {
52
- "egg": "4.1.2-beta.3"
52
+ "egg": "4.1.2-beta.5"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=22.18.0"