Chromium/Helium compatibility for the --chromium build - #1
Open
icnatspell wants to merge 2 commits into
Open
Conversation
Make the existing --chromium build target produce a working extension on Chromium-based browsers (tested on Helium). Firefox-only; a "thin viable port" that drops containers, per-container proxy, and native-strip tab hiding (no Chromium equivalent). build/copy.js: emit a valid MV3 manifest for --chromium — manifest_version 3, sidebar_action -> side_panel, background page -> service worker (module), browser_action -> action, drop SVG icons, filter permissions to Chrome-valid + sidePanel/contextMenus, move hosts to (optional_)host_permissions, strip command suggested keys. build/scripts.js: inject a compat shim as the first import of each entry (onResolve sideEffects:true + onLoad prepend, since inject/bare-import get tree-shaken under "sideEffects": false), and a banner defining the DOM globals a service worker lacks (window, an inert document, getComputedStyle, localStorage, matchMedia) before any chunk body runs. src/injections/browser-compat.ts: patch `chrome` (the build renames browser -> chrome) with feature-guarded shims — menus (sanitizing wrapper over contextMenus: strip icons/viewTypes/command, route onclick -> onClicked, map types/contexts), permissions filter (drop Firefox-only names), tabs (hide/show no-op, onUpdated filter strip, create/query/update prop strip, moveInSuccession/warmup no-op, highlight populate strip, opener-self guard), windows.create prop strip, sessions tab/window value store (window values in storage.local to survive SW restart/reload), sidebarAction bridge + sidePanel.setPanelBehavior, and stubs for theme/contextualIdentities/proxy. build/sw-loadtest.js: Node harness that loads the built service worker with a Chrome-faithful `chrome` mock to catch SW load-time crashes without loading the extension in a browser each iteration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Makes the existing
--chromiumbuild target produce a working extension on Chromium-based browsers (tested on Helium). A thin viable port: drops containers, per-container proxy, and native-strip tab hiding (no Chromium equivalent).What's included
build/copy.js— emit a valid MV3 manifest for--chromium:sidebar_action→side_panel, background page→service worker,browser_action→action, drop SVG icons, Chrome-valid permissions +sidePanel/contextMenus, hosts→(optional_)host_permissions.build/scripts.js— inject the compat shim first in each entry, plus a banner defining the DOM globals a service worker lacks (window, inertdocument,getComputedStyle,localStorage,matchMedia) before any chunk runs.src/injections/browser-compat.ts— feature-guardedchromeshims: menus (sanitizing wrapper), permissions filter, tabs (hide/show/onUpdated-filter/prop-strip/moveInSuccession/warmup/highlight/opener-self),windows.createprop strip, sessions tab/window value store,sidebarAction→sidePanel, theme/contextualIdentities/proxy stubs.build/sw-loadtest.js— Node harness that loads the built SW with a Chrome-faithfulchromemock to catch load-time crashes without a browser.Status
Functional in Helium: tab tree renders, tabs create/switch/move, new windows work. Firefox build path is untouched.
Known limitations (by design)
🤖 Generated with Claude Code