Fork me on GitHub
#cljs-dev
<
2020-04-15
>
henryw37416:04:27

Re the bundle target stuff https://clojurians.slack.com/archives/C07UQ678E/p1586791429463800 it suggests it'll be possible to write cljs libs which depend on npm libs, but it's not clear to me how that would work. Can someone pls explain?

dnolen16:04:08

@henryw374 deps.cljs is a file that can be in your artifact

dnolen16:04:25

this file can declare {:npm-deps ...}

dnolen16:04:50

ClojureScript scans for all of these when installing node deps

dnolen16:04:07

trivial for any other tool to do that too

dnolen16:04:57

there's really nothing else you need to do

henryw37416:04:24

Thanks but npm-deps is not new... Is it new that it can be declared in deps.cljs?

dnolen16:04:53

there's really almost nothing new in the :bundle target

dnolen16:04:23

just tweaked stuff was already there + bug fixes

dnolen16:04:50

a lot of the changes are related to making it easier to build custom tools over the public apis

dnolen16:04:04

now that we've dropped Rhino / Nashorn / Graal.js

dnolen16:04:48

Krell the new React Native tool is also a dogfood project - helps show what's missing

henryw37417:04:43

Ok I didn't think that was new... But I read the post to mean there was something new wrt cljs libs and npm. I had heard ppl say a while back they thought npm-deps was heading towards deprecation... Apparently not then!

dnolen17:04:35

we decoupled a it from the Closure stuff a long time ago

dnolen17:04:49

the old documentation makes it seems like it's tied to Closure processing - it is not

dnolen17:04:16

in fact it's trivial to switch a :bundler project and try to force everything through Closure - won't work for React of course (w/o manual intervention)

dnolen17:04:29

but there's an interesting proposition here for libraries like say Transit.js

dnolen17:04:45

which could easily be written in Closure friendly ES6

dnolen17:04:11

granted you're not going to get much DCE because it's an encoder/decoder

dnolen17:04:16

but you get the idea

dnolen17:04:07

you could write a open source lib that you want JS users to directly consume/contribute that you also want to consume in ClojureScript but get DCE / code splitting

dnolen17:04:19

currently node_modules handling is all or nothing - all :bundle or all Closure but will probably spend some brain cycles on how to allow partitioning that's not cumbersome in the near future

kommen18:04:59

btw, here is my repo for graaljs support using the new :target-fn compiler option https://github.com/nextjournal/clojurescript-graaljs

12