This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-10
Channels
- # announcements (3)
- # babashka (16)
- # beginners (41)
- # biff (4)
- # calva (14)
- # circleci (1)
- # clj-http (24)
- # clj-kondo (9)
- # clj-on-windows (31)
- # cljs-dev (52)
- # clojure (162)
- # clojure-australia (10)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-spec (1)
- # clojure-uk (5)
- # clojurescript (40)
- # conjure (6)
- # core-async (3)
- # cursive (5)
- # datalevin (11)
- # datomic (7)
- # emacs (12)
- # etaoin (19)
- # events (1)
- # figwheel-main (17)
- # fulcro (4)
- # graalvm (3)
- # gratitude (13)
- # honeysql (8)
- # introduce-yourself (7)
- # london-clojurians (1)
- # off-topic (9)
- # polylith (9)
- # rdf (1)
- # re-frame (21)
- # releases (5)
- # remote-jobs (4)
- # sci (28)
- # shadow-cljs (15)
- # spacemacs (2)
- # vim (4)
- # xtdb (15)
having issues with advanced compilation when using npm modules + webpack. This isn't related to externs, I think? Here's an example of the generated code before bundling, with :pseudo-names true
. The method names are minified, as indicated by the dollar signs. But moment itself is not, the name in moment is still ISO_8601
without the dollar signs. Probably because moment itself is not part of the advanced compile minification? Any thoughts?
seems like that's because it's a call directly on the imported react
. (.locale moment)
works fine in my code as well, it's methods called on moment that isn't, and gets minified (such as (.toDate (moment))
)
so from what I can tell so far, this example from the docs won't work in advanced compilation
Is this with :infer-externs
set to true
?
I’m pretty sure I have used moment
at some point with cljs & figwheel; nowadays I mostly just use regular javascript for dates. So that’s a tip, but not helpful if you need to do arithmetic on the dates.
https://time2hack.com/you-dont-need-libraries-for-internationalisation-i18n-of-dates/
@hkjels yes, the behaviour is the same both with and without it. In fact, I get an inferred_externs.js
even if I don't set :infer-externs
at all, so it seems like figwheel (or something else) sets it for me
I guess this is about "externs"? I sort of assumed it's not, since they are imported into the cljs namespaces. But from the perspective of the compiler, I guess they're just opaque required blobs, instead of global variables, but still external?
seems so - I manually added externs for moment and then it worked just fine. So the issue seems to be that figwheel + webpack isn't able to generate externs properly. Which makes sense, I guess. At the time of cljs compilation, it has no access to the npm packages
I also suppose annotations like ^js/moment
won't work either. The problem isn't that cljs doesn't know which type the arguments are, but that it doesn't seem to know that (.toDate (moment))
after a (:require [moment])
in that namespace means that it can't optimize toDate on moment
yeah! I'm considering moving away from those so I can just use npm modules directly. But now I see first hand the value add of a community driven effort for managing externs :)