clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
kah0ona 2020-10-21T08:17:47.164300Z

Hi, anybody else experienced a hanging compilation with :advanced mode, when :target :bundle is used? I can’t for the heck of me figure out why this happens to my project. I have a development/figwheel-main setup that does work with :target :bundle, ie. it will properly use my external libraries, but :advanced compilation seems to hang

kah0ona 2020-10-21T08:17:54.164500Z

any pointers in how to debug this?

kah0ona 2020-10-21T08:18:14.164900Z

cljs 1.10.773

kah0ona 2020-10-21T08:20:02.165200Z

{:main            myns.core
 :output-to       "target/index.js"
 :output-dir      "target"
 :optimizations    :advanced
 :target          :bundle
 :verbose         true
 :bundle-cmd      {:none    ["npx" "webpack" "./target/index.js" "-o" "./target/" "--mode=development"]
                   :default ["npx" "webpack" "./target/index.js" "-o" "./target/"]}
 :closure-defines {cljs.core/*global* "window"}} ;; needed for :advanced compilation

kah0ona 2020-10-21T08:20:12.165400Z

that’s my build.edn

kah0ona 2020-10-21T08:22:47.165800Z

but it never gets to the point of bundling, just hangs at: Applying optimizations :advanced to 281 sources

kah0ona 2020-10-21T08:24:52.166Z

or is it just reaaalllly slow?

thheller 2020-10-21T08:45:09.167Z

no clue about the :bundle-cmd side of things but :advanced can take a long time. depends on your code. I've seen anything between a couple sec and a few minutes

thheller 2020-10-21T08:45:29.167300Z

whereas a couple minutes is quite extreme and uncommon

thheller 2020-10-21T08:45:32.167500Z

so usually a couple secs

victorb 2020-10-21T08:58:46.168800Z

@kah0ona if you're on linux, you could try using strace to see if it's hang/waiting for something, or if it's just doing bunch of work. Try strace <your command> and see if you get tons of output (busy working) or if it stops outputting logs after a while (stuck waiting for something)

victorb 2020-10-21T09:45:08.170500Z

Using juxt/tick in cljs to do some lightweight formatting (just want to show how long time ago something happened) but tick pulls in js-joda which ends up being 30% of my bundle size. Anyone got any handy library/snippet for cljs for taking a js/Date and turning it "X seconds/minutes/hours ago" that is a bit easier on the size side?

Day Bobby 2020-10-21T09:49:00.170600Z

does this work for you? https://github.com/luciodale/arco

Day Bobby 2020-10-21T09:49:29.170900Z

nvm it depends on tick as well

victorb 2020-10-21T09:54:46.171400Z

thanks to both for the pointers. Yeah, DateTimeFormat is nice, but don't think it does "durations" that would be needed to get the "X minutes ago", or at least I don't see how I could get that from DateTimeFormat

p-himik 2020-10-21T09:54:52.171600Z

If you're OK with JS interop: https://github.com/iamkun/dayjs

p-himik 2020-10-21T09:55:29.171900Z

dayjs(1536484369695).fromNow();
// => "5 days ago"
Not sure if it has better precision than days.

p-himik 2020-10-21T09:56:05.172100Z

Ah, it does: https://day.js.org/docs/en/display/from-now#list-of-breakdown-range

victorb 2020-10-21T09:56:29.172400Z

yeah, js interop is fine, as long as the library is small and nimble, and don't end up to big in the bundle. I'll take a look at dayjs, thanks

p-himik 2020-10-21T09:57:11.172600Z

I've glanced at a few articles that talk about replacements for moment - day.js seems to be the most lightweight.

victorb 2020-10-21T09:57:12.172800Z

in the end, what ends up taking lots of space is the locales, rather than the libraries themselves

p-himik 2020-10-21T09:57:24.173Z

In any case, https://bundlephobia.com/ is a great service.

πŸ‘ 1
victorb 2020-10-21T09:57:25.173200Z

that's nice, thanks again for the pointer :thumbsup:

victorb 2020-10-21T09:58:16.173500Z

yeah, tried bundlephobia before but not sure what they use to do the calculations, don't think it's accurate with closure compiler, as it's hard to know before including it and using it how much space it'll actually take

victorb 2020-10-21T09:59:14.173700Z

dayjs seems small enough though, looks great

p-himik 2020-10-21T09:59:22.173900Z

Indeed. But I think it can be useful when comparing different JS libraries between each other.

πŸ‘ 1
2020-10-21T10:00:34.174200Z

actually I was thinking of this before https://github.com/tc39/proposal-intl-duration-format ... still a work in progress unfortunately

victorb 2020-10-21T10:04:34.174500Z

ah sweet, haven't seen that before. Thanks @henryw374

victorb 2020-10-21T10:06:51.174700Z

yeah, unfortunately still a draft but at least the API does look OK πŸ™‚

2020-10-21T10:07:01.174900Z

πŸ˜‰

thheller 2020-10-21T10:20:32.175100Z

I can't believe no one has suggested this but if "X seconds/minutes/hours ago" is all you really need just write that function yourself. its trivial and smaller than any lib you'll find. pretty sure there is also something in the closure library for this.

p-himik 2020-10-21T10:36:13.175700Z

Good to know that Closure has such functionality. Regarding writing it yourself - it's not that easy if you need l10n.

thheller 2020-10-21T10:42:16.175900Z

well yes that makes everything harder. I think the closure lib variant handles that.

victorb 2020-10-21T10:52:02.176200Z

@thheller yeah, was looking for snippets as well! Don't want to spend any time re-writing something that's already been written, the code from relative.js looks good enough so thanks for linking that! :thumbsup:

victorb 2020-10-21T10:52:45.176400Z

makes note to self that I should really sit down and at least scan the top-level API for the closure-library, I always tend to forget/miss the built-in functionality

thheller 2020-10-21T10:56:33.176600Z

I have a local checkout and typically just "find in files" and pretty often there is something πŸ˜›

🍻 1
deadghost 2020-10-21T15:50:16.178900Z

I'm running frontend tests on nodejs and since nodejs is missing some browser things, I need to create stubs like (set! (.-document js/global) (clj->js {:getElementsByClassName (fn [_] [])})). I'm wondering if there's already a comprehensive set of stubs in a repo somewhere.

odge 2020-10-21T18:11:04.181600Z

I have a customer getting errors where the data format looks weird: The logs says :fxrate #object[h {:value 1.1823}] but I would expect :fxrate 1.1823 where is this format coming from? Any ideas or leads appreciated.

p-himik 2020-10-21T18:27:31.181700Z

Hard to say anything specific without my crystal ball. :) But #object[...] can appear when you try to print a JS object that's not a plain object (i.e. for which object? returns false). And the h part may easily come from some minified class name.

odge 2020-10-21T18:42:43.181900Z

Thanks, I guess I'll just have to bite the bullet and find out what h was before minifying

p-himik 2020-10-21T18:44:15.182100Z

Source maps should help.

odge 2020-10-21T18:47:13.182300Z

I can't reproduce the bug, so all I have is my customers error message. I have source maps for the deployed code, but not sure if I can look up whatever h is in them