Fix blank webview panels under Svelte 5 by enabling component API v4 compatibility#808
Merged
chrisdp merged 1 commit intoMay 26, 2026
Conversation
…compatibility The webviews/package.json bump from svelte ^3.54.0 to ^5.55.8 in rokucommunity#794 left the Svelte-4-style class bootstrap in webviews/src/main.ts: new views[viewName]({ target: document.body }) Svelte 5 removes that API and throws `component_api_invalid_new` at runtime, so every "type": "webview" side panel (Roku Device View, Roku File System, Roku App Overlays, Roku Registry, Roku Commands, Roku Automation, Roku REPL, and SceneGraph Inspector) renders blank in 2.66.0. Setting compilerOptions.compatibility.componentApi: 4 in svelte.config.js restores the v4 class API at compile time. The bundle now emits the `if (new.target) return createClassComponent(...)` shim, so new Component(...) goes through Svelte 5's legacy adapter instead of throwing. This is a minimal, build-config-only change. A follow-up should migrate the bootstrap to Svelte 5's mount() API and clean up the remaining Svelte 5 warnings (self-closing non-void elements, on:click vs onclick, export let vs \$props()).
Collaborator
|
confirmed the issue locally and the fix works in this PR. |
10 tasks
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
webviews/src/main.ts:39still uses the Svelte-4 class API (new views[viewName]({ target: document.body })), which throwscomponent_api_invalid_newat runtime in Svelte 5.compilerOptions.compatibility.componentApi: 4inwebviews/svelte.config.js. The bundle now goes through Svelte 5's legacycreateClassComponentshim, so the existing bootstrap keeps working.Verified locally that
npm run buildsucceeds and the compiled bundle emits theif (new.target) return createClassComponent(...)legacy-adapter path.Test plan
npm run buildsucceeds.Follow-ups (out of scope for this PR)
webviews/src/main.tsto Svelte 5'smount(Component, { target })API.<div ... />,<vscode-checkbox ... />),on:click→onclick,export let→\$props().🤖 In help with Claude Code