egg 4.1.2-beta.5 → 4.1.2-beta.7

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/lib/egg.d.ts CHANGED
@@ -244,6 +244,11 @@ declare class EggApplicationCore extends EggCore {
244
244
  */
245
245
  dumpConfig(): void;
246
246
  dumpTiming(): void;
247
+ /**
248
+ * Generate and save startup manifest for faster subsequent startups.
249
+ * Only generates when no valid manifest was loaded (avoids overwriting during manifest-accelerated starts).
250
+ */
251
+ dumpManifest(): void;
247
252
  protected customEggPaths(): string[];
248
253
  get config(): EggAppConfig$1;
249
254
  /**
package/dist/lib/egg.js CHANGED
@@ -9,7 +9,7 @@ import { createLoggers } from "./core/logger.js";
9
9
  import { create } from "./core/messenger/index.js";
10
10
  import { convertObject } from "./core/utils.js";
11
11
  import assert from "node:assert";
12
- import { EggCore, Router, utils } from "@eggjs/core";
12
+ import { EggCore, ManifestStore, Router, utils } from "@eggjs/core";
13
13
  import path from "node:path";
14
14
  import fs from "node:fs";
15
15
  import http from "node:http";
@@ -127,6 +127,7 @@ var EggApplicationCore = class extends EggCore {
127
127
  const dumpStartTime = Date.now();
128
128
  this.dumpConfig();
129
129
  this.dumpTiming();
130
+ this.dumpManifest();
130
131
  this.coreLogger.info("[egg] dump config after ready, %sms", Date.now() - dumpStartTime);
131
132
  }));
132
133
  this.#setupTimeoutTimer();
@@ -139,7 +140,7 @@ var EggApplicationCore = class extends EggCore {
139
140
  this.lifecycle.registerBeforeClose(async () => {
140
141
  for (const clusterClient of this.#clusterClients) await close(clusterClient);
141
142
  this.#clusterClients = [];
142
- if (this.type === "application" && this.options.mode === "single") await this.agent.close();
143
+ if (this.type === "application" && this.options.mode === "single") await this.agent?.close();
143
144
  for (const logger of this.loggers.values()) logger.close();
144
145
  this.messenger.close();
145
146
  process.removeListener("unhandledRejection", this._unhandledRejectionHandler);
@@ -397,6 +398,22 @@ var EggApplicationCore = class extends EggCore {
397
398
  this.coreLogger.warn(`[egg] dumpTiming error: ${err.message}`);
398
399
  }
399
400
  }
401
+ /**
402
+ * Generate and save startup manifest for faster subsequent startups.
403
+ * Only generates when no valid manifest was loaded (avoids overwriting during manifest-accelerated starts).
404
+ */
405
+ dumpManifest() {
406
+ try {
407
+ if (this.loader.serverEnv === "local" && process.env.EGG_MANIFEST !== "true") return;
408
+ if (this.loader.manifest.data.generatedAt) return;
409
+ const manifest = this.loader.generateManifest();
410
+ ManifestStore.write(this.baseDir, manifest).catch((err) => {
411
+ this.coreLogger.warn("[egg] dumpManifest write error: %s", err.message);
412
+ });
413
+ } catch (err) {
414
+ this.coreLogger.warn("[egg] dumpManifest error: %s", err.message);
415
+ }
416
+ }
400
417
  customEggPaths() {
401
418
  return [path.dirname(import.meta.dirname), ...super.customEggPaths()];
402
419
  }
@@ -29,7 +29,7 @@ var AppWorkerLoader = class extends EggApplicationLoader {
29
29
  await this.loadService();
30
30
  await this.loadMiddleware();
31
31
  await this.loadController();
32
- await this.loadRouter();
32
+ if (!this.options.metadataOnly) await this.loadRouter();
33
33
  }
34
34
  };
35
35
 
@@ -13,6 +13,8 @@ interface StartEggOptions {
13
13
  mode?: "single";
14
14
  env?: string;
15
15
  plugins?: EggPlugin;
16
+ /** Skip lifecycle hooks, only trigger loadMetadata for manifest generation */
17
+ metadataOnly?: boolean;
16
18
  }
17
19
  interface SingleModeApplication extends Application {
18
20
  agent: SingleModeAgent;
package/dist/lib/start.js CHANGED
@@ -22,13 +22,18 @@ async function startEgg(options = {}) {
22
22
  AgentClass = framework.Agent;
23
23
  ApplicationClass = framework.Application;
24
24
  }
25
- const agent = new AgentClass({ ...options });
26
- await agent.ready();
25
+ let agent;
26
+ if (!options.metadataOnly) {
27
+ agent = new AgentClass({ ...options });
28
+ await agent.ready();
29
+ }
27
30
  const application = new ApplicationClass({ ...options });
28
- application.agent = agent;
29
- agent.application = application;
31
+ if (agent) {
32
+ application.agent = agent;
33
+ agent.application = application;
34
+ }
30
35
  await application.ready();
31
- application.messenger.broadcast("egg-ready");
36
+ if (!options.metadataOnly) application.messenger.broadcast("egg-ready");
32
37
  return application;
33
38
  }
