Fork me on GitHub
#clojurescript
<
2017-07-29
>
aranhoide01:07:33

I'm trying to use Google Closure's Html5History to handle navigation within my SPA. This works fine with no optimizations but breaks in advanced mode:

(Html5History. nil
                       ;; Custom TokenTransformer to override the default
                       ;; behavior, which appends the search string to all new
                       ;; tokens.
                       #js {:retrieveToken (fn [prefix location]
                                             (subs (.-pathname location) (count prefix)))
                            :createUrl (fn [token path-prefix location]
                                         (str path-prefix token))})

aranhoide01:07:11

i.e., I guess I should be passing an instance of TokenTransformer, but instead I just pass a plain object which has the right function names

aranhoide01:07:25

but it seems the function names get munged by advanced compilation

aranhoide01:07:18

I'd like to try passing a proper TokenTransformer, but how do I create one in Clojurescript?

fabrao01:07:24

Hello @ajpierce . I looked at https://ajpierce.github.io/posts/react-figwheel-npm/ and I tried the steps and got No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react". Do you think am I missing something?

ajpierce02:07:26

Hi Fabrao! The Clojurescript team released a new version just a couple hours ago that addresses some of the issues I was attempting to solve in my post; I'm doing another sample project from scratch with the newest version and then i'll update the blog post

ajpierce02:07:56

I'll also create a quick github gist of the project.clj and core.cljs

ajpierce02:07:52

Give me a little bit and I'll have something else up; hopefully it will solve the issue you're running into 🙂

fabrao03:07:58

Hi, thanks a lot, I´ve tried with anmonteiro to do something near it, but it didn´t work. So, I saw your post and I tried it.

fabrao03:07:04

and didn´t work again 🙂

ajpierce04:07:25

Yeah, i'm getting the same error as you using the latest clojurescript build; it doesn't download anything form npm into node_modules automatically; trying to figure out how that happened for me earlier

ajpierce04:07:32

I remember they just showed up and i was so surprised

fabrao04:07:39

are you using mac or linux?

ajpierce04:07:45

I'm on a mac

fabrao04:07:16

I tried in Windows and Linux but no download

fabrao04:07:35

so, I´m still using .js import manualy

aranhoide02:07:45

for the benefit of anyone having similar problems: the following gist works in advanced compilation: https://gist.github.com/pleasetrythisathome/d1d9b1d74705b6771c20#file-browser-cljs-L14

mfikes02:07:53

@aranhoide Read about “externs” for :advanced, which prevents name munging https://clojurescript.org/reference/advanced-compilation

ajpierce03:07:34

Working on updating my blog post with the new process.env shimming, and I'm noticing that node_modules are no longer automatically installed. Is there a compiler option I need to pass to make that happen?

reefersleep11:07:50

I've googled a bit but not managed to find any articles on speeding up REPL startup/build time for CLJS projects. Do you guys know of any writeups on the matter or perhaps specific tips? 🙂

dnolen11:07:55

@ajpierce :install-deps true for the old behavior and cljs.build.api/install-node-deps! to manually run this step.

dnolen11:07:56

@reefersleep :parallel-build helps, but probably the best way is to just partition the build instead of building everything, which may require restructuring the code a bit

reefersleep11:07:54

cheers @dnolen 🙂 I wonder if there's any partitioning to be done in my hobby projects. All of them are very small to begin with. I'm not very knowledgeable about build processes, as you can tell, which is why I was hoping someone had done a writeup on the theme 🙂

dnolen11:07:13

oh for hobby projects speeding up start time isn’t so hard

dnolen11:07:42

if you do it right it shouldn’t take much longer than 1.5 seconds on newer hardware

dnolen11:07:24

but this is raw REPLs, if you’re going to use Figwheel or nREPL then there’s going to be some startup time

reefersleep11:07:38

Hah, does a T500 from 2008 constitute "newer hardware"? 😉

reefersleep11:07:50

But yeah, I'm also using Figwheel

reefersleep11:07:20

And since I'm using cider, I guess nREPL too

dnolen11:07:22

yeah I’m on a slower machine as well so I’ve done a lot a work around this, but you bottom out at your tooling choices

reefersleep11:07:37

So I'm really making it hard for myself 🙂

dnolen11:07:59

well for example I always use the AOT ClojureScript artifact

dnolen11:07:08

just compiling ClojureScript eats into start time

dnolen11:07:34

[org.clojure/clojurescript "VERSION" :classifier "aot"]

dnolen11:07:02

most tooling however is not AOTed so you have to wait for that stuff to compile

reefersleep11:07:16

My machine has trouble just running Slack in the browser...

reefersleep11:07:31

I'l give that and :parrallel-build a go 😄

dnolen11:07:23

given your machine and your projects I think :parallel-build will probably not have much impact

dnolen11:07:43

a AOTed figwheel-sidecar artifact would probably have much more impact.

dnolen11:07:03

ditto for the nREPL bits

reefersleep11:07:59

I'll look into that, for sure! I must admit that I stopped keeping up with hardware details a long time ago, can't remember when multiple cores became commonplace.

reefersleep12:07:26

It doesn't seem like AOT builds are available online for figwheel-sidecar. Do I have to clone and compile it myself (possibly with some magic compile flags) to provide it locally?

dnolen12:07:39

projects have to make them and publish them

dnolen12:07:07

many projects don’t do this - but I think for critical pieces of the ecosystem I don’t see why people aren’t

dnolen12:07:47

AOT can be a bit finicky it’s true but I think ClojureScript shows that it’s possible for a large Clojure project to be AOTed and work as expected

reefersleep12:07:57

hm, alright. I guess I'll have to lobby @bhauman for AOT of figwheel-sidecar, then 🙂

deadghost14:07:45

I'm using reagent and am getting component flashing

deadghost14:07:09

I suspect it's because I am using reagent/render more than once

deadghost14:07:15

would mounting the same component result in re-rendering even though the data/state is the same?

jpmonettas15:07:22

@dnolen super minor detail but in the readme, maven dependency information still points to <version>1.9.670</version>

deadghost15:07:26

after reading around a bit, yep looks like reagent/render would force a re-render

jeremys15:07:10

@dnolen As we discussed I creted a minimal repo concerning CLJ-2280 it is linked in the ticket’s comment https://dev.clojure.org/jira/browse/CLJS-2281.

dnolen15:07:01

@jeremys this your first time reporting on an issue so I understand you might not be familiar with the process.

dnolen15:07:17

In general it’s not acceptable to link outside of the ticket to minimal repro

dnolen15:07:29

even less acceptable for the minimal repo to use any form of external tooling

dnolen15:07:37

no Maven, no Lein, no Boot

dnolen15:07:26

please provide a minimal repo inline in the ticket - demonstrating how to reproduce with only the QuickStart uberjar

dnolen15:07:06

glancing over your repo it’s mostly in good shape, just get that info into the issue

dnolen15:07:55

also the Node stuff needs to go into a separate issue - assuming these are related is not recommended

jeremys15:07:04

Sorry my bad ok I’ll work on that!

jeremys15:07:43

I’ll take a look at other tickets to see how to do it properly