Skip to content

refactor(devtools): generate the extension VNode bridge from one shared source#8713

Merged
wmertens merged 1 commit into
QwikDev:build/v2from
Aejkatappaja:refactor/shared-vnode-bridge
Jun 25, 2026
Merged

refactor(devtools): generate the extension VNode bridge from one shared source#8713
wmertens merged 1 commit into
QwikDev:build/v2from
Aejkatappaja:refactor/shared-vnode-bridge

Conversation

@Aejkatappaja

Copy link
Copy Markdown

Problem

packages/browser-extension/public/vnode-bridge.js duplicated the VNode bridge logic the Vite plugin already owns in packages/devtools/plugin/src/virtualmodules/vnodeBridge.ts (via createVNodeRuntime() / __qwik_install_vnode_runtime__): tree building, prop serialization, component name normalization, DOM element resolution, highlighting, and component tree update posting. Both had to be kept in sync by hand.

Solution

Generate the extension bridge from the single canonical source, the same way devtools-hook.js is handled.

  • Expose createVNodeRuntime through the internal codegen entry of @qwik.dev/devtools (build-time only, not a published subpath).
  • Generalize the extension generate step into scripts/gen-injected-scripts.mjs, which now emits both devtools-hook.js and vnode-bridge.js from their canonical builders. It replaces gen-devtools-hook.mjs and stays wired as the first step of build and dev (and the firefox variants).
  • Stop tracking public/vnode-bridge.js: it is gitignored and generated on build/dev, matching the devtools-hook.js approach.

The extension bridge is now byte-for-byte the same module the plugin injects (same createVNodeRuntime() output), so the two cannot drift.

Verification

  • @qwik.dev/devtools builds and codegen.mjs exports createVNodeRuntime.
  • The generate step writes both injected scripts; vnode-bridge.js is valid ESM and exposes the full bridge surface (getVNodeTree, resolveElementToComponent, getElementRect, highlightNode, unhighlightNode, getNodeProps, component tree update posting), installed with the bound @qwik.dev/core/internal helpers.
  • eslint passes on the touched source.

References

QwikDev project board, card "p1 VNode Bridge Duplication": https://github.com/orgs/QwikDev/projects/6/views/1

…ed source

The browser extension's public/vnode-bridge.js duplicated the VNode bridge logic
that the Vite plugin already owns via __qwik_install_vnode_runtime__ /
createVNodeRuntime(). Generate it from that single canonical source instead.

- Expose createVNodeRuntime through the internal codegen entry.
- Generalize the extension generate step (gen-injected-scripts.mjs) to emit both
  devtools-hook.js and vnode-bridge.js, wired into build and dev.
- Stop tracking public/vnode-bridge.js; it is gitignored and generated, matching
  the devtools-hook.js approach.
@Aejkatappaja Aejkatappaja requested a review from a team as a code owner June 9, 2026 23:35
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2e6ed3b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@qwik.dev/devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8713

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8713

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8713

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8713

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8713

commit: 2e6ed3b

@JerryWu1234

Copy link
Copy Markdown
Contributor

done, @wmertens please take a look

@wmertens wmertens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wmertens wmertens merged commit b8147cc into QwikDev:build/v2 Jun 25, 2026
24 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.

3 participants