Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot figure out a good workflow for a Shopify site... #5405

Open
twilson90 opened this issue Feb 29, 2024 · 0 comments
Open

Cannot figure out a good workflow for a Shopify site... #5405

twilson90 opened this issue Feb 29, 2024 · 0 comments

Comments

@twilson90
Copy link

twilson90 commented Feb 29, 2024

I have my main script, app.js, which is served on every page.
Then I have lots of individual components consisting of html, css + js. Many of them are only served on specific pages and they refer to their own exported individual JS files.

Ideally I would like to use es imports in these components (import app from "../app.js") to refer to a dependant pre-loaded module.

Here's the issue...
I can't use es imports because the site needs to serve older browsers, and I can't use systemjs because on Shopify every JS file is requested with an id search parameter that can only generated by the Liquid pre-processor. The wrong id (or no id) means you get served the original version of the file uploaded with the same name. SystemJS loads dynamic imports or dependencies without this id parameter, so it fetches and evaluates the oldest version of a script that might already be loaded.
Also consider all assets (js, css, images) must exist in a single assets directory.

The best I can come up with is to rollup app.js and each component .js file as individual entries and output into iife format. This however causes a lot of unnecessary bloat as it duplicates many corejs definitions and shims across components.

Is there a better approach?
Any advice would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant