Skip to content

fix(build): ensure standalone package.json declares module type for Node 24 worker compatibility - #10836

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
adevwithpurpose:fix/standalone-package-json-module-type
Aug 20, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
adevwithpurpose:fix/standalone-package-json-module-type

Conversation

@adevwithpurpose

Copy link
Copy Markdown
Contributor

Summary

Updates scripts/build/colocate-standalone.mjs to ensure the generated Next.js standalone package.json declares "type": "module".

Problem & Motivation

When OmniRoute is built with standalone output and run under Node.js 24, colocated worker threads (such as callLogArtifactWorker.js or onnxWorker.js) are bundled in ESM format (--format=esm). Because Next.js's default standalone tracer produces a package.json without an explicit module type, Node.js 24 emits:

(node:XXXXX) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of .../callLogArtifactWorker.js is not specified and it doesn't parse as CommonJS. Reparsing as ES module because module syntax was detected.

This forces a runtime parsing retry for every newly spawned worker thread and emits repetitive warnings in production logs.

Solution

In the standalone post-build co-location step (colocate-standalone.mjs), check the generated standalone/package.json and set "type": "module" if absent.

Verification

  • Confirmed colocate-standalone.mjs executes and writes "type": "module" to package.json.
  • Tested worker thread spawn under Node.js v24.19.0: workers boot instantaneously without reparsing warnings.

…ode 24 worker compatibility

- Update colocate-standalone.mjs to ensure standalone distributions include type: module in package.json
- Eliminates Node 24 MODULE_TYPELESS_PACKAGE_JSON runtime reparsing overhead and warnings when worker threads are spawned
@diegosouzapw
diegosouzapw merged commit 2c84ce1 into diegosouzapw:release/v3.8.50 Aug 20, 2026
5 checks passed
diegosouzapw pushed a commit that referenced this pull request Aug 21, 2026
…stays CJS (#10936)

Validado no worktree combinado: typecheck:core, changelog-integrity, complexity, cognitive-complexity, file-size, lint e teste focado (colocate-standalone-esm-scope) todos verdes. Fix real, correção de regressão introduzida por #10836 (server.js CommonJS quebrando com type:module reintroduzido). CI vermelho é o base-red já rastreado em #9985. Obrigado!
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ode 24 worker compatibility (diegosouzapw#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
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…stays CJS (diegosouzapw#10936)

Validado no worktree combinado: typecheck:core, changelog-integrity, complexity, cognitive-complexity, file-size, lint e teste focado (colocate-standalone-esm-scope) todos verdes. Fix real, correção de regressão introduzida por diegosouzapw#10836 (server.js CommonJS quebrando com type:module reintroduzido). CI vermelho é o base-red já rastreado em diegosouzapw#9985. Obrigado!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants