Skip to content

Allow hosts to resolve UI extension bundle URLs - #1548

Closed
mpeters1-godaddy wants to merge 3 commits into
godaddy:mainfrom
mpeters1-godaddy:codex/ui-extension-preview-sdk
Closed

mpeters1-godaddy wants to merge 3 commits into
godaddy:mainfrom
mpeters1-godaddy:codex/ui-extension-preview-sdk

Conversation

@mpeters1-godaddy

@mpeters1-godaddy mpeters1-godaddy commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

Allow mounting a locally built DOM extension through the same React runtime that loads released bundles from the Commerce CDN. An optional resolveScriptUrl(extension) callback lets a host supply the preview asset URL through Target or UiExtensionRuntimeHost, using the existing extension record.

  • Accept a same-origin root-relative path or an absolute HTTP(S) URL without credentials. Report invalid URLs and resolver errors through invalid_script_url.
  • Keep the standard CDN path for existing hosts. A resolver callback identity change alone leaves the mounted bundle in place.

The resolver works for existing bundles. Host action integration is tracked in #1546.

Changeset

  • Added a minor changeset for @godaddy/react.

Test Plan

  • Ran corepack pnpm --filter @godaddy/react exec vitest run src/ui-extensions on Node 24 with 37 tests passing.
  • Passed corepack pnpm --filter @godaddy/react typecheck and corepack pnpm --filter @godaddy/react exec biome check src/ui-extensions.
  • Built @godaddy/react and verified the @godaddy/react/ui-extensions entry point exports the resolver declarations.

@mpeters1-godaddy
mpeters1-godaddy requested a review from a team as a code owner November 30, 2026 21:37
@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 73aa393

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

This PR includes changesets to release 1 package
Name Type
@godaddy/react Minor

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

@sbolinger-godaddy sbolinger-godaddy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nothing major found, approving! Nice, tight change. A few optional items, none of them blockers:

  • CORS note in the README: the runtime sets crossOrigin = 'anonymous' on the script tag. A cross-origin dev server like http://127.0.0.1:3000 has to send Access-Control-Allow-Origin, or the load fails with a generic load_failed. Also, http:// URLs only work on localhost or http pages, because of mixed-content blocking. A one-liner in the README would save some debugging.
  • Per-extension CDN fallback: right now the resolver has to return a string for every extension under the Target. Treating undefined as "use the default CDN URL" would make it easy to preview one local extension next to released ones.
  • Tiny inconsistency: resolveScriptUrlRef uses useIsomorphicLayoutEffect, while onErrorRef uses useEffect. The layout effect is the better choice, so this is just a note.

What I checked: traced Target → UiExtensionRuntimeHost → runtime.mount → getUiExtensionScriptUrl and confirmed a resolver identity change doesn't remount. I also probed edge-case URLs (/\host, /..//host, encoded slashes, //host, javascript:, data:) against the same-origin check, ran vitest run src/ui-extensions (39 passing) and biome check locally, and saw CI green.

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