Fork me on GitHub
#shadow-cljs
<
2018-04-11
>
lwhorton00:04:19

is the push-state built-in support :devtools { :http-handler shadow.http.push-state/handle supposed to handle more than one path? localhost:xxxx/foo still directs to /index.html, and all downstream resources still point to <asset-path>/cljs-runtime/<asset> but localhost:xxxx/foo/bar will direct to /index.html and all downstream will incorrectly(?) point to /foo/<asset-path>/main.js

justinlee00:04:37

@lwhorton if I reload on localhost:xxx/app/doc/6 or whatever it will reload the main bundle for me. is that what you are asking?

lwhorton01:04:43

i get the main bundle reloaded, but in dev mode where everything is spit into js/cljs-runtime files, the asset path is off

lwhorton01:04:52

I can write my own handler to fix it, but i’m not sure if that was the original intent

justinlee01:04:19

so i use it with an spa that uses html5 browser history. so no matter what url you hit, it should return index.html. my code then dispatches to the right page. index.html loads the right stuff at that point. it really shouldn’t matter what url you are at, if i understand correctly

lwhorton01:04:39

i wonder if my asset-path is just misconfigured, then

lwhorton01:04:29

am i going crazy? if I remove :asset-path from my configuration, it looks like main.js is dumped into my :output-dir, but for some reason everything beyond the main.js file gets a js/cljs-runtime attached? if I look at the main.js file itself i see

var CLOSURE_BASE_PATH = '/js/cljs-runtime/';

lwhorton02:04:22

ayup. the issue? <script src="/foo" .../> vs <script src="foo" >

lwhorton02:04:29

apparently breaks the world of html

quang04:04:40

anybody ever try to require aws-sdk? I'm new to shadow-cljs and am getting errors

Jon05:04:45

what's the code?

quang05:04:12

hey Jon, 1 sec

quang05:04:51

maybe it has to do with aws-sdk I tried installing a different version, and got a different error

quang05:04:42

uploading repo now...

Jon05:04:01

have you noticed module/method and module.method are different in shadow-cljs, if module is from npm?

Jon05:04:35

guessing, since it's a common mistake

quang05:04:57

2 commits, moment.js works fine, but aws-sdk craps out

quang05:04:09

> have you noticed module/method and module.method are different in shadow-cljs, if module is from npm? What is this?

Jon05:04:50

if you put module in (ns ...) to import, you should use module/method to call it.

Jon06:04:06

(ns (:require ["module" :as module]))

Jon06:04:19

if you paste code, we may rule out this case.

Jon06:04:30

hard to find a clue if you don't show the code.

quang06:04:44

(ns starter.browser
  (:require ["moment" :as moment]
            ["aws-sdk"]))

Jon06:04:26

then how do you use code from aws-sdk?

quang06:04:53

I can't, :as, :default also doesn't work

quang06:04:23

maybe aws-sdk is a monster...

Jon06:04:30

error thrown?

quang06:04:52

actually, I am trying to use aws-amplify but I can't even get aws-sdk to :require... and I think aws-amplify depends on aws-sdk...

quang06:04:15

yeah error thrown, I just tried a different version of aws-sdk and got a different error...

quang06:04:25

so might just be out of luck

Jon06:04:31

sounds strange..

quang06:04:58

thanks for the sanity check Jon!

😄 4
quang06:04:02

I couldn't get this working with leiningen either (or at least :foreign-libs, :npm-deps) context here: https://stackoverflow.com/questions/49767358/aws-amplify-with-clojurescript

quang06:04:42

shadow-cljs was my last attempt... it seems like it should work...

thheller07:04:56

@quang I identified the problem. aws-sdk has a weird circular dependency in their code which shadow has trouble with. will see if I can fix that.

javi09:04:56

when in cursive I follow the instructions to connect to the cljs repl. all works great, however, i cant access the cljs.repl apis... what am i missing?

Connecting to remote nREPL server...
Clojure 1.9.0
(require '[shadow.cljs.devtools.api :as shadow])
=> nil
(shadow/nrepl-select :b2)
To quit, type: :cljs/quit
=> [:selected :b2]
(require '[cljs.repl :refer [doc source]])
=> nil
(doc map)
=> nil
thanks

thheller12:04:11

not sure. will look into it.

javi13:04:19

let me know if i can help somehow

thheller13:04:11

hehe doh. @fj.abanses the output is printed to the browser console. the browser REPL client just didn't forward that to the REPL itself.

javi14:04:45

yeah! ha ha, i see now 🙂 didnt think of looking there!

thheller15:04:21

@quang should work in 2.2.29. at least the require works. didn't know what/how to test further. let me know if you run into other issues.

quang15:04:44

oh wow Thanks @thheller !! 🙂

quang15:04:43

nice! works with latest version of AWS 🙂

quang16:04:34

my next goal was to get aws-amplify required, (steps were 1. moment, 2. aws-sdk 3. aws-amplify) Got a weird Uncaught ReferenceError: Buffer is not defined error, but it might not be related to shadow-cljs https://github.com/aws/aws-amplify/issues/140

quang16:04:25

(ns starter.browser
  (:require ["moment" :as moment]
            ["aws-amplify"]))

thheller16:04:38

@quang I probably have a work around for that. will look into it.

thheller16:04:32

I don't get how anyone can ever say that clojure is slow when yarn add aws-amplify takes Done in 74.61s.

16
thheller16:04:13

@quang create a

(ns starter.buffer-fix
  (:require ["buffer" :as b]))

(js/goog.exportSymbol "Buffer" b)
and then require this in starter.browser BEFORE aws-amplify

thheller16:04:29

that should fix it

quang21:04:15

Thanks @thheller had to use a :refer instead, but fixed worked like a charm! 🙂

quang16:04:48

Thanks @thheller!! I had serious contemplation of going back to JavaScript last night... even hired a VA to research javascript-alternatives for me... hah

quang16:04:57

life saver, thanks man!

thheller16:04:45

no idea what rn-nodeify is though. can't say if that would fix anything.

👍 4
quang16:04:43

nice, have to head out atm, but will try it out once I get back. Thanks thheller!

bauerpauer19:04:09

Hi there - is there any way to specify different configurations when running shadow-cljs release? I’m using (goog-define api-host ") along w/ :closure-defines in my shadow-cljs.edn to switch config for dev/release, but I feel like I need one more option.

bauerpauer19:04:22

But maybe I’m missing something. I could certainly just make a new build altogether.

thheller19:04:41

:release {:closure-defines ...}

bauerpauer19:04:42

Yep - I’ve got that goin already @thheller

thheller19:04:17

what else do you have in mind?

bauerpauer19:04:07

What I’m up against is wanting to essentially do something like shadow-cljs release API_HOST= and shadow-cljs release API_HOST=

bauerpauer19:04:15

when I run shadow-cljs dev, my (goog-define api-host "") works great.

thheller19:04:15

one option is to use the :closure-defines {foo #shadow/env "API_HOST"} in your config

thheller19:04:35

but this has various problems because the env of the server is used when a server is running

thheller19:04:29

apart from that you can use clj-run to call (shadow.cljs.devtools.api/release* build-config-map)

thheller19:04:41

(shadow.cljs.devtools.api/get-build-config :your-build) loads your build config from shadow-cljs.edn

thheller19:04:53

its just a map so you can modify it before calling release*

thheller19:04:00

(defn release [api-host] ...) could be called with shadow-cljs clj-run your.build/release

bauerpauer19:04:18

Ya, clj-run might be perfect. Thanks, I’ll give it a shot!

bauerpauer19:04:22

Skipping around the manual has bitten me again 😉 One of these days I’ll read it straight through I swear!

thheller21:04:35

@jmckitrick no. it has been online a while. @jiyinyiyong made it.

jmckitrick21:04:11

@thheller I must have forgotten about it. Either way, it’s beautiful!

😉 4
cjmurphy22:04:44

Figwheel comes with its own web server for serving up your html/css/cljs using the information it gets from lein presumably. Does shadow-cljs? I assume not. If I'm right, can anyone recommend a server that does exactly what Figwheel does, except doesn't do its primary job of live code reloading? A web server that can be used with shadow-cljs when you don't really need one of your own.

cjmurphy04:04:55

From the intro: "The built-in development server aggressively fixes browser caching issues"

justinlee04:04:07

Oh sorry I didn’t read your question properly.

justinlee04:04:17

Or actually now that I’m reading it I don’t get what you are asking. The development server will serve up static assets .

cjmurphy04:04:30

Not asking anything. Just making the point that I probably should have seen that comment right at the beginning of the docs. And excited about the 'aggressively fixing' part. I'll post my 'typical Lein/Figwheel' config once I've got it all working.