Fork me on GitHub
#shadow-cljs
<
2019-08-18
>
Jeremy00:08:52

Hi Thomas, everyone. I'm trying to use @date-io/moment in conjunction with @material-ui/pickers as described at https://material-ui-pickers.dev/getting-started/installation (except via cljs). When I :require ["@date-io/moment" :default MomentUtils], the cljs repl tells me (undefined? MomentUtils) => true. MomentUtils seems to be built from a TypeScript export default class. The js rendition looks like var MomentUtils = (function () { function MomentUtils (_a) {...}; ...; return MomentUtils; }()); module.exports = MomentUtils

Jeremy00:08:15

Other js libs are coming across fine. Is there something about the way MomentUtils is implemented which causes shadow-cljs to leave it undefined?

thheller07:08:31

@clojure475 no it is related to default exports. They only work when the code is actually shipped as ESM but most of the time it is shipped as pre-compiled CommonJS. see the section about default exports here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports

thheller07:08:50

most likely you just need ["@date-io/moment" :as MomentUtils]

Jeremy07:08:54

thank you!

Jeremy07:08:19

naturally I've now gone down an adjacent rabbit hole

thheller07:08:51

yeah it is an annoying situation currently. all currently released versions of webpack have a sort of hack to cheat CommonJS<->ESM interop so it sort of works in webpack

thheller07:08:58

but webpack5 will be removing that hack

thheller07:08:07

so things should become cleaner in the future

Jeremy07:08:10

I'm pretty sure I tried :refer [MomentUtils], but might not have tried :as

Jeremy07:08:13

thanks for all your incredible work; I'm fiddling with juxt/tick now... and hand-shimming js-joda in the spirit of shadow-cljsjs... how do we get ourselves into these situations!?

thheller07:08:25

I wish those shims weren't necessary but mixing cljsjs and npm is a recipe for disaster so you have to pick one and I went with npm

Jeremy07:08:40

rightly so

Maksym15:08:25

hi I have just installed shadow cljs and expo and I'm truing to run a project, have anybody faced such error?

Ī» shadow-cljs watch app
shadow-cljs - config: D:\Dev\clojure\rn-rf-shadow\shadow-cljs.edn  cli version: 2.8.50  node: v10.9.0
shadow-cljs - starting via "clojure"
Exception in thread "main" java.io.FileNotFoundException: -A:dev (The system cannot find the file specified)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:110)
        at clojure.lang.Compiler.loadFile(Compiler.java:7083)
        at clojure.main$load_script.invoke(main.clj:274)
        at clojure.main$script_opt.invoke(main.clj:336)
        at clojure.main$main.doInvoke(main.clj:420)
        at clojure.lang.RestFn.invoke(RestFn.java:619)
        at clojure.lang.Var.invoke(Var.java:430)
        at clojure.lang.AFn.applyToHelper(AFn.java:195)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)

Maksym15:08:55

I have intuition that I have this error because I work on Windows and I made a trick to use clojure, by default I has only clj in console.

thheller16:08:21

@titov on windows it is expected that you are using the "official" windows distribution. see https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows

Maksym16:08:25

@thheller yeah I've just wanted to write that my approach was wrong, for those who will have this error in future don't follow my path don't install clojure with choco and don't create copy of clj.bat with name cljure.bat, use developers instructions

thheller16:08:34

I wasn't aware there are other approaches. If there are other solutions in other package managers I can add some kind of detection

Maksym16:08:03

But it does not work properly as I understood it only gives clj without clojure

thheller16:08:44

1.6? that seems extremely old?

thheller17:08:26

deps.edn didn't even exist back then so that seems like an entirely different thing?

Maksym17:08:28

idk, definitely I'm not going to use it heh, the author of choco package should update his module

thheller17:08:09

just don't use deps.edn. then you don't have to deal with any of this and just let shadow-cljs handle everything šŸ˜›

Maksym17:08:21

Ok, I have just launched rn-rf-shadow project on my phone, imma play with it šŸ˜„

Maksym18:08:06

how can I connect to REPL server of my app?