ecopages 0.2.0-beta.3 → 0.2.0-beta.31
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/README.md +38 -8
- package/bin/launch-plan.js +26 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,14 +34,14 @@ bun dev
|
|
|
34
34
|
|
|
35
35
|
Server and build commands accept the following options. They automatically map to the equivalent environment variables for the underlying process:
|
|
36
36
|
|
|
37
|
-
| Option | Env Var | Description
|
|
38
|
-
| :------------------------- | :---------------------- |
|
|
39
|
-
| `-p, --port <port>` | `ECOPAGES_PORT` | Server port (default 3000)
|
|
40
|
-
| `-n, --hostname <host>` | `ECOPAGES_HOSTNAME` | Server hostname
|
|
41
|
-
| `-b, --base-url <url>` | `ECOPAGES_BASE_URL` | Base URL string
|
|
42
|
-
| `-d, --debug` | `ECOPAGES_LOGGER_DEBUG` | Enables debug
|
|
43
|
-
| `-r, --react-fast-refresh` | | Enables React Fast Refresh
|
|
44
|
-
| `--runtime <runtime>` | | Force execution via `bun` or `node`
|
|
37
|
+
| Option | Env Var | Description |
|
|
38
|
+
| :------------------------- | :---------------------- | :-------------------------------------------------------- |
|
|
39
|
+
| `-p, --port <port>` | `ECOPAGES_PORT` | Server port (default 3000) |
|
|
40
|
+
| `-n, --hostname <host>` | `ECOPAGES_HOSTNAME` | Server hostname |
|
|
41
|
+
| `-b, --base-url <url>` | `ECOPAGES_BASE_URL` | Base URL string |
|
|
42
|
+
| `-d, --debug` | `ECOPAGES_LOGGER_DEBUG` | Enables debug logging and startup phase trace (see below) |
|
|
43
|
+
| `-r, --react-fast-refresh` | | Enables React Fast Refresh |
|
|
44
|
+
| `--runtime <runtime>` | | Force execution via `bun` or `node` |
|
|
45
45
|
|
|
46
46
|
### Runtime Detection
|
|
47
47
|
|
|
@@ -63,6 +63,36 @@ ecopages dev --port 8080 --debug
|
|
|
63
63
|
ecopages dev -r
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
### Debug logging and startup trace
|
|
67
|
+
|
|
68
|
+
Set these in `.env` or on the command line when diagnosing slow dev startup or first page load.
|
|
69
|
+
|
|
70
|
+
| Env var | CLI | What you get |
|
|
71
|
+
| :---------------------------- | :--------------------- | :--------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `ECOPAGES_LOGGER_DEBUG=true` | `ecopages dev --debug` | Verbose `[@ecopages/core]` logs across the stack, plus **startup phase trace** lines on stderr |
|
|
73
|
+
| `ECOPAGES_STARTUP_TRACE=true` | — | **Only** the phase trace (no extra debug noise). Useful when measuring first-open latency |
|
|
74
|
+
|
|
75
|
+
Trace lines are prefixed with `[ecopages:startup-trace]` and look like:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
[ecopages:startup-trace] phase=config-ready wallMs=1271
|
|
79
|
+
[ecopages:startup-trace] phase=setupAppRuntimePlugins durationMs=714 wallMs=1999
|
|
80
|
+
[ecopages:startup-trace] phase=route-registry durationMs=1 wallMs=2000
|
|
81
|
+
[ecopages:startup-trace] phase=server-listen durationMs=45 wallMs=2046
|
|
82
|
+
[ecopages:startup-trace] phase=first-request-ssr durationMs=5296 wallMs=12495
|
|
83
|
+
[ecopages:startup-trace] summary path=/docs/getting-started/introduction bundleCount=13 clientBundleBytes=858396 wallMs=12496
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Phases: config ready → runtime plugins → route registry → server listening → first request SSR. The summary includes bundle count and total client JS bytes for that first request.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Focused perf trace only
|
|
90
|
+
ECOPAGES_STARTUP_TRACE=true pnpm dev
|
|
91
|
+
|
|
92
|
+
# Full debug + trace
|
|
93
|
+
ecopages dev --debug
|
|
94
|
+
```
|
|
95
|
+
|
|
66
96
|
## Ecosystem & Plugins
|
|
67
97
|
|
|
68
98
|
Ecopages relies on a modular architecture. Core logic and framework integrations are published as `@ecopages/*` packages on [npm](https://www.npmjs.com/org/ecopages).
|
package/bin/launch-plan.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parseEnv } from "node:util";
|
|
4
4
|
import { SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from "@ecopages/core/utils/resolve-entry-file";
|
|
5
|
+
const SERVER_BUNDLE_MANIFEST_FILENAME = "manifest.json";
|
|
5
6
|
const nodeRequirePreload = import.meta.resolve("./node-require-preload.js");
|
|
6
7
|
const tsxLoader = import.meta.resolve("tsx/esm");
|
|
7
8
|
function getEnvFilePaths(nodeEnv) {
|
|
@@ -76,15 +77,38 @@ function inferLaunchMode(args, launchMode) {
|
|
|
76
77
|
}
|
|
77
78
|
return "start";
|
|
78
79
|
}
|
|
80
|
+
function resolveProductionServerEntry(cwd = process.cwd()) {
|
|
81
|
+
const manifestPath = path.join(cwd, "dist", SERVER_BUNDLE_DIR, SERVER_BUNDLE_MANIFEST_FILENAME);
|
|
82
|
+
if (existsSync(manifestPath)) {
|
|
83
|
+
try {
|
|
84
|
+
const parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
85
|
+
if (parsed?.serverEntry) {
|
|
86
|
+
const fromManifest = path.isAbsolute(parsed.serverEntry) ? parsed.serverEntry : path.join(path.dirname(manifestPath), parsed.serverEntry);
|
|
87
|
+
if (existsSync(fromManifest)) {
|
|
88
|
+
return fromManifest;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (parsed?.distDir) {
|
|
92
|
+
const fromDistDir = path.join(parsed.distDir, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME);
|
|
93
|
+
if (existsSync(fromDistDir)) {
|
|
94
|
+
return fromDistDir;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const legacyPath = path.join(cwd, "dist", SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME);
|
|
101
|
+
return existsSync(legacyPath) ? legacyPath : void 0;
|
|
102
|
+
}
|
|
79
103
|
function createLaunchPlan(args, options, entryFile, launchMode) {
|
|
80
104
|
const resolvedOptions = options ?? {};
|
|
81
105
|
const resolvedEntryFile = entryFile ?? "app.ts";
|
|
82
106
|
const { envOverrides, env } = buildLaunchEnv(resolvedOptions);
|
|
83
107
|
const runtime = detectRuntime(resolvedOptions);
|
|
84
108
|
const resolvedLaunchMode = inferLaunchMode(args, launchMode);
|
|
85
|
-
const distServerApp =
|
|
109
|
+
const distServerApp = resolveProductionServerEntry(process.cwd());
|
|
86
110
|
const shouldUseBundle = usesProductionBundle(resolvedLaunchMode);
|
|
87
|
-
const useBundle = shouldUseBundle &&
|
|
111
|
+
const useBundle = shouldUseBundle && Boolean(distServerApp);
|
|
88
112
|
if (shouldUseBundle && !useBundle) {
|
|
89
113
|
throw new Error("No production bundle found. Run `ecopages build` before starting in production mode.");
|
|
90
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecopages",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.31",
|
|
4
4
|
"description": "CLI utilities for Ecopages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"ecopages": "bin/cli.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ecopages/core": "0.2.0-beta.
|
|
35
|
+
"@ecopages/core": "0.2.0-beta.31",
|
|
36
36
|
"@ecopages/logger": "^0.2.3",
|
|
37
37
|
"giget": "^2.0.0",
|
|
38
38
|
"tsx": "^4.22.3"
|