Fork me on GitHub
#shadow-cljs
<
2023-08-18
>
greg09:08:00

What's the difference between :js-provider :import and :js-provider :external ?

thheller09:08:51

external creates an additional file that you run through webpack or so, but leave the CLJS output itself untouched. :external only applies to :browser builds

thheller09:08:26

import leaves all JS requires as they are, meaning when processed with webpack it'll process everything. :import only applies to :esm builds.

greg10:08:31

Let me paraphrase it. The difference that: • :target :esm produce esm module, while :target :browser not • when I use :target :esm the resulting bundle should be still subject for processing via webpack, while with :target :browser webpack should not touch it • In the :target :browser webpack resolves deps from index file while with :target :esm webpack resolves the deps based on the build artifact Correct?

thheller11:08:00

:target :esm itself does not need processing by webpack, only in combination with :js-provider :import

thheller11:08:16

but I guess thats what you mean

greg10:08:27

Which option would you suggest in the project when TypeScript and ClojureScript sit one next to the other, and they call each other. Initially I set it up based on :target browser with :js-provider :external with some relative imports translation via babel. Would it be possible to support such env (TS+CLJS) using :target :esm ?

thheller11:08:58

well, the essential question here is what you mean by "they call each other"?

thheller11:08:22

if you need full interop then :npm-module might be easier to work with

thheller11:08:13

you can also just use :browser and let shadow-cljs process the TS output

greg11:08:13

> well, the essential question here is what you mean by "they call each other"? In one directory you could have both .ts and .cljs files, and they could import each others functions

greg11:08:23

> you can also just use :browser and let shadow-cljs process the TS output Yes, and this is what I used to do. But then with libraries like aws-amplify I no longer can

thheller11:08:01

but with :external you can?

thheller11:08:53

:esm works but the .ts files won't be in the same directory

thheller11:08:10

and the relative requires will be relative to the CLJS output, not the sources

thheller11:08:50

but I guess that you can circumvent with JS tool side config

thheller11:08:16

its always a bit complicated when two build tools are involved

thheller11:08:35

especially if they have different views of the world, like shadow-cljs and webpack do

greg11:08:48

Ok, I will try to use :esm later

borkdude14:08:36

I want to pull clojure.string functions in their own module and also one for cljs.core clojure.string obviously depends on cljs.core and pretty much every other module I have also depends on both. When I compile I'm getting in dev mode:

Module Entry "clojure.string" was moved out of module ":clojure.string".
It was moved to ":cljs.core" and used by #{:cljs.core :cherry.tests :clojure.string :compiler :cli}.
It works in release mode though. What's the issue?

thheller14:08:42

please don't abuse :esm this way. it was not designed to do this.

thheller14:08:26

I'm guessing the injected devtools cause this? not sure why though

thheller14:08:42

try setting :devtools {:enabled false} in the build config to confirm I guess

borkdude14:08:36

that seems to work

thheller14:08:25

the devtools are injected into the base module by default, so that doesn't work if clojure.string or anything else they depend on are specifically pinned to a different module

borkdude14:08:08

makes sense

zarkone16:08:35

hi hi 👋 asked in #tools-deps, but also not sure if it exists/supported in shadow-cljs? https://clojurians.slack.com/archives/C6QH853H8/p1692374945799339

2
thheller16:08:26

I don't quite understand the question, but shadow-cljs itself has no :local/root equivalent. just what is supported by deps.edn when using that.

zarkone16:08:24

Thanks! it seems deps.edn does not support aliases in deps

thheller16:08:32

as I said. I do not understand what you mean by that

zarkone16:08:34

Ah, ok. I want to add a local/root dependency, which has paths and deps from a certain alias of this dependency, specified in extra-path for example

thheller16:08:47

ah, now I get it. yes, I don't think this is supported currently

👍 2