chore(build): re-apply build-reorg follow-ups (compat fallback + deploy docs) (#3127)

* build(compat): serve CLI falls back dist/ -> app/ for upgrade safety

Backward-compat hardening: the npm CLI prefers the new dist/ standalone but falls
back to the legacy app/ location, so an upgrade over a partially-replaced install
(or a package built before the app/->dist/ rename) still boots. Deployed runtimes
(VPS app/, Docker /app, Electron resources/app) are unchanged by design.

* docs(deploy): stop pm2 before rsync --delete to avoid transient chunk error

rsync --delete removing chunk files under a live server produced the transient [Shutdown] Cannot find module ./chunks/NNNNN.js. Stop the process first, then start with a clean module graph.

* test(cli): cover serve APP_DIR dist/->app/ backward-compat fallback
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-03 18:12:30 -03:00
committed by GitHub
parent 0231fbb335
commit c9620eb741
5 changed files with 55 additions and 10 deletions

View File

@@ -10,7 +10,11 @@ import { isTermux } from "../../../scripts/build/postinstallSupport.mjs";
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, "..", "..", "..");
const APP_DIR = join(ROOT, "dist");
// The standalone bundle ships in `dist/` (since the build-output-isolation
// refactor). Fall back to the legacy `app/` location so an upgrade over a
// partially-replaced install — or a package built before the rename — still
// boots. Backward-compatible by design: every deployed runtime keeps its path.
const APP_DIR = existsSync(join(ROOT, "dist", "server.js")) ? join(ROOT, "dist") : join(ROOT, "app");
function parsePort(value, fallback) {
const parsed = parseInt(String(value), 10);