Fork me on GitHub
#shadow-cljs
<
2018-10-16
>
wilkerlucio02:10:56

@thheller after I bumped I'm getting a ton of these:

wilkerlucio02:10:58

[:failed-to-compare "^2.2.5" "2.2.6" #error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 20]}]
 :trace
 [[shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 20]
  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 11]
  [shadow.cljs.devtools.server.npm_deps$fn__18305$fn__18306 invoke "npm_deps.clj" 27]
  [clojure.lang.Delay deref "Delay.java" 42]
  [clojure.core$deref invokeStatic "core.clj" 2312]
  [clojure.core$deref invoke "core.clj" 2298]
  [shadow.cljs.devtools.server.npm_deps$fn__18305$fn__18308 invoke "npm_deps.clj" 33]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 163]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 157]
  [shadow.cljs.devtools.server.npm_deps$main$fn__18389 invoke "npm_deps.clj" 179]
  [clojure.core$complement$fn__5391 invoke "core.clj" 1433]
  [clojure.core$filter$fn__5614 invoke "core.clj" 2813]
  [clojure.lang.LazySeq sval "LazySeq.java" 40]
  [clojure.lang.LazySeq seq "LazySeq.java" 49]
  [clojure.lang.RT seq "RT.java" 528]
  [clojure.core$seq__5124 invokeStatic "core.clj" 137]
  [clojure.core$seq__5124 invoke "core.clj" 137]
  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 181]
  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 172]
  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 162]
  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 153]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]

wilkerlucio02:10:10

the compilation still works, but that's making the console unusable

thheller07:10:53

@wilkerlucio hmm odd. should be fixed in 2.6.12

Hukka07:10:03

I've been reading https://github.com/thheller/shadow-cljs/issues/238 but cannot figure out a way to require the go macro from cljs.core.async

Hukka07:10:06

I get

File: jar:file:/home/hukka/.m2/repository/thheller/shadow-cljs/2.4.21/shadow-cljs-2.4.21.jar!/shadow/cljs/devtools/client/hud.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.cljs.devtools.client.hud
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.core.async/go does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [shadow.dom :as dom]
   4 |     [shadow.xhr :as xhr]
   5 |     [shadow.animate :as anim]
--------------------------------------------------------------------------------
no matter what kind of requires I use in my code

thheller07:10:40

@tomi.hukkalainen_slac you have an old incompatible core.async version in your classpath

Hukka07:10:19

Hum, ok. No wonder I'm hitting walls

thheller07:10:06

make sure its 0.4.474

Hukka07:10:55

cljs-http requires 0.3.442 😞 Let's see if it works with overrides

Hukka07:10:34

Huh. The maintainer has made a release on the same day, before he updated the deps

thheller07:10:10

yeah that dep should really be bumped

Hukka09:10:06

I hadn't realized that <!! is not available on cljs, so I couldn't do the quick hack I needed anyway 😞 But thanks again for the lightning fast help. I wouldn't have guessed the problem from that error and my googling wasn't good enough

thheller09:10:04

yes blocking IO is not possible in CLJS (or rather the underlying JS)

wilkerlucio11:10:18

@thheller fix confirmed, thanks!

grav12:10:43

If I 1. start MY_ENV=foo shadow-cljs server, 2. connect via nrepl and compile a node-script build, 3. start the script with MY_ENV=bar node out/my-script.js, 4. connect a node-repl, then (.-MY_ENV js/process.env) has the value foo. How come? I’d expect bar.

thheller12:10:53

are you connecting to node-repl or the REPL for your build?

thheller12:10:09

node-repl is its own node process started by shadow-cljs

romdoq13:10:04

I have an :npm-module project that's being yarn installed from a git repo by a website, and so runs shadow-cljs release npm in the package.json postinstall hook. Unfortunately the module uses Reagent, which needs (but doesn't explicitly depend on) other packages, so shadow-cljs apparently doesn't have some namespaces (for example, create-react-class) available at this point. The dependencies are installed by yarn, but in the main website's node_modules, which I guess isn't accessible to each individual package's postinstall command. Are there any good/recommended ways of making such packages available when the project is installed as a dependency?

romdoq13:10:58

I'm currently looking at ways to just distribute the transpiled javascript instead, but I might just be missing something, so advice is welcome.

p-himik13:10:32

Hi. Is there a way to get the access to the data from shadow-cljs.edn in my cljs files?

thheller15:10:29

@mel.collins never use shadow-cljs in a postinstall hook, thats just way too slow. instead you do the release and just publish the compiled files instead

thheller15:10:03

@p-himik only in the form of :closure-defines. what else would you want access to?

p-himik15:10:31

@thheller E.g. TinyMCE has an option to explicitly provide it with the paths to themes and skins that it downloads when it's used for the first time.

p-himik15:10:47

So, I think :asset-path is required in this case.

thheller15:10:01

