Fork me on GitHub
#shadow-cljs
<
2023-09-12
>
Hendrik13:09:48

What is the recommend solution, if the target is node and ESM modules need to be imported? I tried :target :node-script and :esm, but I got no running solution

thheller14:09:44

:esm works fine. what did you try?

Hendrik19:09:00

Ok I got it to work. This is the target setting

{:target :esm
   :runtime :custom
   :compiler-options {:source-map true}
   :modules {:main {:entries [com.example.core]}}
   :output-dir "target/app"}
I had to add a package.json into target/app with content {"type": "module"} . This was the missing piece to convince node

Hendrik19:09:03

Thanks for your help. Is it also possible to import typescript. I think, that it it isn’t, right?

hifumi12320:09:35

Importing typescript isnt possible since it isnt javascript

hifumi12320:09:11

You will have to import an ESM (or CJS) dist or compile the typescript sources to javascript yourself