@eggjs/tegg-plugin 4.0.2-beta.6 → 4.0.2-beta.8
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 +1 -0
- package/dist/app.js +7 -0
- package/dist/lib/EggModuleLoader.d.ts +11 -1
- package/dist/lib/EggModuleLoader.js +32 -3
- package/package.json +18 -18
package/dist/app.d.ts
CHANGED
package/dist/app.js
CHANGED
|
@@ -3,12 +3,14 @@ import "./lib/AppLoadUnitInstance.js";
|
|
|
3
3
|
import "./lib/EggCompatibleObject.js";
|
|
4
4
|
import { CompatibleUtil } from "./lib/CompatibleUtil.js";
|
|
5
5
|
import { ConfigSourceLoadUnitHook } from "./lib/ConfigSourceLoadUnitHook.js";
|
|
6
|
+
import { EggModuleLoader } from "./lib/EggModuleLoader.js";
|
|
6
7
|
import { ModuleHandler } from "./lib/ModuleHandler.js";
|
|
7
8
|
import { EggContextCompatibleHook } from "./lib/EggContextCompatibleHook.js";
|
|
8
9
|
import { EggContextHandler } from "./lib/EggContextHandler.js";
|
|
9
10
|
import { EggQualifierProtoHook } from "./lib/EggQualifierProtoHook.js";
|
|
10
11
|
import { hijackRunInBackground } from "./lib/run_in_background.js";
|
|
11
12
|
import { LoadUnitMultiInstanceProtoHook } from "@eggjs/metadata";
|
|
13
|
+
import { LoaderFactory } from "@eggjs/tegg-loader";
|
|
12
14
|
|
|
13
15
|
//#region src/app.ts
|
|
14
16
|
var TeggAppBoot = class {
|
|
@@ -42,6 +44,11 @@ var TeggAppBoot = class {
|
|
|
42
44
|
this.compatibleHook = new EggContextCompatibleHook(this.app.moduleHandler);
|
|
43
45
|
this.app.eggContextLifecycleUtil.registerLifecycle(this.compatibleHook);
|
|
44
46
|
}
|
|
47
|
+
async loadMetadata() {
|
|
48
|
+
if (!this.app.moduleReferences) return;
|
|
49
|
+
const moduleDescriptors = await LoaderFactory.loadApp(this.app.moduleReferences);
|
|
50
|
+
EggModuleLoader.collectTeggManifest(this.app, moduleDescriptors);
|
|
51
|
+
}
|
|
45
52
|
async beforeClose() {
|
|
46
53
|
CompatibleUtil.clean();
|
|
47
54
|
await this.app.moduleHandler.destroy();
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { GlobalGraph, GlobalGraphBuildHook } from "@eggjs/metadata";
|
|
1
|
+
import { GlobalGraph, GlobalGraphBuildHook, ModuleDescriptor } from "@eggjs/metadata";
|
|
2
|
+
import { TeggManifestExtension } from "@eggjs/tegg-loader";
|
|
3
|
+
import { ModuleReference } from "@eggjs/tegg-types";
|
|
2
4
|
import { Application } from "egg";
|
|
3
5
|
|
|
4
6
|
//#region src/lib/EggModuleLoader.d.ts
|
|
@@ -10,6 +12,14 @@ declare class EggModuleLoader {
|
|
|
10
12
|
registerBuildHook(hook: GlobalGraphBuildHook): void;
|
|
11
13
|
private loadApp;
|
|
12
14
|
private buildAppGraph;
|
|
15
|
+
/**
|
|
16
|
+
* Build tegg manifest data from module references and descriptors.
|
|
17
|
+
*/
|
|
18
|
+
static buildTeggManifestData(moduleReferences: readonly ModuleReference[], moduleDescriptors: readonly ModuleDescriptor[]): TeggManifestExtension;
|
|
19
|
+
/**
|
|
20
|
+
* Collect tegg manifest data and store in manifest extensions.
|
|
21
|
+
*/
|
|
22
|
+
static collectTeggManifest(app: Application, moduleDescriptors: readonly ModuleDescriptor[]): void;
|
|
13
23
|
private loadModule;
|
|
14
24
|
load(): Promise<void>;
|
|
15
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EggAppLoader } from "./EggAppLoader.js";
|
|
2
2
|
import { EggLoadUnitType, GlobalGraph, LoadUnitFactory, ModuleDescriptorDumper } from "@eggjs/metadata";
|
|
3
|
-
import { LoaderFactory } from "@eggjs/tegg-loader";
|
|
3
|
+
import { LoaderFactory, TEGG_MANIFEST_KEY } from "@eggjs/tegg-loader";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/EggModuleLoader.ts
|
|
6
|
-
var EggModuleLoader = class {
|
|
6
|
+
var EggModuleLoader = class EggModuleLoader {
|
|
7
7
|
app;
|
|
8
8
|
globalGraph;
|
|
9
9
|
pendingBuildHooks = [];
|
|
@@ -24,13 +24,42 @@ var EggModuleLoader = class {
|
|
|
24
24
|
const modulePlugin = this.app.moduleReferences.find((t) => t.path === plugin.path);
|
|
25
25
|
if (modulePlugin) modulePlugin.optional = false;
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const manifestTegg = this.app.loader.manifest.getExtension(TEGG_MANIFEST_KEY);
|
|
28
|
+
const loadAppManifest = manifestTegg?.moduleDescriptors?.length ? manifestTegg : void 0;
|
|
29
|
+
const moduleDescriptors = await LoaderFactory.loadApp(this.app.moduleReferences, loadAppManifest);
|
|
30
|
+
if (!loadAppManifest) EggModuleLoader.collectTeggManifest(this.app, moduleDescriptors);
|
|
28
31
|
for (const moduleDescriptor of moduleDescriptors) ModuleDescriptorDumper.dump(moduleDescriptor, { dumpDir: this.app.baseDir }).catch((e) => {
|
|
29
32
|
e.message = "dump module descriptor failed: " + e.message;
|
|
30
33
|
this.app.logger.warn(e);
|
|
31
34
|
});
|
|
32
35
|
return await GlobalGraph.create(moduleDescriptors);
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Build tegg manifest data from module references and descriptors.
|
|
39
|
+
*/
|
|
40
|
+
static buildTeggManifestData(moduleReferences, moduleDescriptors) {
|
|
41
|
+
return {
|
|
42
|
+
moduleReferences: moduleReferences.map((ref) => ({
|
|
43
|
+
name: ref.name,
|
|
44
|
+
path: ref.path,
|
|
45
|
+
optional: ref.optional,
|
|
46
|
+
loaderType: ref.loaderType
|
|
47
|
+
})),
|
|
48
|
+
moduleDescriptors: moduleDescriptors.map((desc) => ({
|
|
49
|
+
name: desc.name,
|
|
50
|
+
unitPath: desc.unitPath,
|
|
51
|
+
optional: desc.optional,
|
|
52
|
+
decoratedFiles: ModuleDescriptorDumper.getDecoratedFiles(desc)
|
|
53
|
+
}))
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Collect tegg manifest data and store in manifest extensions.
|
|
58
|
+
*/
|
|
59
|
+
static collectTeggManifest(app, moduleDescriptors) {
|
|
60
|
+
const data = EggModuleLoader.buildTeggManifestData(app.moduleReferences, moduleDescriptors);
|
|
61
|
+
app.loader.manifest.setExtension(TEGG_MANIFEST_KEY, data);
|
|
62
|
+
}
|
|
34
63
|
async loadModule() {
|
|
35
64
|
this.globalGraph.build();
|
|
36
65
|
this.globalGraph.sort();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/tegg-plugin",
|
|
3
|
-
"version": "4.0.2-beta.
|
|
3
|
+
"version": "4.0.2-beta.8",
|
|
4
4
|
"description": "module plugin for egg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"egg",
|
|
@@ -59,30 +59,30 @@
|
|
|
59
59
|
"await-first": "^1.0.0",
|
|
60
60
|
"extend2": "^4.0.0",
|
|
61
61
|
"sdk-base": "^5.0.1",
|
|
62
|
-
"@eggjs/
|
|
63
|
-
"@eggjs/
|
|
64
|
-
"@eggjs/
|
|
65
|
-
"@eggjs/tegg-
|
|
66
|
-
"@eggjs/dynamic-inject-runtime": "4.0.2-beta.
|
|
67
|
-
"@eggjs/tegg-
|
|
68
|
-
"@eggjs/tegg-
|
|
69
|
-
"@eggjs/
|
|
70
|
-
"@eggjs/
|
|
71
|
-
"@eggjs/background-task": "4.0.2-beta.
|
|
62
|
+
"@eggjs/lifecycle": "4.0.2-beta.8",
|
|
63
|
+
"@eggjs/metadata": "4.0.2-beta.8",
|
|
64
|
+
"@eggjs/module-common": "4.0.2-beta.8",
|
|
65
|
+
"@eggjs/tegg-common-util": "4.0.2-beta.8",
|
|
66
|
+
"@eggjs/dynamic-inject-runtime": "4.0.2-beta.8",
|
|
67
|
+
"@eggjs/tegg-loader": "4.0.2-beta.8",
|
|
68
|
+
"@eggjs/tegg-runtime": "4.0.2-beta.8",
|
|
69
|
+
"@eggjs/tegg-types": "4.0.2-beta.8",
|
|
70
|
+
"@eggjs/core-decorator": "4.0.2-beta.8",
|
|
71
|
+
"@eggjs/background-task": "4.0.2-beta.8"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/node": "^24.10.2",
|
|
75
75
|
"egg-logger": "^3.5.0",
|
|
76
76
|
"typescript": "^5.9.3",
|
|
77
|
-
"@eggjs/mock": "7.0.2-beta.
|
|
78
|
-
"@eggjs/tegg
|
|
79
|
-
"@eggjs/tegg": "4.0.2-beta.
|
|
80
|
-
"
|
|
81
|
-
"
|
|
77
|
+
"@eggjs/mock": "7.0.2-beta.8",
|
|
78
|
+
"@eggjs/tegg": "4.0.2-beta.8",
|
|
79
|
+
"@eggjs/tegg-config": "4.0.2-beta.8",
|
|
80
|
+
"@eggjs/tracer": "4.0.2-beta.8",
|
|
81
|
+
"egg": "4.1.2-beta.8"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@eggjs/tegg-config": "4.0.2-beta.
|
|
85
|
-
"egg": "4.1.2-beta.
|
|
84
|
+
"@eggjs/tegg-config": "4.0.2-beta.8",
|
|
85
|
+
"egg": "4.1.2-beta.8"
|
|
86
86
|
},
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=22.18.0"
|