How to get latest asset file version from CDN?

Topic summary

Ensuring cache-busted asset loading from a Shopify CDN when using ES modules.

  • Using Liquid’s asset_url generates a script tag with a versioned query (?v=…), which correctly serves the latest asset from the CDN after compilation.

  • Removing the ?v= parameter (direct CDN URL without query) returns an older, cached version of the file.

  • Constraint: The developer needs to import the library via ES modules inside assets/app.js (e.g., import { createApp, reactive } from ‘./petite-vue.es.chunk.bundle.min.js’;), so they cannot use Liquid’s asset_url within the module import path.

  • Ask: How to ensure ES module imports resolve to the latest versioned asset (i.e., include cache-busting) when Liquid cannot be used in the import statement.

  • Artifacts: Code snippets are central to understanding the setup (Liquid-generated script tag vs. ES module import).

  • Status: Unresolved; the poster is seeking ideas or a workaround to import the latest versioned asset from the CDN with ES modules.

Summarized with AI on January 18. AI used: gpt-5.

1 use liquid asset_url


after compilation

<script type="module" src="//someStore/cdn/shop/t/386/assets/petite-vue.es.chunk.bundle.min.js?v=134111650605917990921695085744"></script>

It’s correct, will get the latest version.

2 remove ?v= parameter

https://someStore/cdn/shop/t/386/assets/petite-vue.es.chunk.bundle.min.js

will get the older version

Because I need to use javascript module to import library, cannot use liquid asset_url

// assets/app.js
import {createApp, reactive} from './petite-vue.es.chunk.bundle.min.js';

is any idea to resolve this issue?
Thanks