Fork me on GitHub
#clojurescript
<
2020-01-30
>
ak-coram08:01:19

anyone building successfully with closure compiler releases after v20190909? they seem to have phased out a few things leading to errors. can't find anything related in the CLJS Jira yet.

thheller08:01:34

standard clojurescript is not currently compatible with newer closure-compiler releases

thheller08:01:59

shadow-cljs uses a fairly recent version though

ak-coram08:01:10

thanks, shadow-cljs seems to be using v20191027

thheller08:01:54

next release will likely bump that to whatever is the latest now

thheller08:01:23

but nothing really noteworthy was added since then so no high priority

ak-coram08:01:44

ok, good to know. I was just a bit surprised that there isn't an issue where this is tracked.

thheller09:01:36

I think there is? @dnolen started work on it I think

ak-coram09:01:22

hmmm, in Jira you mean? let me try and search for it again šŸ™‚

ak-coram09:01:26

ah, maybe CLJS-3208?

thheller09:01:04

I think there might be another. the reason the closure-compiler can't be bumped easily is because of changes in the closure-library, so that needs to be bumped also. but there were changes in the closure-library that require using the closure-compiler a bit differently than CLJS currently does. so its not a super trivial upgrade.

ak-coram09:01:32

I've already tried bumping it myself and seen the errors. Luckily it doesn't seem to be too urgent to update.

ak-coram09:01:52

thanks for the info

thheller09:01:29

yeah it was a bit higher priority in shadow-cljs it depends more on the JS processing. for CLJS itself it barely makes a difference.

dnolen12:01:48

it's getting close, we'll probably cut a release just for CLJS-3208 - tests are already all passing. However need to handle goog.module. The browser REPL already works since debug loader magically handles it. Node.js REPL not working (and probably the other non-browser ones). It's finicky but it should get sorted out this week and that'll be it.

šŸ‘ 4
Maik Wild14:01:19

Without checking: (+ "foo") (- "bar") What is the result of those two statements?

p-himik14:01:01

I'd assume a warning during compilation, and NaN as the result.

ak-coram14:01:31

unary + might be implemented as identity though.

p-himik14:01:59

Ah, that's right. In any case, it should be considered an undefined behavior with non-numeric arguments. So even if you 100% what it will return, you should not rely on it.

Maik Wild14:01:25

Yea so + and * return identity and and - and / return a warning + ##NaN. Itā€™s clear from the implementation of why this is the case, but unexpected nevertheless.

delaguardo14:01:14

Latest version of clojurescript increases size of ā€œHello worldā€ bundle dramaticaly. From 5.3K -> 94K

// Compiled by ClojureScript 1.10.597 {:static-fns true, :optimize-constants false}
goog.provide('jslt.sample');
goog.require('cljs.core');
console.log("Hello, World!");

delaguardo15:01:19

result is -rw-r--r-- 1 delaguardo staff 94K Jan 30 15:55 min.js

dnolen14:01:18

the single arity should also warn - probably just an oversight

dnolen15:01:38

@delaguardo file a bug report, sometimes there's regressions around dead code elimination - usually something simple

Roman Liutikov15:01:02

from a quick look, seems like itā€™s pprint

thheller15:01:57

pprint isn't in cljs.core (and adds more than 94k)

dnolen15:01:14

well likely printing

dnolen15:01:26

that's almost always the reason

thheller15:01:00

I thought we didn't care about the "eliminate everything" size anyways

dnolen15:01:12

it's not huge priority

dnolen15:01:36

but it is useful for the times when you're being very careful and you want to use ClojureScript as a DSL over JS

dnolen15:01:00

we should just add a test case for this so it does just regress w/ patches

dnolen16:01:09

hrm interesting - strange that doesn't get eliminated since :target won't be nodejs

thheller16:01:30

maybe just because of the fact that its a keyword? or cljs.core/=?

dnolen16:01:50

ah yeah, i changed it to string later

dnolen16:01:59

but you're right about equals - should be identical?

delaguardo16:01:21

sometimes ā€œeliminate everythingā€ could be usefull. Iā€™m trying to write simple reader macro to generate JS snippet and embed it directly to hiccup form: something like [:script #inline/cljs (js/console.log "!")] but right now Iā€™m getting 94K of JS in html) but even with previous version 5.4K is overkill for such a task. So Iā€™m curious - is it possible to ā€œeliminate everythingā€?

thheller16:01:12

I'd say no in a practical sense. if you restrict yourself in what you actually use maybe but that doesn't look like CLJS at all anymore then šŸ˜›

dnolen16:01:02

not really possible, and 5.4K gzipped I believe is <1K

thheller16:01:08

parts of the leftover 5k are from goog.math.Long I think

delaguardo16:01:50

Yes, but as long Iā€™m not using math and write direct DOM manipulations - why it is not deleted?

delaguardo16:01:21

And again - Iā€™m completely understand that there is no practical use) just curious

thheller16:01:22

not everything is deletable

dnolen15:01:07

@maik.wild note the only issue is the lack of warning - you cannot depend on the result (this is different from JS - the behavior is well defined there)

adz5a16:01:30

Hello, is it normal that set! turns kebab-case into snake_case ? I have the following

(let [o (js/Object.)]
    (set! (. o -add-points) "hello")
    o);; #js {:add_points "hello"})
  

adz5a16:01:38

Am I overlooking anything ?

thheller16:01:48

add-points is not a valid JS property name. since it would be add - points doing actual math. therefore it is always munged by the compiler.

adz5a16:01:37

ok so to build an object with a field named "add-points" i must use a function which will do o[fieldName] = value . thanks

thheller16:01:23

yes. (goog.object/set o "add-points" "hello") does that.

Roman Liutikov16:01:57

@thheller Is there a way to hook into shadowā€™s heads up display? Say if I want to build one for a custom platform. Is there some multimethod or something?

thheller16:01:10

what do you mean by custom platform?

thheller16:01:20

it isn't currently customizable no

Roman Liutikov16:01:55

any other rendering target than web or react native

thheller17:01:20

each "platform" has its own namespace for handling the hot-reload stuff. so you'd probably start bt taking one and adding the hud however you need to

thheller17:01:31

browser is the only one with an actual hud

thheller17:01:10

browser,worker,node,react-native are the current impls

Roman Liutikov17:01:20

I guess I can wrap Nodeā€™s process-message, this should be enough

thheller17:01:44

you can look at the browser impl and all the hud/ references

thheller17:01:01

that should be the places you'd need to adjust

Roman Liutikov18:01:33

Already built it, thanks!

adz5a16:01:12

thanks. I see there is also the js-obj util but it uses the gobject/set functions you mentionned

Maik Wild21:01:48

< > * etc are the same deal

dnolen22:01:22

yes it's noted in the ticket, it applies to the arithmetic operators, including comparison etc.

šŸ‘ 4
dnolen19:01:41

I made an issue

šŸ‘ 8