Fork me on GitHub
#squint
<
2023-11-15
>
witek12:11:49

Hi. I have a server implemented in Clojure. I want to serve squint-compiled code to the browser. The README suggests I have to include in my HTML. But since I already have included io.github.squint-cljs/squint {:tag "v0.4.44" :sha "157720a"} in my deps.edn - can I load this somehow with ( "???") and serve it concatinated with my sqint-compiled code?

witek12:11:47

(io/resource "squint/core.js") 😄

witek12:11:59

Ok, this does not work. In the browser I get Unexpected token 'export'.

borkdude12:11:12

you have to load it with type="module"

borkdude12:11:31

unlike the umd module\

borkdude12:11:40

the umd module is there to avoid ES6 module async-ness

witek12:11:54

What do you mean by "load it"? I slurp it and concatenate it to my JavaScript for the browser.

witek13:11:06

Ah! type="module" in HTML...

borkdude13:11:20

you can check the squint repo for index.html, I'm also using the squint module from npm in there

borkdude13:11:44

I think using the import map together with the normal squint output should work

borkdude13:11:54

(as can be seen in index.html)

borkdude13:11:59

gotta run for a bit

witek13:11:09

Thank you very much!

borkdude10:11:44

@U2ERGD6UD Did you get it working?

witek12:11:17

Yes, by using <script type="importmap"> containing entries for all my namespaces. Having a bundler would be nice. So that it generates a .js file which contains sqint and user namespaces, all hooked up correctly. But it works well so far. Thank you for your help.

witek12:11:48

And a sourcemap 😉

borkdude12:11:19

well, the bundler is just esbuild or anything else you would use for a JS project

borkdude12:11:36

sourcemap is something I'm going to work on soon

1