How does Horizon support @theme imports inside JavaScript files in assets?

Short description of issue

How does Horizon support @theme imports inside JavaScript files in assets?

Reproduction steps

Nothing

Additional info

Hi Shopify community,

I’m trying to better understand how the Horizon theme handles a functionality that allows importing modules using @theme and using them inside .js files located in the assets folder.

For example, I would like to understand:

How @theme imports are resolved internally
Whether this is officially supported in Horizon or part of a custom build setup
Best practices for structuring imports when working with JavaScript files in assets

My goal is to understand how this works under the hood and whether it can be replicated or extended in custom Shopify themes.

Any documentation, examples, or technical insights would be greatly appreciated.

Thanks in advance!

What type of topic is this

General discussion

Upload screenshot(s) of issue

I believe it uses the native browser import map - there should be a mapping between the import + the JS asset URL somewhere

Ohhh, very good, now I understand the structure. Thank you, and I’ll take this as the solution.

Ah nice one @joseamaya! Which file is that in?

Of course, I found it in this path in the GitHub code: