fix: pass onWarn to viteResolvePlugin in build mode#22487
Open
toshetah wants to merge 1 commit into
Open
Conversation
In build mode, viteResolvePlugin was not passed an onWarn callback. When builtin:vite-resolve (a Rolldown NAPI plugin) needed to emit a warning, it fell back to calling this.warn() on its native Rust context, which is marked unimplemented!() — causing a hard panic. The callback was already provided in serve mode. Making it unconditional fixes the panic and routes warnings through Vite's logger in both modes.
Author
|
The three failing checks are pre-existing CI issues unrelated to this change:
The code change itself is a one-line fix removing a serve-mode guard from the onWarn callback. |
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.
Fixes the Rolldown NAPI panic that crashes
vite buildwhenbuiltin:vite-resolveneeds to emit a warning.Problem
In build mode,
viteResolvePluginwas not passed anonWarncallback. When the nativebuiltin:vite-resolveNAPI plugin encountered a condition requiring a warning, it fell back to callingthis.warn()on its Rust plugin context — which is markedunimplemented!()in Rolldown, causing a hard panic:thread 'rolldown-worker' panicked at crates/rolldown_plugin/src/plugin_context/plugin_context.rs:
not implemented: Can't call warn on PluginContext::Napi
The
onWarncallback was already provided in serve mode but was missing from the build mode branch.Fix
Remove the
command === 'serve'conditional soonWarnis passed unconditionally, routing warnings through Vite's logger in both modes.Tests
A test is not included because the panic occurs inside Rolldown's native binary and cannot be reproduced in Vite's JS test suite. The fix is structural —
onWarnwas already exercised in serve mode; this change makes it unconditional.Alternatives explored
rolldownOptions.checksflags — those are JS-level config, the Rust panic fires before they are consultedcreateBuilderwithuseLegacyBuilder: true— controls the Environment API shape only, Rolldown is still used either way