Hey folks. Another question: there is a way to specify a custom subpath for loading modules (with shadow lazy loading)? I'm trying to setup an application under subpath, but i see that the lazy modules are loaded from /js/. But I want to load them from /prefix/js/.
I'm pretty sure they follow the :asset-path "/js" on the configuration, but I wanted to ask if there is any other way. Would be nice to have this configurable on runtime; without that i need to make a custom build for each prefix and that is not very usable when distributing the already compiled application.
In any case, thanks 😄
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/loader.js#L33
(:require [shadow.loader :as sl]) (sl/init "/prefix/js") some time before any modules are loaded
frankly nobody should be using this at all anymore and use :target :esm instead
but some of shadow.lazy utils still missing esm support, so I guess if you need that its not an option currently
I'm not clearly understand that you saying. You mean we should not be using shadow.lazy? Our build is :target = :browser and we are using shadow lazy for load some collection of namespaces when a X page is required. I want to make the application to be able to start and work correctly under a prefix and not depend on the :asset-path build option.
You are suggesting that we should target esm instead of browser? for our web application?
:browser is fine, but :esm has certain advantages when it comes to lazy loading. :browser requires the whole closure loader stuff, while :esm can just use the built-in native browser import()
esm is also a browser built-in standard for a decade or so, so it has other advantages too just from that
for example the files you are importing in esm can just use ./that-module.js as path, since the path resolves relative to the current JS file. so no custom prefix is required
this doesn't work for the current loader stuff since that path is relative to the current html file
I've been lazy myself and have not switched to :esm for all my stuff yet, but I feel its time 😛
Very interesting. Thanks for explanation i will try to make an experiment on migrating all to esm.