Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi everyone,
I'm encountering an issue with JavaScript modules in my Shopify store, and I could really use some help.
I've added a script tag in main-product.liquid like this:
<script type="module">
const product = document.querySelector(".product");
const productSizes = product.dataset.productSizes;
export { productSizes };
</script>
This file is located in the Sections folder.
Then, in size-guide-1.js.liquid which is in the Assets folder, I tried to import productSizes like this:
import productSizes from "{% section 'main-product' %}";
However, this doesn't seem to work, and I get the following error:
TypeError: Failed to resolve module specifier "". Invalid relative URL or base scheme isn't hierarchical.
Can anyone help me understand why this import is failing and how to properly import the productSizes variable from main-product.liquid into size-guide-1.js.liquid?
Thanks in advance!
Ignore this message.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025