
ClojureScript 1.9.456, Externs Inference and Comprehensive JavaScript Modules - tosh
https://groups.google.com/forum/#!msg/clojurescript/wGJeG36GPTk/e9XCo3a2BgAJ
======
gw
I've been using the externs inference feature for a little while, and it works
great. Writing externs was the last truly ugly and error-prone part of
ClojureScript development. For my game library [1], I can finally use advanced
compilation because of this feature. The resulting games are much smaller and
get better frame rates now.

[1] [https://github.com/oakes/play-cljs](https://github.com/oakes/play-cljs)

~~~
swannodette
Glad it's working out!

------
drcode
ELI5: My understanding is that this version of clojurescript makes it feasible
to import arbitrary javascript libraries into a clojurescript project
(including npm package support) and then use pretty effective "dead code
elimination" over the entire code (js libraries + clojurescript) to output a
very lean production js file.

~~~
hackerboos
"React + ReactDOM production scripts are 53K.

ClojureScript (via Closure) can advance compile them to 32K

dead code elimination works"

[https://twitter.com/swannodette/status/825384686629355520](https://twitter.com/swannodette/status/825384686629355520)

This only worked because he wrote a program which didn't need every feature of
react's library. YMMV.

~~~
bpicolo
Most programs you write use only a segment of the libraries you dep. Closure
DCE is really, really good when it has type knowledge. Kills branches, inlines
code, etc. It blows anything else in the javascript ecosystem out of the water
in that regard (which is important if you're using Closure libraries, because
the Closure libraries are massive without DCE).

That said, these days I wouldn't use Closure raw. The tooling is just awful,
years out of date. ClojureScript doesn't have that issue though. It gets all
the benefits without the crappy tooling.

------
moomin
This is huge. ClojureScript's biggest weakness has always been its inability
to just use standard JS stuff the way Clojure could use standard Java stuff.
Sounds like they've finally solved it (yes, alpha-quality, but still).

~~~
juskrey
Have to say, JavaScript itself also can't "just use" all the JS stuff.

------
swannodette
Happy to answer any questions people might have about this release.

~~~
STRML
Just wanted to say, you and the team are an inspiration. The CLJS community's
work goes a long way toward making web applications - dare I say it - reliable
- and fun to code too.

Congrats on this great release. We're all looking forward to what comes next!

------
jarpineh
Great news, just yesterday I was dusting off my old Cljs project and now this
happened.

I was reading the docs on externs (how to describe your JS code - like a 3rd
party library - Closure compliant for its API surface). Could it be possible
to make Closure's advanced compilation work _without_ name mangling and thus
skip the need for externs? Or is there something else going that Closure
requires?

Having read about running Babel in Cljs project on Clojurescript site, I'm now
contemplating using TypeScript with my Cljs project. There was just now an
article on HN about using Angular with Closure, and someone pointed out a
library that can convert TypeScript to Closure annotations. It feels like
having the best of both worlds: bearable JS when you have to use it and
powerful Clojure to rely on. This method would probably work by having TS
compiler and Tsickle produce JS + annotations and importing that through
CommonJS module support into Cljs. I'll have to make a test for it.

~~~
drcode
Is this the document you were reading?
[https://clojurescript.org/guides/javascript-
modules](https://clojurescript.org/guides/javascript-modules)

This is the "new stuff"... if you were reading any other document you were
probably reading about a far more painful process.

~~~
jarpineh
Yes, that was one, but this too:
[https://clojurescript.org/guides/externs](https://clojurescript.org/guides/externs)

The previous way was painful. The one before that few years back was also very
hard to get correct...

------
raspasov
I just upgraded the the latest ClojureScript two days ago - big thanks to
swannodette and all the ClojureScript contributors!

It's really a killer feature that allows generating externs almost pain-free!
I'm making the jump to advance compile my React Native ClojureScript code
because of that. :)

------
tlrobinson
Is there a good way to integrate ClojureScript into an existing JavaScript
project yet (not vice-versa)?

All I want is a ClojureScript Webpack loader.

------
msoad
For us migration to cc is not easy. We use css and image loaders with webpack.
Cc has a weird way of doing that.

------
atomicbeanie
Great news!

