mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-22 23:22:09 +03:00
fix(build): ensure standalone package.json declares module type for Node 24 worker compatibility (#10836)
Obrigado — corrige um warning real de runtime em produção sob Node.js 24: o package.json do standalone gerado pelo Next.js não declara "type": "module", forçando reparse de todo worker thread ESM (callLogArtifactWorker, onnxWorker) a cada spawn. Validação (worktree combinado a partir de origin/release/v3.8.50, 0 conflitos): - typecheck:core limpo, complexity/cognitive-complexity dentro do baseline - Confirmado que colocate-standalone.mjs escreve "type": "module" corretamente; testado sob Node 24.19.0, workers sobem sem warning de reparse
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*
|
||||
* Run manually after a build, or automatically via the `postbuild` npm hook.
|
||||
*/
|
||||
import { cpSync, existsSync, mkdirSync } from "node:fs";
|
||||
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
@@ -107,3 +107,22 @@ for (const pkg of closure) {
|
||||
console.log(
|
||||
`[colocate-standalone] ✅ optional-dep closure: ${closure.length} packages (copied ${copied})`
|
||||
);
|
||||
|
||||
// 3) Ensure standalone package.json declares "type": "module" so Node 24 runs ESM worker bundles without warning
|
||||
const standalonePkgPath = join(STANDALONE, "package.json");
|
||||
if (existsSync(standalonePkgPath)) {
|
||||
try {
|
||||
const rawPkg = readFileSync(standalonePkgPath, "utf8");
|
||||
const pkgJson = JSON.parse(rawPkg);
|
||||
if (!pkgJson.type) {
|
||||
pkgJson.type = "module";
|
||||
writeFileSync(standalonePkgPath, JSON.stringify(pkgJson, null, 2) + "\n", "utf8");
|
||||
console.log("[colocate-standalone] ✅ standalone package.json configured with type: module");
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
"[colocate-standalone] ⚠️ could not update standalone package.json:",
|
||||
err.message
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user