not sure what you'd want to do with that? it only contains the files generated by the compiler

p-himik15:10:04

Maybe my logic is a bit convoluted, yeah. Right now, I use a build hook to copy all relevant files from node_modules to :asset-path, and then use the copied files either as arguments to TinyMCE or somewhere in index.html (e.g. CSS files).

thheller15:10:08

(meaning that the themes and skins won't be on that directory)

thheller15:10:01

ah so they are there

thheller15:10:01

so :asset-path is available as js/CLOSURE_BASE_PATH

thheller15:10:21

but its a development only thing so do not use that

thheller15:10:37

its probably best to goog-define it

thheller15:10:05

OR just discover it dynamically by looking for the script tag in the DOM and taking its src attribute

p-himik15:10:35

Wow that's convoluted.

p-himik15:10:44

Would it make sense to add an access to shadow-cljs.edn via some marco that just inlines all requested values?

thheller15:10:24

hmm no I don't think so

thheller15:10:02

but I still don't understand what exactly it is you are trying to do

thheller15:10:33

you already copied the files yourself. assume for a second that you copied them somewhere NOT in :asset-path

thheller15:10:40

how would you pass it then?

p-himik16:10:06

I would have to write this other path in: 1. Some cljs files that use them (currently an issue with :asset-path as well) 2. In index.html (not an issue with :asset-path since the server can just read the EDN and inline all values in the HTML template) 3. In nginx.conf (not an issue since this file is being generated from different files, including the EDN) Of course, for (1) I could use the same thing as in (2) or (3), but it would become much more convoluted than it is now, and also it would probably lose some integration with IDE since I would have to use some kind of templating. Another solution would be to read the EDN with some Lein plugin (I also use project.clj). I think something like that can be achieved since there's already lein-environ plugin that does something similar.

thheller16:10:54

so I do have plans for adding support for some static asset paths

thheller16:10:21

say in webpack you can require("./some-path/some.png") and it'll return the path to that file

thheller16:10:34

it sounds like that is what you need

thheller16:10:26

so (def some-tiny-mce-asset (assets/path-for "tiny-mce/theme/foo.css"))?

thheller16:10:52

or is it just a bunch of files with a specific naming convention where the entire folder needs to be copied?

thheller16:10:35

the compiler would only copy the path you actually asked for but could maybe support wildcards

thheller16:10:06

the problem with having a macro access the config is cache invalidation since the code must be recompiled if the values change

thheller16:10:18

and that already is complicated enough. I don't want to add to it

p-himik16:10:03

It's both. CSS are used in just the way you described, with require. That is, in JS. In CLJS, I just include the relevant CSS files in index.html and copy them from node_modules/something to :asset-path. And some things, like TinyMCE require a user to supply a bunch of files with a specific naming convention. So in this case, I just copy the whole folder from node_modules/tinymce to :asset-path and then pass the configured path (mapped in nginx.conf) to tinymce.init. > the problem with having a macro access the config is cache invalidation since the code must be recompiled if the values change Ahhh, that's right. I remember having this issue with lein-environ. Thanks for making me aware of that. Would the option with goog-define that you've suggested solve it? If so, could you please describe it a bit more? I have no clue on how one would link it with shadow-cljs.edn.

thheller16:10:49

you don't "link" it. you create (ns your.config) (goog-define asset-path "/foo") and in the config :closure-defines {your.config/asset-path "/bar"}

thheller16:10:49

a helper function might help too (defn path-for [asset] (str asset-path asset))

thheller16:10:08

so you use (config/path-for "/some.css") in your code

p-himik16:10:26

Ah, so I will have to repeat the value of :asset-path - in :asset-path itself and in :closure-defines?

thheller16:10:48

technically :asset-path itself has no meaning in release builds

thheller16:10:31

since you decide what the asset path is when you include the <script src="/something/foo.js">

thheller16:10:06

development builds just need to know the path since they dynamically load more code later (eg. hot-reload)

thheller16:10:16

but yeah you would add it twice

p-himik16:10:03

I see. Thanks!

kanwei20:10:25

@thheller upgraded to 2.6.12 and randomly got an exception and now seems stuck/hanging: https://gist.github.com/kanwei/fee660eb1cdeb22934402cd5ee8ef2ed

thheller20:10:02

given that it is in a boot function I have no idea whats happening

tony.kay23:10:11

The HUD seems to regularly malfunction on me when I’m working with errors like this:

#error {:message 
"Invalid symbol: cloj … lang.ExceptionInfo:."
, :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:151
(anonymous)	@	browser.cljs:343

tony.kay23:10:33

I’ve been seeing this for some time. sometimes HUD works, but often it just spins and I have to look in the console to understand the error

tony.kay23:10:45

Seems like the serialization n line 104 of impl.clj is sending an exception over the websocket, and cljs reader can’t decode it because it is a clojure type

tony.kay23:10:05

not sure why it works sometimes, and sometimes not