Fork me on GitHub
#shadow-cljs
<
2018-07-23
>
flyboarder00:07:01

@thheller so after spending all night fixing errors that shadow warned all the builds compile, except that I am getting a new error on runtime: IllegalStateException: ASSIGN 2 [length: 45] [source_file: feathers/app.cljs] is not the parent of GETPROP 2 [length: 21] [originalname: feathers] [source_file: feathers/app.cljs]

Josh Horwitz02:07:50

I was looking to use https://github.com/priornix/antizer to use Ant design CSS framekwork in my project, but I can’t seem to get it to work. I have the cljsjs/antd added to my shadow-cljs.edn but I’m getting the error ’cljsjs.antd` is not available.

flyboarder03:07:43

Looks like I was able to solve the above with simple optimizations

thheller05:07:40

@joshua.d.horwitz see https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs so you'd create a src/cljsjs/antd.cljs with

(ns cljsjs.antd
  (:require ["antd" :as antd]))

(js/goog.exportSymbol "antd" antd)

thheller05:07:28

@flyboarder can you share the feathers/app.cljs? maybe you are doing something you are not supposed to. never seen that error before though.

thheller05:07:52

@flyboarder oh I do think I have seen this error before. are you maybe doing (def feathers feathers) or something similar? ie. assigning a variable to its own name?

flyboarder14:07:59

This is exactly what I am trying to do!

flyboarder14:07:23

It worked with boot-cljs without issues, but moving to the npm packages from cljsjs seems to complain

thheller15:07:20

why are doing that though? it doesn't do anything?

thheller15:07:54

I understand that you did need to do this with cljsjs to pull the global into the local scope but you no longer need that with shadow-cljs since there is no global to pull in

flyboarder18:07:01

@thheller often what I am doing is directly exposing something from an npm lib via my own lib which then gives easy access to whatever was in npm, for whoever consumes my library

flyboarder18:07:01

but I guess if I wrap this in a function it will do the same thing

thheller18:07:12

its fine if you choose different names

thheller18:07:50

just assigning the same name to itself actually assigns itself, ie. var x = x; so it ends up undefined

mitchelkuijpers09:07:37

Just tried it out, this is very helpful for us. Because sometimes we need to work inside of an iframe with ngrok. Loading 1000's of files often takes a while 😛 It works for us with one module and fails for the other 4 modules we have. One fails with:

root.cljc:28 Uncaught TypeError: Cannot read property 'create_react_factory_STAR_' of undefined
    at eval (root.cljc:28)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:2188)
    at Object.env.evalLoad (shared.js:3042)
    at issue-linking-panel.js:1

mitchelkuijpers09:07:44

Another one fails with:

main.cljs:28 Uncaught TypeError: Cannot read property 'get_SSR_initial_state' of undefined
    at eval (main.cljs:28)
    at eval (main.cljs:50)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:2188)
    at Object.env.evalLoad (shared.js:3042)
    at page-linking-panel.js:3
But I have to say those two cannot connect to the shadow-cljs websocket because that runs on localhost, could that be related?

thheller09:07:06

hmm are you calling eval in main.cljs or root.cljc? can you share whats happening in the reported lines?

mitchelkuijpers09:07:04

Hmm one is runnning: (def spinner (utils/create-react-factory "spinner/default")) which is a macro which does:

(defn create-react-factory* [clazz]
  #?(:clj (constantly nil)
     :cljs (createFactory clazz)))

mitchelkuijpers09:07:09

The other one is failing on:

(ssr/get-SSR-initial-state)
which is from fulcro which reads transit from a script tag, so I can imagine it might be using eval

thheller09:07:21

is there an earlier/later error related to the ssr namespace?

thheller09:07:06

it just seems like the namespace isn't created properly which can happen when an exception it thrown

mitchelkuijpers09:07:31

browser.cljs:321 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:321
(anonymous) @ browser.cljs:379
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ shared.js:3320
browser.cljs:321 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
    at Object.shadow$cljs$devtools$client$browser$ws_connect [as ws_connect] (/js/modules/cljs-runtime/shadow.cljs.devtools.client.browser.js:982:15)
    at eval (/js/modules/cljs-runtime/shadow.cljs.devtools.client.browser.js:1064:37)
    at eval (<anonymous>)
    at Object.goog.globalEval ()
    at Object.env.evalLoad ()
    at 
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:321
(anonymous) @ browser.cljs:379
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ shared.js:3320
main.cljs:28 Uncaught TypeError: Cannot read property 'get_SSR_initial_state' of undefined
    at eval (main.cljs:28)
    at eval (main.cljs:50)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:2188)
    at Object.env.evalLoad (shared.js:3042)
    at page-linking-panel.js:3
(anonymous) @ main.cljs:28
(anonymous) @ main.cljs:50
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ page-linking-panel.js:3

thheller09:07:38

since that would currently abort loading all the things that come after

mitchelkuijpers09:07:53

These are all errors that it is trying to connect to shadow so maybe that makes the rest fail

mitchelkuijpers10:07:04

Because it works with one module which can correctly connect to shadow-cljs

thheller10:07:17

ah ok yeah that makes sense

thheller10:07:42

the devtools are loaded first via preload. that throws when loading and aborts loading the rest

thheller10:07:00

try setting :devtools {:enabled false}

thheller10:07:30

I will make the websocket detection more robust so it doesn't hard fail and breaks everything else

thheller10:07:58

with the traditional loader this doesn't affect the overall loading since each file is eval'd individually

thheller10:07:15

@mitchelkuijpers just pushed 2.4.24 which should handle this more gracefully

Hukka11:07:52

@thheller @mitchelkuijpers I'll start a thread here, since this is a bit different. Earlier I prodded about the small files too. Then I started to work on jetty's http/2, which took a while since the adapter's h2 support was broken, and only today I managed to fix it. It didn't help squat. Jetty was using full 4 threads and page load was over a minute. Then I wondered if the problem wasn't jetty, but ring. Or compojure. So just last hour I tried changing resource serve from routes into wrap-resources. Now page load is 1.5 seconds

Hukka11:07:27

http/2's effect now is neglible, at least with localhost latencies. Might still matter with some added latency, will try that later.

Hukka11:07:21

Even browsing straight to /index.html which maps to the filesystem shaves about 100ms off the loading time

Hukka11:07:08

For comparison, my pageload is about 700 requests with dev mode on

Hukka11:07:33

With Chrome's fast 3G preset h2 is 55 seconds and http/1.1 85 seconds

Hukka11:07:45

That's without server push, which I won't bother setting up for now

Hukka13:07:13

I was barking the wrong tree completely. The problem is the authentication handler. It's checking the pw hundreds of times...

thheller15:07:27

FWIW shadow-cljs supports h2 automatically when you enable SSL

thheller15:07:46

but yeah h2 doesn't help much on localhost