Skip to content

Fix blank webview panels under Svelte 5 by enabling component API v4 compatibility#808

Merged
chrisdp merged 1 commit into
rokucommunity:masterfrom
kanhaiyaXITE:fix/svelte5-webview-compat-api
May 26, 2026
Merged

Fix blank webview panels under Svelte 5 by enabling component API v4 compatibility#808
chrisdp merged 1 commit into
rokucommunity:masterfrom
kanhaiyaXITE:fix/svelte5-webview-compat-api

Conversation

@kanhaiyaXITE

@kanhaiyaXITE kanhaiyaXITE commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Webview side panels (Roku Device View, Roku File System, Roku App Overlays, Roku Registry, Roku Commands, Roku Automation, Roku REPL, SceneGraph Inspector) render blank in 2.66.0.
  • Caused by the svelte 3 → 5 dependency bump in Security enhancements #794: webviews/src/main.ts:39 still uses the Svelte-4 class API (new views[viewName]({ target: document.body })), which throws component_api_invalid_new at runtime in Svelte 5.
  • Fix: enable compilerOptions.compatibility.componentApi: 4 in webviews/svelte.config.js. The bundle now goes through Svelte 5's legacy createClassComponent shim, so the existing bootstrap keeps working.

Verified locally that npm run build succeeds and the compiled bundle emits the if (new.target) return createClassComponent(...) legacy-adapter path.

Test plan

  • npm run build succeeds.
  • Start a BrightScript debug session against a device.
  • Confirm Roku Device View, Roku File System, Roku App Overlays render content (not blank).
  • Confirm Roku Registry, Roku Commands, Roku Automation, Roku REPL, SceneGraph Inspector also render.

Follow-ups (out of scope for this PR)

  • Migrate webviews/src/main.ts to Svelte 5's mount(Component, { target }) API.
  • Address remaining Svelte 5 warnings: self-closing non-void elements (e.g. <div ... />, <vscode-checkbox ... />), on:clickonclick, export let\$props().

🤖 In help with Claude Code

…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()).
@chrisdp

chrisdp commented May 26, 2026

Copy link
Copy Markdown
Collaborator

confirmed the issue locally and the fix works in this PR.

@chrisdp
chrisdp merged commit d06dc29 into rokucommunity:master May 26, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants