Fork me on GitHub
#shadow-cljs
<
2017-11-10
>
mitchelkuijpers07:11:09

Oh nice good idea

thheller08:11:51

@mitchelkuijpers did you do any other tweaks to get the nREPL working or was including the middleware enough?

mitchelkuijpers08:11:56

Including the middleware was enough

thheller08:11:46

could you post the setup somewhere so I can use it for future tests? 🙂

mitchelkuijpers08:11:05

Will have to extract it will do it this weekend

mitchelkuijpers08:11:55

Will make one with a automatic emacs configuration so you can also run it in emacs 😛

mitchelkuijpers08:11:21

You have project specific config if you use projectile (which spacemacs does)

thheller10:11:21

so I finally wrote that blog post about JS deps

thheller10:11:44

please let me know if I missed something or how to improve it overall

cmal12:11:43

Hi, @thheller ! Do we have a method to hot-reload over https in shadow-cljs watch app now?

thheller12:11:17

not yet. I have it working but dealing with certificates is pretty painful 😞

cmal12:11:53

What is the problem? I wonder whether I can help.

cmal12:11:36

reloading hundreds of files every time is also painful.. 😢

thheller12:11:48

the problem is that the default java keytool for working with certificates doesn’t like things openssl generates

thheller12:11:51

and vice versa

thheller12:11:59

so you constantly need to convert between each

cmal12:11:52

It seems a profound field.

thheller12:11:58

for example this method of generating self-signed certs https://certsimple.com/blog/localhost-ssl-fix

thheller12:11:06

can’t be directly imported into java

thheller12:11:19

so you first need to convert it using openssl

thheller12:11:25

super annoying

cmal12:11:17

Can we use nodejs ssl? Or does it have the same problem?

thheller12:11:33

can’t use it and probably similar issues

thheller12:11:58

once you have a cert its pretty easy though

cmal12:11:20

I have a cert 😄

thheller12:11:30

I can merge the branch I have for this so you can try it

thheller12:11:43

is that cert compatible with keytool though? 😛

cmal12:11:44

OK. Thank you for that.

cmal12:11:01

Not sure. But I can have a try.

thheller12:11:30

also the most annoying thing is that java requires a password on a cert

thheller12:11:01

no way I’ll allow putting a password into the shadow-cljs.edn config

thheller12:11:10

but how do I get it then? 😛

thheller12:11:26

what format is the cert in? .p12? .pem?

cmal12:11:17

I only used them. The only thing I know is there is a privateKey file and a certificate file.

thheller12:11:04

what do they look like?

thheller12:11:08

-----BEGI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lay45jpFeObU5LMe57iNizRCF6E7eDPh7O0EIfJM+IcWtrxc
PDLcVSI=
-----END CERTIFICATE-----

thheller12:11:12

that style?

cmal12:11:21

I'll have a look

thheller12:11:10

dont paste the priv key 😉

cmal12:11:26

I almost do that...

thheller12:11:01

are they plain text files or some binary stuff?

thheller12:11:20

-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAxV7BEpu7npq...

cmal12:11:44

plain text

cmal12:11:48

both are.

thheller12:11:47

ok, let me grab my notes. kinda forgot how this worked already.

thheller12:11:54

once you have the cert stuff sorted out its easy 🙂

cmal12:11:09

Ahh, how can I try it?

cmal12:11:29

Have you merged the branch?

thheller12:11:01

cleaning it up a bit, will do soon

cmal12:11:08

Thank you.

thheller13:11:32

I’ll write up the instructions for getting a self-signed cert for osx

thheller13:11:45

maybe you can figure out how it works if you already have a cert

thheller13:11:00

keytool has quite a few very confusing options

cmal13:11:07

Thank you. I will have a try

thheller13:11:27

those are the steps I did to get the cert I’m using for testing

thheller13:11:19

the SAN stuff is important for Chrome. Otherwise I couldn’t get it to trust the cert.

cmal13:11:05

Sorry for bothering. I have the key and cert file on my server. Should I download the two files and add the path of them to :ssl?

cmal13:11:17

Or I should use keytool?

thheller13:11:12

you must use keytool to create the keystore. I have no clue if you can import the certs you already have

thheller13:11:15

but I think you can

cmal13:11:01

Ok. I will have a try.

thheller13:11:22

that tool is probably more complicated than java itself but it can do pretty much anything related to ssl

cmal14:11:54

