r/Clojure • u/alexdmiller • Apr 24 '20
ClojureScript - Embracing JavaScript Tools
https://clojurescript.org/news/2020-04-24-bundle-target8
u/CryptoNaiah Apr 25 '20
This did it for me, I plan to finally jump in to ClojureScript. Great work!
"You can now publish ClojureScript libraries that depend directly on the JavaScript ecosystem without additional ceremony and be confident that the whole community can benefit regardless of what other JavaScript and ClojureScript build tools they may prefer..."
And yes Webpack is there for sure:
2
u/lgstein Apr 25 '20
What happens when a Javascript project consumes two different libraries published via ClojureScript. Do they not clash?
4
u/Bediavad Apr 25 '20
Just to understand better what it means:
Should I replace shadow-cljs with webpack and this method?
Or does shadow-cljs do something else/extra.
5
u/swannodette Apr 25 '20
If you like shadow-cljs, keep using shadow-cljs! Again these changes just mean all users can join in the fun of easily using JavaScript dependencies, not just fans of shadow-cljs.
3
2
u/lgstein Apr 25 '20
Does this work with figwheel already? Also, is webpack now shell invoked after every build?
6
u/swannodette Apr 25 '20
I chatted with Bruce. Figwheel will need some changes, he's being funded again by Clojurists Together - so this should be fixed soon.
These changes have nothing specifically to do with Webpack, and no we don't run any commands for you.
2
u/lgstein Apr 25 '20
Thanks. The way I understand the new webpack guide, as a way to consume npm dependencies, it would have to run webpack CLI after every incremental figwheel build, yes?
3
u/swannodette Apr 25 '20
You don't need to re-run the JS bundler unless your dependencies on node_modules change. In all other cases hot-reload or incremental compile does not need to rerun the bundler.
2
2
1
Apr 24 '20
"externs inference" is not reliable. The correct path is to really fully embrace JS modern features/tooling and not depend on closure advanced compilation.
24
u/swannodette Apr 24 '20
If you've found a bug please report it. All the known externs inference bugs prior to this release were moved into the blocker category and resolved. Note we've also been using this feature for some time in a fairly sizable React Native codebase and hadn't run into anything I would consider a showstopper. But I agree that there were annoyances previously.
Not using advanced compilation would just lead to bigger payloads. I don't see many users asking for that ;)
0
Apr 24 '20
There are other ways to do "advanced compilation" without closure, but that requires leveraging ES6 modules.
10
u/swannodette Apr 24 '20 edited Apr 24 '20
The only comprehensive thing that I'm aware of is Rollup.js but so far no-one has provided evidence that it would best Closure advanced compilation for ClojureScript. Given that Closure works at property and method level, I'm somewhat skeptical. Do you have some other tool in mind?
3
u/jiyinyiyong Apr 25 '20
I was totally convinced that dead code elimination of Google Closure Compiler is a lot smarter than tree shaking from Webpack. However I'm still very curious how bad is the result if ClojureScript makes full use of ES6. Or would ES6 cljs be acceptable for a small part of users. Probably a bad example but some people who are using Webpack just accepted the large bundles... https://twitter.com/boriscoder/status/1251823596747571200 .
23
u/vlaaad Apr 24 '20
The new webpack guide is wonderful, give it a try! REPL-driven development just as in Clojure, with npm deps out of the box — ClojureScript is truly not an island!