Fork me on GitHub
Rob Aguilera01:07:09

What's the best way to load a file in Clojurescript? I'm trying to read an .env file to retrieve my api keys.


there might be a lib but my first instinct would be to use platform interop - it's not hard to use node apis (or use the OS js apis on the slim chance you are using that instead of node...)

Rob Aguilera01:07:51

I'm actually not using Node. It's just a toy app I'm building to play around with cljs. The only library I'm using is Reagent.

Rob Aguilera01:07:28

I tried the environ lib but couldn't make that work. Tried a variety of things and could never get CLJS to recognize the library (I'm also using leiningen for what what that's worth)


if you aren't using node, which js vm is running your code?


if it's running in a browser, you can't read their files unless the user explicitly goes and provides it to the app, for security reasons


if you want to do this from the server, this is a clojure question and not a clojurescript one

Rob Aguilera01:07:28

Good question, I'm not actually sure. I'm using lein with the reagent template. I don't think it's running node under the hood. I'm actually trying to read my own .env file in my project directory for the API key I'm going to use to hit a third party api.


OK then this is a clojure question, you can use slurp in your clojure code (the part that runs on the back end)

Rob Aguilera01:07:50

Yeah I know you can use the io namespace in Clojure. Was hoping I could do something similar in CLJS. Bummer, thanks anyways!


cljs can't read data on your server, because it's running on the client's machine


if it could read files on your server, that would be a big problem


also, if its a secret, it can't go to a random person's browser. if it does, it's not secret since you've shared it

💯 3

funny how secrets work that way isn't it


its easy to slip into code = compiled and not inspectable i guess


when I was first learning ot program I often thought things were safe because I would never figure them out


I underestimated how much more I'd know a few decades later

Rob Aguilera02:07:23

Gosh that's such a good point. Was too busy figuring out clojure I forgot the basics. Thanks for the help guys.


Hi. I've been using material-ui in my cljs. I have used Button, TextField components. But I cant use material-ui/MenuItem component. I want to use it inside material-ui/Select. My code is: (defn MenuItem [] [:> material-ui/MenuItem {:value "a"}]) ; :children "A"}]])) (defn Select [] [:> material-ui/Select {:defaultValue "Change Review event" :multiple true :values ["a" "b"]} (MenuItem)]) I get this error:

The above error occurred in the <ForwardRef> component:
    in ForwardRef (created by ForwardRef)
    in div (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by ForwardRef(Select))
    in ForwardRef(Select) (created by WithStyles(ForwardRef(Select)))
    in WithStyles(ForwardRef(Select)) (created by reviews_next.pages.feedback_event.feedback_event)
    in div (created by reviews_next.pages.feedback_event.feedback_event)
    in div (created by reviews_next.pages.feedback_event.feedback_event)
    in reviews_next.pages.feedback_event.feedback_event (created by )
    in div (created by )


It talks about "The above error". And what is the above error?


Thanks @U2FRKM4TW, I have resolved the error. I had to change the :values to :value in Select component.


Hi all, I want to consume some es6 code from clojurescript, which doesn't come from a library - I mean the es6 code is just a local file. It is possible to require a .js file from cljs when it is written with goog.provide I know, but this code is written as an es6 module. The Google Closure compiler is fine reading this es6 code when I invoke it directly (not via cljs compiler) and I have a demo of that here, but I can't work out how to write the clojurescript require so that it will work to read the es6 file. I want this to work everywhere, including shadow so js modules is not going to be an option. I'm starting to dig into the cljs compiler for answers but if anyone can give me some pointers it'd be appreciated 😉


I've asked about es6 import from google closure module on Closure forum so maybe that will provide the next clue


regular CLJS does not


Thanks! Shame regular cljs doesn't support this


Tried this a while ago and had problems getting both to work.

👍 3

Hey, not sure if I am posting this on the right channel (its my first public message ever on this Slack), but in one of the projects I am migrating from cljs-time 0.4.0 to 0.5.2 and it seems that behaviour of cljs-time.coerce/from-string has changed over the years, i.e.:

(cljs-time.coerce/from-string "2015-06")
=> #object[Object 20150106T000000]
Has anyone came across this? Not sure if this behaviour is expected? I'd expect 2015-06-01, not 2015-01-06. I can probably change the order of formatters used to parse dates, but I'd prefer not to.


But "2015-06" is ambiguous either way. If you yourself know that it's definitely "yyyy-MM", then it's better to avoid from-string altogether and just call cljs-time.format/parse.


hmmm, cljs-time.format/formatters contains an entry for yyyy-MM , but unfortunately for me another formatter is chosen by parse-string. So I will just assume the input is in yyyy-MM format and parse it as such, what seems doable. Thanks @U2FRKM4TW


couldn't you effect this by specifying a locale? it's a regional thing which order month/day are in right?


probably better to specify a precise ISO rather than locale actually


It feels like you could treat this as a valid RFC-3339 representation, just like #inst "2015-06" works


I guess it depends on what semantics you want to tie to that string...


Oh, wow, sorry about that. I didn't realize the date format for #inst isn't really specified as ISO 8601, which allows for partial representations. (RFC-3339 doesn't allow for what I suggested above.) I guess the actual format of #inst is a bit of an open question.


in java.time that would be the default format of a YearMonth, which is as ISO thing . using yearmonth entity you can convert into date etc. unashamed plug coming up: