shadow-cljs

Pepijn de Vos 2025-06-03T14:35:22.354129Z

I'm having trouble with assets. There is this template that references source files, but in the built package all the paths are like ./assets/name-abcdef.ttf and such. That package uses vite to build the template I think. Is there a sane way to refer to these assets in the distributed package?

Pepijn de Vos 2025-06-04T08:34:30.652649Z

EXACTLY but when you build the package vite bundles everything into names with hashes in them. So inside node_modules you don't just have index.js but index-randomhex.js and randomhex is a hash of the content. So there doesn't appear to be a stable way to refer to the assets in the compiled package

thheller 2025-06-04T08:35:12.282869Z

why are you asking me a question about vite? I'm missing crucial information here?

thheller 2025-06-04T08:35:28.659829Z

how is shadow-cljs involved in this? so far I haven't seen any CLJS

Pepijn de Vos 2025-06-04T08:36:09.893479Z

I was hoping this is some standard JS module scheme that shadow-cljs has a way of dealing with

thheller 2025-06-04T08:36:53.472719Z

if you explain how shadow-cljs is involved in this and what you are trying to do I can maybe make suggestions

thheller 2025-06-04T08:37:03.836599Z

right now I'm just lost and have no clue what the actual issue is

Pepijn de Vos 2025-06-04T08:38:57.770409Z

Like, vite transforms the source references to hashed asset references. I was hoping to replicate that so that I can refer to index.js and then shadow-cljs compiles that to index-hex.js` but maybe this is just a vite problem where the assets are essentially "private" internal names that I'll have to work around.

thheller 2025-06-04T08:39:46.054739Z

please take about 5 steps back and describe the problem you are trying to solve

thheller 2025-06-04T08:39:57.570919Z

do no mention vite or whatever. I cannot answer questsions about vite.

Pepijn de Vos 2025-06-04T08:40:04.628419Z

Sure

Pepijn de Vos 2025-06-04T08:42:11.748759Z

So I added a package as a dependency and I want to load the JS files inside it. But the JS files have weird hashed names. I was hoping this is some C++ name mangling type deal that tools in the JS ecosystem know how to deal with.

Pepijn de Vos 2025-06-04T08:44:32.311619Z

But I'm starting to think this is not some type of "ES module" thing but rather their bundler making "private" assets that can't be reliably loaded externally.

thheller 2025-06-04T10:21:26.167739Z

ok so this is a normal npm dependency?

thheller 2025-06-04T10:22:17.950209Z

the hashed names is not normally something you'd refer to directly. usually package.json will have some sort of aliasing so that you can use normal names and it gives you the hashed name

thheller 2025-06-04T10:23:15.194089Z

assets are a different story, but I need specifics because there are about a million different ways these things are done, so I cannot give a generic answer

Pepijn de Vos 2025-06-03T14:35:41.280249Z

the file: https://github.com/marimo-team/marimo/blob/main/frontend/index.html

thheller 2025-06-03T16:24:19.037099Z

just move the assets folder from src/assets to public/assets

thheller 2025-06-03T16:24:27.543499Z

then just use /assets/whatever in the html

thheller 2025-06-03T16:25:12.215009Z

not sure what you mean by "distributed package"

Pepijn de Vos 2025-06-03T19:36:04.242419Z

The weirdness is that they use vite to assemble everything and it puts the content hash in the filename so if you just copy assets from node_modules to public they have hashes in the name so it's very fragile

thheller 2025-06-04T06:06:14.723809Z

yeah sorry I do not understand what kind of setup you are using. the files must be somewhere? in the repo you linked its all just regular files?