Skip to content

fix(cli): resolve Node 22 TS entrypoint incompatibility - #1325

Merged
diegosouzapw merged 1 commit into
release/v3.6.7from
fix/cli-node22-entrypoint
Apr 16, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.6.7from
fix/cli-node22-entrypoint

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

This PR resolves the [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING] error that prevents the omniroute CLI from correctly running under Node 22. It does this by compiling the CLI TS file into an executable bin/omniroute.mjs wrapper during build time.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions the CLI entrypoint from a TypeScript file to a bundled JavaScript file (bin/omniroute.mjs). Key changes include updating package.json, adding the bundled file to .gitignore, and implementing a bundling step in scripts/prepublish.ts using esbuild. Feedback focuses on improving the build script's robustness by making bundling failures fatal, ensuring cross-platform compatibility for file permissions, and updating the artifact policy to include the new file.

Comment thread scripts/prepublish.ts
Comment on lines +381 to +390
try {
execSync(
`npx esbuild bin/omniroute.ts --bundle --platform=node --packages=external --format=esm --outfile=bin/omniroute.mjs`,
{ cwd: ROOT, stdio: "inherit" }
);
execSync(`chmod +x bin/omniroute.mjs`, { cwd: ROOT });
console.log(" ✅ CLI Entrypoint bundled to bin/omniroute.mjs");
} catch (err: any) {
console.warn(" ⚠️ CLI bundle error:", err.message);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The bundling of the CLI entrypoint is a critical build step for the package to function correctly. There are several issues with the current implementation:

  1. Error Handling: If esbuild fails, the script currently only logs a warning and continues. Since package.json now points to bin/omniroute.mjs, a failed bundle will result in a broken npm package being published. This should be a fatal error (process.exit(1)).
  2. Cross-platform Compatibility: execSync('chmod +x ...') will fail on Windows systems, breaking the build for developers on that platform. It should be wrapped in a platform check.
  3. Artifact Policy: The new bin/omniroute.mjs file must be added to PACK_ARTIFACT_ROOT_ALLOWED_EXACT_PATHS in scripts/pack-artifact-policy.ts, otherwise the check:pack-artifact validation (which runs during prepublishOnly) will fail.

Additionally, it is highly recommended to add esbuild to devDependencies in package.json to ensure build reproducibility and avoid the overhead/unreliability of npx downloading it during the build process.

  try {
    execSync(
      `npx esbuild bin/omniroute.ts --bundle --platform=node --packages=external --format=esm --outfile=bin/omniroute.mjs`,
      { cwd: ROOT, stdio: "inherit" }
    );
    if (process.platform !== "win32") {
      execSync(`chmod +x bin/omniroute.mjs`, { cwd: ROOT });
    }
    console.log("  ✅ CLI Entrypoint bundled to bin/omniroute.mjs");
  } catch (err: any) {
    console.error("  ❌ CLI bundle error:", err.message);
    process.exit(1);
  }

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d52a6cc7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/prepublish.ts
console.log(" 🔨 Bundling CLI Entrypoint (TypeScript → JavaScript)...");
try {
execSync(
`npx esbuild bin/omniroute.ts --bundle --platform=node --packages=external --format=esm --outfile=bin/omniroute.mjs`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update pack-artifact allowlist for new CLI binary

This build step now writes bin/omniroute.mjs, but the pack policy still only allows/requires bin/omniroute.ts in scripts/pack-artifact-policy.ts (PACK_ARTIFACT_ROOT_ALLOWED_EXACT_PATHS and PACK_ARTIFACT_REQUIRED_PATHS). Because prepublishOnly runs build:cli before check:pack-artifact, the generated .mjs is treated as an unexpected artifact and the publish gate fails even when bundling succeeds.

Useful? React with 👍 / 👎.

Comment thread scripts/prepublish.ts
execSync(`chmod +x bin/omniroute.mjs`, { cwd: ROOT });
console.log(" ✅ CLI Entrypoint bundled to bin/omniroute.mjs");
} catch (err: any) {
console.warn(" ⚠️ CLI bundle error:", err.message);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail prepublish when CLI bundling step errors

If esbuild (or chmod) fails here, the script only warns and continues, but package.json now points the omniroute bin to bin/omniroute.mjs. In that path, the release can proceed without a valid CLI entrypoint, producing an installed omniroute command that fails at runtime; this should be a hard failure or at least verify the output file exists before continuing.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

CI Coverage Report

  • Coverage job: failure
  • PR test policy: success

Coverage artifact was not available for this run.

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.6.7 April 16, 2026 13:17
@diegosouzapw
diegosouzapw merged commit d1ca9c2 into release/v3.6.7 Apr 16, 2026
6 checks passed
@diegosouzapw
diegosouzapw deleted the fix/cli-node22-entrypoint branch April 16, 2026 13:17
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…-entrypoint

fix(cli): resolve Node 22 TS entrypoint incompatibility
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…-entrypoint

fix(cli): resolve Node 22 TS entrypoint incompatibility
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.

1 participant