Hi, @thheller. It seems there is some (goog-define ssl false). How to enable ssl? I generated a keystore but don't know how to use it, if it can be used. I've already add :ssl {...} to shadow-cljs.edn

mitchelkuijpers14:11:15

I just upgraded to the newest shadow-cljs and I start getting errors like:

ReferenceError: [BABEL] node_modules/styled-components/dist/styled-components.es.js: Unknown option: /home/mitchel/Development/atlas-crm-next/node_modules/react/react.js.Children. Check out  for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

For more detailed information on preset configuration, please see . (While processing preset: "/home/mitchel/Development/atlas-crm-next/node_modules/react/react.js")
    at Logger.error (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/logger.js:41:11)
    at OptionManager.mergeOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
    at /home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
    at /home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
    at Array.map (native)
    at OptionManager.resolvePresets (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/index.js:212:65)

mitchelkuijpers14:11:32

Oh wait is it loading babel config?

thheller14:11:42

@mitchelkuijpers looks like it. did it work before?

thheller14:11:52

@cmal did you restart the server process?

thheller14:11:01

the define will be set automatically

cmal14:11:30

I just restart shadow-cljs watch app.

cmal14:11:44

and I see shadow-cljs - starting ...

cmal14:11:53

shadow-cljs - config: /Users/yuzhao/gits/luminus-projects/shadow-cljs-demo/shadow-cljs.edn version: 2.0.71

cmal14:11:52

Still got this.

browser.cljs:260 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:260
(anonymous) @ browser.cljs:303
browser.cljs:260 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] ()
    at 

cmal14:11:25

Shouldn't it talk to the browser using wss://?

thheller14:11:31

it should if ssl is set

cmal14:11:20

Should :keystore "the-file.ks" be in the same path of shadow-cljs.edn?

thheller14:11:16

its relative to the project root, so in that case yes

cmal14:11:01

Is the version 2.0.71 the newest?

cmal14:11:32

I see the clojars gray in github frontpage.

thheller14:11:38

yes, add :http {:port 8021} to your config, restart the server and open

cmal14:11:39

ERR_SSL_PROTOCOL_ERROR

cmal14:11:04

maybe the keystore is not valid?

cmal14:11:09

shadow-cljs coming soon ...

thheller14:11:20

ok, so ssl config isn’t working

mitchelkuijpers14:11:20

@thheller It did work before, and I did not see the babel transforms before

cmal14:11:31

shadow-cljs - server running at http://localhost:8021

thheller14:11:50

do you have :ssl {...} at the top level?

thheller14:11:55

not in the build config?

cmal14:11:19

{:dependencies
 [[cljs-ajax "0.7.2"]
  [re-frame "0.10.2"]
  [day8.re-frame/undo "0.3.2"]
  [day8.re-frame/http-fx "0.1.4"]
  [cljsjs/react "15.6.2-0"] ;; required by "reagent/impl/util.cljs"
  [reagent "0.7.0"]
  [reagent-utils "0.2.1"]
  [secretary "1.2.3"]
  [garden "1.3.3"]
  #_[braintripping/re-frame-trace "0.1.9"]
  [binaryage/devtools "0.9.7"]
  [re-frisk "0.5.0"]]

 :ssl {:keystore "my-keystore.jks"
       :password "000000"}
 
 :http {:port 8021}...}

thheller14:11:22

@mitchelkuijpers doh. I accidentally enabled the use of package.json "module".

thheller14:11:34

I did some tests with that and forgot to disable it again

thheller14:11:39

thats probably the issue

mitchelkuijpers14:11:46

Ah it does look cool but I get some random issues now 😛

thheller14:11:43

I’ll disable it again. It is definitely causing too many issues.

thheller14:11:21

@cmal I’m setting up a test project now. only tested it from within shadow-cljs itself so I might have missed something

cmal14:11:40

OK. You can clone https://bitbucket.org/cmal/shadow-cljs-demo and run shadow-cljs watch doumi

thheller14:11:44

test project works as well

cmal15:11:18

Does that mean I give an invalid keystore file?

thheller15:11:51

that should throw an exception. your config looks ok.

cmal15:11:46

I can not remember why I add "/Users/yuzhao/gits/shadow-cljs/src/main"to the :source-paths

thheller15:11:12

yeah you need to remove that

thheller15:11:18

or git pull that checkout 😛

cmal15:11:20

still shadow-cljs - server running at

thheller15:11:30

otherwise you are using the old code

cmal15:11:33

I removed it.

