build(node): add experimental Node-compatible CLI startup path#1
Open
0pen7ech wants to merge 5 commits into
Open
build(node): add experimental Node-compatible CLI startup path#10pen7ech wants to merge 5 commits into
0pen7ech wants to merge 5 commits into
Conversation
added 5 commits
May 8, 2026 21:32
Author
Краткое описаниеЭтот PR добавляет экспериментальный путь запуска CLI, совместимый с Node, для NekoFree. Цель — сделать базовый CLI пригодным к использованию в окружениях, где Bun не может надежно стартовать, особенно на non-AVX QEMU/KVM VM, где Bun может падать еще до выполнения какого-либо JavaScript-кода. Этот PR не заявляет полной runtime-совместимости с Node.js. Bun остается основным runtime. Node-путь сейчас является экспериментальным и сфокусирован на проверке базового запуска внешнего CLI и выполнения команд. ПроблемаВ некоторых виртуализированных окружениях или на старых CPU Bun может падать до того, как выполняется код NekoFree. Пример режима отказа: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an experimental Node-compatible CLI startup path for NekoFree.
The goal is to make the basic CLI usable in environments where Bun cannot start reliably, especially non-AVX QEMU/KVM VMs where Bun may crash before any JavaScript code runs.
This PR does not claim full Node.js runtime parity. Bun remains the primary runtime. The Node path is currently experimental and focused on validating basic external CLI startup and command execution.
Problem
On some virtualized or older CPU environments, Bun can fail before NekoFree code is executed.
Example failure mode:
```text
CPU lacks AVX support
panic(main thread): Segmentation fault
Illegal instruction
```
In this case, the CLI cannot even reach its own error handling, because the runtime exits first.
At the same time, NekoFree heavily uses Bun-specific build-time features, especially:
```ts
import { feature } from "bun:bundle";
```
There are many `bun:bundle` feature flag imports across the codebase. Manually rewriting those files would be risky, noisy, and difficult to review.
This PR explores a build-time compatibility approach instead.
Approach
Instead of rewriting source files manually, this PR introduces an experimental Node build pipeline that handles Bun-specific build behavior at bundle time.
The main idea:
What changed
Added experimental Node build
Added:
This produces an experimental Node-compatible ESM bundle at:
`dist-node/cli.js`
The generated bundle is not committed.
Added bun:bundle feature transform
Added: `tools/bun-bundle-feature-transform.mjs`
This esbuild plugin intercepts `bun:bundle` imports and replaces them with a lightweight Node-compatible shim that resolves feature flags at bundle time.
Added Node-specific tsup config
Added: `tsup.node.config.ts`
Configures the Node build pipeline with the appropriate esbuild plugins and build defines.
Verification
Out of scope