Fork me on GitHub
#shadow-cljs
<
2019-04-09
>
manuel09:04:57

With latest shadow-cljs (`2.8.29`), I am getting this on shadow-cljs watch:

/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:3497                                                                                                                            
!0,Hg.Ya="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717",Hg.Hb=function(b){return Vb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717")};return new Hg(a,oe)$
function Oi(a){try{var b=a[0];return b.l?b.l(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].qb(null),b;throw c;}}function Pi(a,b){b=Hi(b,Ni(function(c){a[2]=c;a[1]=4;return Oi(a)}));return z(b)?(
a[2]=H(b),a[1]=4,vh):null}                                                                                                                                                                                           
                                                                                                                                                                                                                     
                                                                                               ^                                                                                                                     
                                                                                                                                                                                                                     
TypeError: Invalid value used as weak map key                                                                                                                                                                        
    at WeakMap.set (native)                                                                                                                                                                                          
    at d (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1790:192)                                                                                                             
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1795:282                                                                                                                 
    at Array.map (<anonymous>)                                                                                                                                                                                       
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1795:259                                                                                                                 
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1700:229                                                                                                                 
    at presets (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1794:267)                                                                                                       
    at z (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1826:376)                                                                                                             
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1825:87                                                                                                                  
    at e.buildRootChain (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1830:93) 

thheller09:04:54

what the heck is that 😛

manuel09:04:05

still trying to figure it out

thheller09:04:06

I updated the babel stuff to the "new" babel7

thheller09:04:42

but the used API is kinda tiny so not a clue

thheller09:04:48

probably doesn't like something you do in the code?

thheller09:04:08

does it tell you which file it failed to convert? it should?

manuel09:04:33

no worries. I trashed the node_modules directory in the root of my project and re-installed the dependencies I need via npm. It works just fine as usual now. Sorry for the noise.

ouvasam11:04:56

Hi, does someone can get airbnb react-dates(latest version) work with reagent ?

thheller12:04:17

@ouvasam the general way should work? (:require ["react-dates" :as rd]) then in reagent [:> rd/Thing {:foo "bar"} ...]

ouvasam12:04:11

Hi @thheller, no i can't make it work. It ssems that something change from version 13 and it use react-with-styles I did already try sometimes ago but went with another lib, but i really want to be able to use it.

ouvasam12:04:14

"As of v13.0.0 of react-dates, this project relies on react-with-styles. If you want to continue using CSS stylesheets and classes, there is a little bit of extra set-up required to get things going. As such, you need to import react-dates/initialize to set up class names on our components. This import should go at the top of your application as you won't be able to import any react-dates components without it."

thheller12:04:00

and what does that produce?

thheller12:04:21

looks correct to me?

ouvasam12:04:53

Something like this but it doesn't open selector or nothing

thheller12:04:53

that looks like css is missing?

thheller12:04:14

maybe it is opening just not anywhere visible because of missing styles?

ouvasam12:04:53

Normally css should be included via import 'react-dates/lib/css/_datepicker.css'; But i included it in the html with a link tag. When focusing on a field the dom should change, but it is not the case for me

thheller12:04:21

well in your example you have hardcoded :start-date and :end-date?

ouvasam12:04:12

Yes but nothing change even if i use r/atom

thheller12:04:53

do the callbacks trigger?

thheller12:04:02

:on-dates-change #(println "on date change")?

ouvasam13:04:54

The handler is never called since i cannot change the date

thheller13:04:20

the handler is the thing changing the date so it should be called?

lilactown14:04:09

using the :chrome-extension target, I’m not sure how to setup my background script

lilactown14:04:05

my build config:

{:target :chrome-extension
   :extension-dir "extension"
   :manifest-file "extension/manifest.edn"
   :outputs
   {:devtools {:output-type :chrome/shared
               :init-fn punk.ui.chrome.devtools/init!}
    :background {:output-type :chrome/shared
               :init-fn punk.ui.chrome.background/init!}
    :panel {:output-type :chrome/shared
            :init-fn punk.ui.chrome.panel/init!}
    }}

lilactown14:04:49

relevant manifest.edn:

:background {:persistent false
              :scripts ["out/background.js"]}

lilactown14:04:08

ah. I need the bg-shared

thheller14:04:14

:background {:output-type :chrome/background

lilactown14:04:01

are there docs for :chrome-extension yet?

lilactown14:04:53

OK I see my script loaded in the background page, but I don’t see any output

lilactown14:04:10

ex I currently have this in my background ns:

(defn init! []
  (log "bg init"))

lilactown14:04:32

build config is now:

:background {:output-type :chrome/background
                 :init-fn punk.ui.chrome.background/init!}

thheller14:04:58

IIRC log output from background page is in the original devtools

thheller14:04:02

not the nested ones

thheller14:04:09

or the other way .. its weird

lilactown14:04:15

I have 3 devtools open lol

thheller14:04:44

might need to open the background page

thheller14:04:52

I can't remember really

lilactown14:04:00

yeah, I have the background page open (I think)

lilactown14:04:45

background page console is empty

lilactown14:04:02

my devtools page is where all my REPL output seems to go

lilactown14:04:52

and the console for the page I’m inspecting is blank

lilactown14:04:05

does :type :chrome/background take an :init-fn or something else?

lilactown14:04:11

I don’t actually see my namespace even loaded

thheller14:04:18

maybe only supports :entries not actually sure

thheller14:04:27

its been a while since I worked on that

lilactown14:04:30

do I need to include any of the other .js files like shared.js or bg-shared.js?

thheller14:04:44

you don't include either?

lilactown14:04:15

for the background script, I’m just include background.js atm

thheller14:04:36

you have html for your background page? shouldn't have?

lilactown14:04:58

chrome docs say I can just give it a JS file and I think it generates an HTML page for me

lilactown14:04:10

:background {:persistent false
              :scripts ["out/background.js"]}

thheller14:04:14

uhm wait you have your own manifest?

thheller14:04:24

right .. don't do scripts

lilactown14:04:25

☝️ that’s what I wrote in my manifest.edn

thheller14:04:54

just leave that out completely

thheller14:04:06

:chrome/background takes care of it

lilactown14:04:19

hmm, lots of errors now

thheller14:04:53

sorry I don't have time to look at that further now

thheller14:04:26

dig into the shadow/build/targets/chrome-extension.clj file

thheller14:04:32

maybe that makes sense and you can figure it out

lilactown14:04:20

FWIW I restarted my shadow-cljs process. I’m now getting errors about websockets. it looks like the background page is trying to connect to the shadow-cljs process

lilactown14:04:17

ah no, it’s still the old errors preventing it. nvm. I’ll dig into it

lilactown14:04:54

sigh. I’m sorry thheller. I cleared out my .shadow-cljs and it started working 😞

mauricio.szabo19:04:01

Sometimes I have the same problem too, but I'm still not able to reproduce it in a consistent way...

thheller14:04:16

that should absolutely NEVER be necessary

thheller14:04:27

if it is its a bug

thheller14:04:03

I really need to figure out why is happening for you guys .. I have never had a problem where deleting anything was necessary

lilactown14:04:06

the next time I see the startsWith error, I’ll zip up my builds folder and send it your way

thheller14:04:52

I already identified that problem with the code Wilker sent me, just can't explain how it happens

lilactown15:04:30

yeah super strange. I thought it had something to do with switching between diff versions of the closure library

lilactown15:04:49

since it was occurring so frequently when we would switch between branches with different shadow-cljs versions

thheller15:04:43

yes that would cause such a problem but the file that triggers the bad behavior should be written correctly always

lilactown15:04:59

but in this project, I’ve only ever used latest shadow-cljs. I was modifying shadow-cljs.edn and the manifest.edn, and my new background page exhibited the same behavior

thheller15:04:26

yeah dunno .. can't concentrate on this now .. gotta fix other work stuff

mss15:04:36

is there any way to change the CLOSURE_BASE_PATH output by a browser compilation? I’d like it to output a relative path but it’s prepending a /, making it an absolute path and breaking dep resolution

thheller15:04:50

set :asset-path in your config

👍 4
lilactown19:04:58

for some reason, in my background script i have a namespace that won’t load unless I trigger it to compile that namespace

lilactown19:04:10

it loads in my :browser target fine

lilactown19:04:58

(ns punk.ui.encode
  (:require [cljs.reader :as reader]))

(defn write [x]
  (prn-str x))

(defn read [x]
  (reader/read-string x))

thheller19:04:02

sounds like the other issue again. please check the background.js

thheller19:04:07

there should be some load instructions

thheller19:04:20

it might be missing that file?

lilactown19:04:26

hm. right off hand, I don’t see the load instructions

lilactown19:04:30

anything I can CTRL-F for?

thheller19:04:39

punk.ui.encode

lilactown19:04:53

that’s definitely not anywhere in background.js

thheller19:04:10

ah no wait .. nvm

lilactown19:04:11

but I don’t see any other load instructions so I might be looking in the wrong place

thheller19:04:14

it is using chrome for loading

thheller19:04:23

need to reload the chrome ext probably

thheller19:04:40

since the manifest changed

lilactown19:04:23

so I’ll need to do that anytime I add a new ns?

thheller19:04:30

currently yes

Daniel Hines23:04:56

Can someone translate to a noob what this means and what I should do instead?

[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/d4hines/repos/rectangles/src/rectangles/view.cljs:14:20
--------------------------------------------------------------------------------
  11 | (prn fps-div)
  12 | (add-watch fps :fps
  13 |            (fn [k r o n]
  14 |              (set! (.-innerHtml fps-div (str "<p>" n "<p>")))))
--------------------------^-----------------------------------------------------
Error in phase :compilation
dot prop access with args
{:form (. fps-div -innerHtml (str "<p>" n "<p>"))}
ExceptionInfo: dot prop access with args

Mno23:04:42

I have no idea, but my best guess would be it doesn’t like you passing arguments when trying to access the innerHtml?

Mno23:04:23

maybe possibly it’s like this (set! (.-innerHtml fps-div) (str "<p>" n "<p>"))

Daniel Hines23:04:49

(def fps-div (. js/document -getElementById "fps"))

Daniel Hines23:04:53

Also fails the same way.

Mno23:04:53

:thinking_face:

Mno23:04:43

maybe (def fps-div (.getElementById js/document "fps"))

Mno23:04:30

IIRC the .-something was to access a property, and method calls were just (.whatever whatever-you’re-calling-it-on arguments)

Mno23:04:39

I found this on stack overflow, it seems like what you’re trying to attempt. :man-shrugging: I dunno.

lilactown23:04:42

@d4hines that’s invalid syntax

lilactown23:04:56

what Mno is saying is correct

Mno23:04:41

I’m giving myself a gold star

16
Daniel Hines23:04:05

Aha! Thanks guys.

lilactown23:04:21

your first example would be (. fps-div innerHtml (str “<p>” n “<p>”)) for proper syntax. but also, I’m not sure you can call node.innerHtml as a function?