Skip to content

fix(vite): bundle cli for npx runtime#4

Merged
remarkablemark merged 2 commits into
masterfrom
fix/vite
May 5, 2026
Merged

fix(vite): bundle cli for npx runtime#4
remarkablemark merged 2 commits into
masterfrom
fix/vite

Conversation

@remarkablemark
Copy link
Copy Markdown
Member

@remarkablemark remarkablemark commented May 5, 2026

What is the motivation for this pull request?

This fixes a packaging/runtime bug where the published CLI could fail when invoked via npx because the Vite/Rolldown output left the TUI stack externalized in a way that triggered a runtime require("react") error. It also adds a CI smoke test to catch the same packaged CLI regression in the future.

What is the current behavior?

The built CLI could throw Error: Calling requirefor "react" in an environment that doesn't expose therequire function when run from an npx-style environment. The existing GitHub Actions workflow built and installed the package globally, but it did not explicitly exercise the packed tarball through npm exec from an isolated temp directory.

What is the new behavior?

The CLI is now built as a Node SSR bundle so the TUI stack is bundled correctly for packaged execution, and the test workflow now verifies the packed CLI via npm exec to cover the npx path.

Checklist:

Changed the build to target Node SSR instead of Vite’s default client/lib
pipeline, and stopped externalizing the TUI stack.

The relevant change is in `vite.config.mts:6: build.ssr = 'src/cli.ts'`,
a fixed `cli.js` entry name, and removal of `react`/`ink`/`@inkjs/ui`
from external.

That removes the emitted Rolldown fallback that was throwing
`Calling require for "react"` when the binary was launched via `npx`.

The new build no longer contains that runtime stub, and
`node dist/cli.js --help` now runs successfully.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remarkablemark remarkablemark self-assigned this May 5, 2026
@remarkablemark remarkablemark added the bug Something isn't working label May 5, 2026
@remarkablemark remarkablemark merged commit 8de7581 into master May 5, 2026
15 checks passed
@remarkablemark remarkablemark deleted the fix/vite branch May 5, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant