Fork me on GitHub
#clojurescript
<
2018-01-18
>
justinlee00:01:46

@josh_tackett After thinking about your issue I’m convinced that is a bug and I opened one up against cljs-http. Hopefully I’m not wrong about that. 🙂 https://github.com/r0man/cljs-http/issues/112

josh_tackett00:01:44

@lee.justin.m Glad to hear we help make the library better!

mac00:01:46

I am using emacs/cider/fighwheel to develop cljs on a Ubuntu machine and having intermittent issues where files are not compiled on save and newly created files are not visible to the compiler. I am periodically seeing broken symlinks appear in my project folder name as other files in the folder but prefixed with .#. I should maybe also mention that my repo is in a Dropbox subfolder. Any idea what might be going on? I can't find any mention of symlinks with a .# prefix anywhere.

dpsutton01:01:01

the .# prefix is an emacs temporary saved file where it saves a copy of your buffer because you haven't saved it

mac01:01:36

@dpsutton Yeah, just discovered that. It is actually a lock file (in realty a broken symlink) that prevents double edits. I have disabled it to see if this fixes the issue.

dpsutton01:01:26

good luck then. if you're in a git repo can you do this outside of a dropbox synced folder then?

mac01:01:09

@dpsutton Sorry, I don't think I understand your question.

dpsutton01:01:52

you mentioned you were in a drop box folder. just mentioning that if you have a repo, you probably have some remote git location. the only reason i bring it up is that it might be weird with a file watching process like figwheel

mac01:01:49

Yeah, that is my next step if this doesn't solve the issue. Thanks for bringing it to my attention. Thing is that it has worked flawlessly for a long time.

xiongtx02:01:24

It seems that :import doesn’t work as I expect in cljs:

(ns foo.bar
  (:import [goog.i18n NumberFormat NumberFormat.Format]))

(NumberFormat. Format.CURRENCY) 
;; => #object[ReferenceError ReferenceError: Format is not defined]
Using (:import goog.i18n.NumberFormat.Format), however, works. Is this a known limitation of :import?

noisesmith02:01:07

that's not a valid import syntax in clojure or clojurescript

noisesmith02:01:54

try (ns foo.bar (:import (goog.il8n NumberForma) (goog.il8n.NumberFormat Format)))

xiongtx02:01:41

Ahh, I see

xiongtx02:01:04

@noisesmith This bug was made harder to track down b/c defining a function w/ Format.CURRENCY didn’t even raise a warning. In fact, for some undefined Foo,

(defn money [n]
  (let [fmt (NumberFormat. Foo)]
    (.format fmt n)))

;; => WARNING: Use of undeclared Var cljs.user/Foo at line 2
#'cljs.user/money
but
(defn money [n]
  (let [fmt (NumberFormat. Foo.Bar.Baz)]
    (.format fmt n)))
;; => #'cljs.user/money
What’s up w/ that?

noisesmith02:01:45

I have no idea - all I know is that having a . in the middle of a symbol on the right hand side of an import sublist isn't a documented syntax

robert-stuttaford08:01:19

hi folks. i’m trying to use :npm-deps, but running into what seems to be a pretty basic bug. details: https://gist.github.com/robert-stuttaford/f314c78c5bd88e98be17fb259543128e cc @anmonteiro

robert-stuttaford08:01:56

my question: am i doing something daft, or is this a bug?

Dos12:01:16

Is there any function to round up/down to the nearest minute in #cljs-time ?

Dos13:01:05

(parse formatter (unparse formatter %))
helped

hlolli14:01:53

I have arraybuffer response type and "chunked" Transfer-Encoding, to get the body of the response, would it make sense to convert the arraybuffer to #js [] array and concat the incoming chunks and convert it back to arraybuffer (Uint8array). Or concat arraybuffers togeather. This seems to be a streaming problem I can't find much about online. psudeocode:

(aset xhr "onreadystatechange"
      (fn []
        (reset! stream (conj @stream (.-response xhr)))
        (when (= (.-readyState xhr) 4)
          (prn "ready" (new js/uInt8array @stream)))))

Roman Liutikov14:01:14

@hlolli Have a look into Fetch API

Roman Liutikov14:01:30

Is supports streaming out of the box

Roman Liutikov14:01:25

do you want to process incoming chunks one by one?

theasp14:01:38

If I am getting TypeError: Path must be a string. Received false when using :npm-deps, is that indicative of a problem with the library I am depending on, or something I am doing wrong?

hlolli14:01:56

no, I just want the final body @roman01la, I'd be curious to look at the source code on how that streaming is done. Sadly this part of the code at our company is pure js 😞

Roman Liutikov14:01:49

if you only need the body, then just add a listener that will fire once everything is fetched

theasp14:01:59

Oh, maybe I am seeing the same thing @robert-stuttaford mentioned above

hlolli14:01:33

yes, if that should work, then it's not a streaming problem, but something else

xHR.readyState==4 && (xHR.status==200 || xHR.status==201)
only for Transfer-Encoding "chunked" is the xHR.response empty. So I figured I needed to accumilate the chunks. But it could be something else, never done much streaming.

Roman Liutikov14:01:53

try "load" event, it should fire after response is fully received

hlolli14:01:50

@roman01la thanks for that tip, I think I will look more into the backend

