Repository navigation
fix(nuxt): bundle rolldown wasm binding for webcontainer - #137
Merged
Merged
Conversation
|
|
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.
Problem
New Nuxt projects fail to install in WebContainers.
nuxt prepare(thepostinstallstep) andnuxt devboth crash with:Rolldown (used by Vite 8) can't load its native binary in a WebContainer. When
@rolldown/binding-wasm32-wasiisn't innode_modules, Rolldown downloads it at runtime withpnpm i @rolldown/binding-wasm32-wasi@<version>. That download resolves fresh versions:@rolldown/binding-wasm32-wasi@1.2.12pins@emnapi/coreand@emnapi/runtimeto2.0.0-alpha.5and depends on@napi-rs/wasm-runtime@~1.2.4.@napi-rs/wasm-runtime@1.2.6(published 2026-10-25) changed its@emnapipeer range to^1.7.1 || 2.0.0-beta.2, which no longer acceptsalpha.5, so the binding fails to load.The starter worked when it was added in #131 because the download picked up
@napi-rs/wasm-runtime@1.2.5at the time. Newer Rolldown bindings (up to 1.2.15) still pinalpha.5, so bumping Rolldown doesn't fix it.Solution
Ship the WASI binding in the starter's lockfile with a known-good
@napi-rs/wasm-runtime, so Rolldown finds it locally and never downloads anything at runtime.High-Level Approach
Rolldown's loader tries the native binary first, then a locally installed
@rolldown/binding-wasm32-wasi, and only falls back to the runtimepnpmdownload if neither loads. Adding the binding as a dependency makes the second step succeed in WebContainers. On normal machines the native binary still loads first, so nothing changes there.Implementation Details
@rolldown/binding-wasm32-wasiat exactly1.2.12, matching the lockedrolldownversion (Rolldown checks the binding version matches). The package has nocpu/osrestriction, so it installs on every platform.overridesto pin@napi-rs/wasm-runtimeto1.2.5, the last version whose peer range accepts@emnapi2.0.0-alpha.5.@emnapi/*,@napi-rs/wasm-runtime,@tybys/wasm-util,tslib) plus two stale optional peer entries (cac,commander) dropped.nuxt4.5.2,rolldown1.2.12, andvite8.3.3 are unchanged.npm cipasses with the repo's npm 10.2.3.pnpmdownload.nuxt/viteare bumped later androlldownmoves off 1.2.12, this binding version needs to move with it.Verified:
@webcontainer/test, Chromium): reproduced the exact error onmain. With this change,npm installrunsnuxt preparecleanly with no runtime download, andnpm run devserves the "Start prompting" page.npm ci,nuxt dev, andnuxt generatework, and Rolldown still loads its native binary.Main Files Changed
nuxt/package.json- add@rolldown/binding-wasm32-wasi@1.2.12and override@napi-rs/wasm-runtimeto1.2.5nuxt/package-lock.json- lock the WASI binding chainTicket
N/A