Closed junaidkbr closed 1 year ago
Did you try import.meta.glob
?
I have this example that you could adjust as needed to load Vue components dynamically.
Thanks Miquel. That's a neat solution. There're some side-effects of this approach but we can resolve those hopefully.
@junaidkbr Just curious, what was the number of modules when you reached the limit?
@slavamak For us, it was ~210 components. The actual component CSS and JS injections weren't that big of a deal but the preloading modules bombarded the vite.liquid file.
Interesting, tried to break it on my side but no luck 😁 I guess there are additional conditions that make it happen.
ps. Did get to break this when the snippet contained a little over 3000 lines.
Hi,
We migrated a Shopify theme from Barrel CLI's codebase to Shopify Vite. The setup we have right now compiles all component JS and Vuejs files along with their peer dependencies (one file for each) to the assets folder. Due to the nature of many files for each component and the files being hashed by Vite, we couldn't figure out how to load module JS files dynamically with the
[data-module]
approach.To overcome this, we included the JS files in each component snippet using the
vite.liquid
snippet in each component. Now that we have ~150 components and all the dependencies stuffed into the compiledvite.liquid
, the size goes over 256 KB limit Shopify has on theme files. We get the following error:I don't know where to go from here. Any directions would be appreciated. I'd love to have the modules load dynamically but don't know how.