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
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
During release builds, the core package rewrites each supported `@rolldown/binding-*` import to the matching Vite+ platform package (see `packages/core/build-support/rewrite-rolldown-binding.ts`):
1. The bundled rolldown code in `@voidzero-dev/vite-plus-core/rolldown` resolves native bindings from `vite-plus/binding`
1. The bundled rolldown code in `@voidzero-dev/vite-plus-core/rolldown` resolves native bindings through core's own declared optional dependencies (injected at publish time by `publish-native-addons.ts`)
2. Users don't need to install separate `@rolldown/binding-*` platform packages
3. The single `.node` file contains both vite-plus task runner and rolldown bindings
3. The platform `.node` file contains both vite-plus task runner and rolldown bindings
### Native Binding Contents
Expand All
@@ -259,23 +253,27 @@ When compiled with `RELEASE_BUILD=1`, the `.node` file contains:
User imports 'vite-plus/rolldown'
→ packages/cli re-exports from @voidzero-dev/vite-plus-core/rolldown
→ packages/core/dist/rolldown/index.mjs
→ Native binding: vite-plus/binding (rewritten from @rolldown/binding-*)
| Linux ARM64 glibc | `@voidzero-dev/vite-plus-linux-arm64-gnu` |
| Linux ARM64 musl | `@voidzero-dev/vite-plus-linux-arm64-musl` |
| Linux x64 glibc | `@voidzero-dev/vite-plus-linux-x64-gnu` |
| Linux x64 musl | `@voidzero-dev/vite-plus-linux-x64-musl` |
| Windows ARM64 | `@voidzero-dev/vite-plus-win32-arm64-msvc` |
| Windows x64 | `@voidzero-dev/vite-plus-win32-x64-msvc` |
These are automatically installed via `optionalDependencies` based on the user's platform. `publish-native-addons.ts` injects the exact-pinned entries into both `vite-plus` (via napi-rs prePublish) and `@voidzero-dev/vite-plus-core` during publish; the committed package.json files carry none of them.
See `publish-native-addons.ts` for the publishing pipeline.
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
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
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
- In release builds: `@rolldown/binding-*` → `vite-plus/binding`
- In release builds: supported `@rolldown/binding-*` → `@voidzero-dev/vite-plus-*`
**Input**: `rolldown/packages/rolldown/dist/`
**Output**: `dist/rolldown/`
Expand Down
Expand Up
@@ -142,45 +142,34 @@ Located in `build-support/rewrite-module-specifiers.ts`, this utility rewrites s
### Release Build: Native Binding Rewriting
During release builds (`RELEASE_BUILD=1`), an additional critical transformation occurs for Rolldown's native bindings:
During release builds (`RELEASE_BUILD=1`), `bundleRolldown()` rewrites Rolldown's native binding requires through `build-support/rewrite-rolldown-binding.ts`. For every platform in the CLI's `napi.targets` (mapped to napi platform suffixes with `parseTriple`), the loader's `@rolldown/binding-<suffix>` requires become `@voidzero-dev/vite-plus-<suffix>`, and that branch's version guard switches from the Rolldown version to core's version, which is what the Vite+ platform packages are published as.
**Platform-specific binding rewrites**, one per `napi.targets` entry in `packages/cli/package.json` (see the target table in [CLI Package Bundling](../cli/BUNDLING.md#napi-targets)), for example:
Specifiers for platforms Vite+ does not ship (android, freebsd, the `wasm32-wasi` fallback, `darwin-universal`, ...) stay on `@rolldown/binding-*` and keep their upstream version guards. The build fails if the rewritten specifier and guard counts diverge from the napi-rs loader shape, so a loader format change cannot ship a partial rewrite.
**Why this matters**:
1. **Self-contained distribution** - Users don't need to install separate `@rolldown/binding-*` packages
2. **Version alignment** - The rolldown binding version is synced to the vite-plus version
3. **Single native module** - The `vite-plus/binding` export points to the CLI's compiled `.node` file which includes `rolldown_binding` when built with `RELEASE_BUILD=1`
2. **Declared dependency graph** - Core resolves the binding through its own `optionalDependencies` (injected during publish by `packages/cli/publish-native-addons.ts`), so pnpm's global virtual store and Yarn PnP work without hidden hoisting, and core no longer requires back into `vite-plus`
3. **Version alignment** - Each rewritten branch's guard checks the platform package version against core's version; both are published lockstep
**Resolution chain**:
```
User code imports '@voidzero-dev/vite-plus-core/rolldown'
→ dist/rolldown/index.mjs
→ imports 'vite-plus/binding' (rewritten from @rolldown/binding-*)
See [CLI Package Bundling](../cli/BUNDLING.md#rolldown-native-binding-integration) for details on how the CLI compiles rolldown bindings.
See [CLI Package Bundling](../cli/BUNDLING.md#rolldown-native-binding-integration) for details on how the CLI compiles and publishes the platform packages, and `rfcs/core-binding-resolution.md` for the design.
---
Expand Down
Expand Up
@@ -350,7 +339,7 @@ dist/
# Build the core package
pnpm -C packages/core build
# Release build (rewrites @rolldown/binding-* to vite-plus/binding)
# Release build (rewrites supported @rolldown/binding-* to @voidzero-dev/vite-plus-*)
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.
fix(core): resolve bundled Rolldown bindings via platform packages #2313
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
fix(core): resolve bundled Rolldown bindings via platform packages #2313
Filter by extension
Only manifest files
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.