thheller15:11:40

it works for me?

cmal15:11:52

still shadow-cljs - server running at 😢

thheller15:11:15

yeah I didn’t update the message yet. it will show http always.

thheller15:11:22

need to open it to actually see if its working

cmal15:11:52

it seems works

cmal15:11:23

browser.cljs:281 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

cmal15:11:35

maybe this is because of the cert

thheller15:11:45

check this

cmal15:11:57

NET::ERR_CERT_REVOKED

thheller15:11:34

yeah, getting a full trusted cert is complicated

thheller15:11:07

you can create one for localhost as I described in the GH issue

thheller15:11:13

that seems to work ok

thheller15:11:39

but I don’t know how your entire setup works since you are not using a local server?

cmal15:11:57

I rsync my cljs-runtime to the remote server.

cmal15:11:33

my Chrome get my page from remote server to debug.

cmal15:11:11

only in the wechat devtool I can get data from the API and see the whole webpage, and it must be in a https:// server.

cmal15:11:48

So I rsync my file to the remote server and debug in the wechat devtool.

cmal15:11:32

I am not sure, does the error message browser.cljs:281 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED tell me that the ssl-keystore is not valid?

thheller15:11:03

I don’t know. is your server?

cmal15:11:20

I will remove that.

mitchelkuijpers15:11:15

@thheller I am setting up devcards and I got this error:

------ ERROR -------------------------------------------------------------------
 File: /home/mitchel/Development/atlas-crm-next/src/cards/atlas_crm/hipchat/ui/configuration_cards.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns atlas-crm.hipchat.ui.configuration-cards
-------^------------------------------------------------------------------------
Invalid :refer, var devcards.core/defcard does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |    [fulcro.client.cards :refer [defcard-fulcro]]
   4 |    [devcards.core :as dc :refer [defcard]]
   5 |    [atlas-crm.ui.screens.hipchat.configuration :as configuration]
   6 |    [fulcro.ui.forms :as forms]))
--------------------------------------------------------------------------------
when I changed the :refer to :refer-macros it started working. Is the compiler maybe to strict? Because this should work in CLJS

thheller15:11:54

hmm devcard.core has no self-require https://github.com/bhauman/devcards/blob/master/src/devcards/core.cljs so no it should not work

cmal15:11:36

@thheller that is the server. remove :http {:port 8021} got WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

mitchelkuijpers15:11:06

Ah true, then it's correct

mitchelkuijpers15:11:14

Nvm then @thheller sorry for wasting your time

thheller15:11:44

@mitchelkuijpers should definitely be done by devcards though. does it really work in figwheel without?

mitchelkuijpers15:11:00

Yeah somehow it works in figwheel

thheller15:11:01

maybe something in that behaviour changed in CLJS itself?

thheller15:11:26

it used to only work with self-require, maybe thats optional now?

thheller15:11:34

I can totally make that optional too

mitchelkuijpers15:11:00

I don't know tbh

cmal15:11:41

@thheller I see. the wss:// server should be in my local machine, not the remote server.

mikeb15:11:01

Does anyone know if shadow-cljs appends timestamps to sourcemaps, same as the main cljs compiler does mentioned here https://www.reddit.com/r/Clojure/comments/7bwtzu/anyone_here_using_macchiato_in_production/dplvemz/

cmal15:11:07

The connect to nothing.

thheller15:11:14

@mikeb no it does not

mikeb15:11:34

Awesome, thanks. Will let the guys over there know.

mitchelkuijpers15:11:53

@mikeb btw that breaks sourcemaps in firefox if you add timestamps

thheller15:11:02

@cmal you are probably running into https://github.com/thheller/shadow-cljs/issues/91 now. did the websocket ever work?

thheller15:11:08

I gotta go for a bit … bbl

cmal15:11:20

Thank you for that!

chrisdavies15:11:27

Anyone here gotten shadow-cljs to work with Node? I'm getting Assert failed: (satisfies? build-log/BuildLog logger) when I run.

chrisdavies15:11:35

I opened an issue before I thought to come here. 🙂

cmal15:11:31

DEVTOOLS: connected!
browser.cljs:25 DEVTOOLS: REPL init successful

chrisdavies15:11:18

^^^ My error was caused by an invalid main configuration.

chrisdavies15:11:21

{:id :script
   :target :node-script
   :main shadowhi.core/main
   :output-to "dist/shadowhi.js"}}}

chrisdavies15:11:26

That worked for me.