xHR.addEventListener("load", function(){
    console.log(xHR.response.byteLength);
});
returns 0 for chunk transfers. I'll not pollute the cljs channel with more js 🙂

zalky15:01:22

Hi all, let's say you are building an authenticated SPA, where you do not want to download the main app until after authentication. The simple way to do this would seem to be to just compile and serve separate login and main app payloads. While this works, you end up recompiling the common dependencies twice. Is there a way to avoid this, maybe using modules?

thheller15:01:05

@zalky :modules is a valid solution yes.

zalky15:01:55

@thheller: would the approach be along the lines of setting the modules to load dynamically on the frontend, and then ensuring those modules resources are served from authenticated/authorized routes? Just trying to get a sense of the direction to research.

thheller16:01:30

It is really hard to give generic instructions for :modules since the “best solution” is usually specific to each individual app.

thheller16:01:20

:modules just let you split the code in specific ways so you can delay loading parts until later

thheller16:01:35

how you load them is an entirely different subject

thheller16:01:33

unfortunately I’m not aware of any open source examples that use :modules

zalky16:01:05

Yeah, that's fair. I suppose in principle it should work as long as you can ensure that the private modules are served only on authenticated routes. Thanks for the response!

thheller16:01:51

I don’t think it is useful to protect the JS files themselves. The code should ensure that the user is properly signed in and everything but that is part of your application code.

thheller16:01:50

Delayed loading of the code should just be an optimization so that users only need to load code they are actually going to use

levitanong16:01:39

@theasp @robert-stuttaford have you guys tried lein clean before rerunning the app?

theasp16:01:22

rm -rf target resources/public/js node_modules && rlwrap lein do clean, figwheel

theasp16:01:03

Interestingly, I don't get the warning unless I clean first, but whatever it writes out doesn't work in either case

levitanong16:01:20

Lol, very odd. Mine doesn’t work unless I do a lein clean

levitanong16:01:39

have you looked into shadow-cljs? I hear it clears out a lot of the npm issues.

thheller16:01:36

I can confirm that you’ll never see Undefined nameToPath for ... with shadow-cljs 😉

theasp16:01:49

Actually I was just reading about it 🙂

anmonteiro17:01:06

@robert-stuttaford I don’t think we support nested node_modules installations

anmonteiro17:01:19

didn’t NPM stop doing that too at some point?

thheller17:01:48

@anmonteiro they do it less but it still happens on version conflicts

robert-stuttaford18:01:42

@anmonteiro i’m not saying i want nested; i’m saying it seems cljs-deps is incorrectly producing a nested require relationship. the files on disk are flat, and my declared deps are flat. but it creates a nested dep call.

robert-stuttaford18:01:10

@levitanong i don’t ask for help unless i’ve tried everything first. it’s so clean you could fry your breakfast on it!

justinlee18:01:50

@robert-stuttaford run npm ls and see if npm agrees that there are version conflicts. since npm 3 the tree will be flat unless two projects have conflicting subdependencies

justinlee18:01:22

i have no idea if cljs can handle that situation if it exists, but at least it will tell you what the source of the issue is

robert-stuttaford19:01:12

thanks @lee.justin.m - i actually manually made sure that the version is correct; and npm ls confirms it. only v3.7.4 of immutable shows up anywhere.

theasp19:01:56

@thheller Yup, I don't see "undefined nameToPath"... Exception in thread "main" java.lang.ExceptionInInitializerError, compiling:(shadow/cljs/devtools/cli.clj:1:1) 🙂

justinlee19:01:54

@robert-stuttaford weird. i spent a ton of time reading the available documentation and blog posts and i still don’t understand what the npm-deps feature is actually doing. i should check out shadow-cljs but i’m having serious tool fatigue right now

robert-stuttaford19:01:42

i hear you @lee.justin.m 🙂 i’ve been spiking this draftjs thing and i’m already quite ready to set fire to everything.js

justinlee21:01:08

hey does anybody know how a cljsjs package could have disappeared? There was, apparently, a package called [cljsjs/react-dnd "2.0.2-0"] but it is gone! It’s like left-pad all over again, except that apparently I’m the only one who noticed.

justinlee21:01:09

Oh it was a fork of cjsjs/packages.

ajs22:01:52

What would cause a lein cljsbuild auto to suddenly switch from building a dev version to building a prod version after watching for a change and rebuilding?

ajs22:01:40

in one line it says it's building from ["src" "env/dev/cljs"] and in the next line it says ["src" "env/prod/cljs"]

alexisvincent23:01:23

@robert-stuttaford been getting similar issues. Often I’ve found a Lein clean fixes it. Sometimes need a second Lein clean as well

alexisvincent23:01:56

For a Clojure ClojureScript project, what’s the best way to structure them for shared code and easy cider development. Separate Lein projects or joint?

alexisvincent23:01:24

And if joint, how do you specify client does vs server does

alexisvincent23:01:19

Is there a way to specify Clojure only deps, so that the repl doesn’t bum out

noisesmith23:01:04

you could isolate all cljs only deps to the cljsbuild profile

justinlee23:01:53

has anybody ever messed with javascript interop and run into either a _classCallCheck error or a “can’t call a class as a function error”. they clearly have something to do with the babel transpilation from es6 classes but i cannot for the life of me figure out what is going on

thheller23:01:16

@lee.justin.m maybe you are calling something as a function instead of creating a new isntance via new? (Thing) vs (Thing.)?