Hi,
I’m trying to set something similar up with my shopify theme but I’ve run into a snag when it comes to dynamic imports.
It’s hard to explain, but basically I want a big chunk of code to load but only when the user clicks a button.
The only neat way of doing this with rollup and everything else is to use dynamic es imports in my source code, which gets converted into SystemJS.import()s.
However, Shopify likes to append a long string of numbers to version every time you upload an asset (ie, code).
SystemJS doesn’t know this and tries to load the original version of the uploaded script, which has long since changed. Not only that but it also has a dependency check that causes it to also load the original uploaded version of the calling script!
Those ?v= arguments are important.
Shopify never make it easy…
I could change it so rollup outputs the files using the default template [name]-[hash].js, but this doesn’t address the issue of SystemJS attempting to load dependencies (app.system.js) because it doesn’t recognize that ‘app.system.js?v=38838934239889749121708712258’ is the actual dependency and is already loaded.
Any ideas?
EDIT
The problem is a bit worse than I thought. forget dynamic imports.
I have a component called ‘flipdown’ which is embedded in its own section type.
In sections/flipdown.liquid:
{{ "flipdown.css" | asset_url | stylesheet_tag }}
But even this ends up downloading and running the original uploaded version of app.system.js
