Short description of issue
In Firefox, importing “@shopify/partial-rendering” fails because the import map in content_for_header is output after several Shopify module scripts, so Firefox ignores it. Chrome and Safari are not affected.
Reproduction steps
- On a development store, add a section containing:
<script type="module"> const { partials } = await import('@shopify/partial-rendering'); console.log(partials.getAll()); </script> - Open the page in Chrome or Safari: the package loads and
partials.refresh('partials-test')works. - Open the same page in Firefox 158 (macOS): the import fails with:
The specifier "@shopify/partial-rendering" was a bare specifier, but was not remapped to anything. Relative module specifiers must start with "./", "../" or "/". - Inspect the order of module-related elements in the DOM: the
<script type="importmap">comes after several module scripts thatcontent_for_headeroutputs itself.
Additional info
In content_for_header, the importmap is output after Shopify’s own module scripts (shop-js):
… [head] module inline: (o.Shopify=o.Shopify||{}).modules=!0
… [head] module shopifycloud/shop-js/modules/v2/loader.init-shop-cart-sync.fr.esm.js
… [head] module inline: await import("…/shop-js/…")
… [head] importmap {"imports":{"@shopify/partial-rendering":"…"}}
Firefox ignores an import map that appears after module loading has started (Chrome/Safari merge it). Moving content_for_header above the theme scripts doesn’t help, since these modules come from content_for_header itself.
Expected: output the importmap first in content_for_header.
Workaround: import the URL read from the import map directly (works in Firefox, but bypasses its integrity check).
What type of topic is this
Bug report