Skip to content

fix(extension): emit no modulepreload links, which Chrome refuses to use - #248

Merged
stormer78 merged 1 commit into
mainfrom
fix/no-modulepreload-in-extension-pages
Sep 15, 2026
Merged

stormer78 merged 1 commit into
mainfrom
fix/no-modulepreload-in-extension-pages

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

Every generated wallet page carried a <link rel="modulepreload" crossorigin> for each shared chunk its entry imports, and Chrome declined all of them:

A preload for 'chrome-extension://…/assets/bridge-protocol-….js' is found, but is not used because it is a cross-world extension resource mismatch.

The hint is fetched under a different resource world than the module graph that <script type="module"> then loads, so the preloaded copy never matches the lookup and is discarded — each chunk fetched twice, and 18 warnings across popup (4), options (6), confirm (4) and offscreen (4) on the chrome://extensions Errors page.

Nothing was broken by them; the script tag is what actually loads the graph. The cost is the page they filled. The Errors page is where a real fault has to be noticed, and a screenful of benign warnings is how one gets scrolled past — the same reasoning R7.2 applies to a lost prompt.

Preloading buys nothing here anyway: every asset is read from local disk, with no network latency to hide. manager.html never had any, because codeSplitting: false leaves the console no shared chunks to preload, and background.js is a single bundle with no HTML at all — so vite.config.ts is the one config that needed the option.

Verification

Built both ways and counted the links:

page before after
popup.html 4 0
options.html 6 0
confirm.html 4 0
offscreen.html 4 0

The entry's own <script type="module" crossorigin src="…"> is unchanged, which is the tag that actually loads.

  • npm run build --workspace @openvtc/pnm-extension (all three configs) — clean
  • npm test --workspace @openvtc/pnm-extension — 726 pass, 0 fail
  • dist guards re-run locally: background.js has no dynamic import(); acl/*, contexts/delete, keys/sign and persona/attribute/put appear in no file but manager.js; no vta/seeds/* anywhere; no manager-split-*.js; packaged manifest has no content_scripts; no chrome.cookies in dist/

Pre-merge checklist (vti-stack-development-guide.md)

  • No cross-service wire contract touched — this is a bundler output option only
  • No compatibility fold added
  • No new fetch, endpoint or error-matching path (R1.2 / R3.7 unaffected)
  • MV3 invariants intact: single background.js bundle, codeSplitting: false on the console build

Every generated wallet page carried `<link rel="modulepreload" crossorigin>`
for each shared chunk its entry imports, and Chrome declined all of them:

    A preload for 'chrome-extension://…/assets/bridge-protocol-….js' is
    found, but is not used because it is a cross-world extension resource
    mismatch.

The hint is fetched under a different resource world than the module graph
that `<script type="module">` then loads, so the preloaded copy never matches
the lookup and is discarded — each chunk fetched twice, and 18 warnings
across popup (4), options (6), confirm (4) and offscreen (4) on the
chrome://extensions Errors page.

Nothing was broken by them; the script tag is what actually loads the graph.
The cost is the page they filled. The Errors page is where a real fault has
to be noticed, and a screenful of benign warnings is how one gets scrolled
past — the same reasoning R7.2 applies to a lost prompt.

Preloading buys nothing here anyway: every asset is read from local disk,
with no network latency to hide. `manager.html` never had any, because
`codeSplitting: false` leaves the console no shared chunks to preload, and
`background.js` is a single bundle with no HTML at all — so this is the one
config that needed it.

Verified by building both ways: 18 links before, 0 after, with the entry's
own `<script type="module" crossorigin>` unchanged. Full three-config build,
726 extension tests and the dist guards (single background bundle, admin and
persona URIs confined to manager.js, no seeds family, one manager chunk) all
pass.

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
@stormer78
stormer78 merged commit 07e2f3b into main Sep 15, 2026
4 checks passed
@stormer78
stormer78 deleted the fix/no-modulepreload-in-extension-pages branch September 15, 2026 12:17
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.

1 participant