34
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "4.1.2-beta.5",
3
+ "version": "4.1.2-beta.7",
4
4
  "description": "A web application framework for Node.js",
5
5
  "keywords": [
6
6
  "app",
@@ -98,34 +98,34 @@
98
98
  "type-fest": "^5.0.1",
99
99
  "urllib": "^4.8.2",
100
100
  "utility": "^2.5.0",
101
- "@eggjs/ajv-plugin": "4.0.2-beta.5",
102
- "@eggjs/cluster": "4.0.2-beta.5",
103
- "@eggjs/controller-plugin": "4.0.2-beta.5",
104
- "@eggjs/cookies": "4.0.2-beta.5",
105
- "@eggjs/core": "7.0.2-beta.5",
106
- "@eggjs/errors": "3.0.2-beta.5",
107
- "@eggjs/development": "5.0.2-beta.5",
108
- "@eggjs/aop-plugin": "4.0.2-beta.5",
109
- "@eggjs/eventbus-plugin": "4.0.2-beta.5",
110
- "@eggjs/dal-plugin": "4.0.2-beta.5",
111
- "@eggjs/extend2": "5.0.2-beta.5",
112
- "@eggjs/i18n": "4.0.2-beta.5",
113
- "@eggjs/jsonp": "4.0.2-beta.5",
114
- "@eggjs/logrotator": "5.0.2-beta.5",
115
- "@eggjs/schedule": "6.0.2-beta.5",
116
- "@eggjs/onerror": "4.0.2-beta.5",
117
- "@eggjs/orm-plugin": "4.0.2-beta.5",
118
- "@eggjs/multipart": "5.0.2-beta.5",
119
- "@eggjs/security": "5.0.2-beta.5",
120
- "@eggjs/schedule-plugin": "4.0.2-beta.5",
121
- "@eggjs/session": "5.0.2-beta.5",
122
- "@eggjs/tegg": "4.0.2-beta.5",
123
- "@eggjs/static": "4.0.2-beta.5",
124
- "@eggjs/tegg-config": "4.0.2-beta.5",
125
- "@eggjs/tegg-plugin": "4.0.2-beta.5",
126
- "@eggjs/view": "4.0.2-beta.5",
127
- "@eggjs/watcher": "5.0.2-beta.5",
128
- "@eggjs/utils": "5.0.2-beta.5"
101
+ "@eggjs/controller-plugin": "4.0.2-beta.7",
102
+ "@eggjs/cookies": "4.0.2-beta.7",
103
+ "@eggjs/dal-plugin": "4.0.2-beta.7",
104
+ "@eggjs/core": "7.0.2-beta.7",
105
+ "@eggjs/development": "5.0.2-beta.7",
106
+ "@eggjs/errors": "3.0.2-beta.7",
107
+ "@eggjs/i18n": "4.0.2-beta.7",
108
+ "@eggjs/cluster": "4.0.2-beta.7",
109
+ "@eggjs/aop-plugin": "4.0.2-beta.7",
110
+ "@eggjs/ajv-plugin": "4.0.2-beta.7",
111
+ "@eggjs/logrotator": "5.0.2-beta.7",
112
+ "@eggjs/eventbus-plugin": "4.0.2-beta.7",
113
+ "@eggjs/onerror": "4.0.2-beta.7",
114
+ "@eggjs/multipart": "5.0.2-beta.7",
115
+ "@eggjs/extend2": "5.0.2-beta.7",
116
+ "@eggjs/orm-plugin": "4.0.2-beta.7",
117
+ "@eggjs/jsonp": "4.0.2-beta.7",
118
+ "@eggjs/schedule-plugin": "4.0.2-beta.7",
119
+ "@eggjs/security": "5.0.2-beta.7",
120
+ "@eggjs/tegg": "4.0.2-beta.7",
121
+ "@eggjs/schedule": "6.0.2-beta.7",
122
+ "@eggjs/tegg-plugin": "4.0.2-beta.7",
123
+ "@eggjs/utils": "5.0.2-beta.7",
124
+ "@eggjs/tegg-config": "4.0.2-beta.7",
125
+ "@eggjs/view": "4.0.2-beta.7",
126
+ "@eggjs/watcher": "5.0.2-beta.7",
127
+ "@eggjs/static": "4.0.2-beta.7",
128
+ "@eggjs/session": "5.0.2-beta.7"
129
129
  },
130
130
  "devDependencies": {
131
131
  "@types/koa-bodyparser": "^4.3.12",
@@ -141,10 +141,10 @@
141
141
  "sdk-base": "^5.0.1",
142
142
  "spy": "^1.0.0",
143
143
  "typescript": "^5.9.3",
144
- "@eggjs/mock": "7.0.2-beta.5",
145
- "@eggjs/supertest": "9.0.2-beta.5",
146
- "@eggjs/tracer": "4.0.2-beta.5",
147
- "@eggjs/koa": "3.1.2-beta.5"
144
+ "@eggjs/koa": "3.1.2-beta.7",
145
+ "@eggjs/mock": "7.0.2-beta.7",
146
+ "@eggjs/supertest": "9.0.2-beta.7",
147
+ "@eggjs/tracer": "4.0.2-beta.7"
148
148
  },
149
149
  "engines": {
150
150
  "node": ">=22.18.0"