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.
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024