This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-30
Channels
- # beginners (126)
- # boot (2)
- # cider (6)
- # cljs-dev (46)
- # cljsjs (8)
- # clojure (122)
- # clojure-greece (57)
- # clojure-italy (6)
- # clojure-poland (3)
- # clojure-russia (2)
- # clojure-serbia (5)
- # clojure-spec (26)
- # clojure-uk (99)
- # clojurescript (39)
- # cursive (15)
- # datascript (7)
- # datomic (21)
- # dirac (7)
- # duct (1)
- # emacs (19)
- # fulcro (58)
- # garden (4)
- # graphql (15)
- # hoplon (2)
- # immutant (1)
- # instaparse (3)
- # jobs (5)
- # juxt (15)
- # klipse (4)
- # leiningen (2)
- # lumo (52)
- # off-topic (8)
- # om (27)
- # onyx (22)
- # other-languages (3)
- # portkey (2)
- # protorepl (2)
- # re-frame (7)
- # reagent (7)
- # ring (11)
- # rum (7)
- # shadow-cljs (114)
- # spacemacs (20)
- # specter (16)
- # test-check (5)
- # timbre (1)
- # unrepl (43)
- # yada (17)
given that the shadow-cljs
CLI script does this as well I’m quite confident it works. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L3
unless you maybe tried to do it with :target :browser
which won’t work because its a node only package
=>> node target/main.js
SHADOW import error /Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/shadow.module.main.append.js
/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:11154
var self__ = this;
^
RangeError: Maximum call stack size exceeded
at Array.join (native)
at cljs.core.Keyword.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:11154:94)
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:31863:12)
at cljs$core$pr_writer (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9739:6)
at /Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9861:30
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9594:39)
at Object.cljs$core$print_prefix_map [as print_prefix_map] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:32481:18)
at cljs$core$print_map (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9871:8)
at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9680:23)
at cljs$core$pr_writer (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9739:6)
=>> cat src/server/main.cljs
(ns server.main
(:require ["walk-sync" :as walk-sync]
[clojure.string :as string]
["fs" :as fs]
["path" :as path])) ; <---
(defn main! []
(println path) ; <---
(let [base-dir js/process.env.base
paths (filter
(fn [filepath] (string/ends-with? filepath ".tsx"))
(walk-sync base-dir))
*colors (atom [])]
(doseq [filepath paths]
(let [content (fs/readFileSync (str base-dir filepath) "utf8")]
(doseq [line (string/split-lines content)]
(if (string/includes? line "#")
(let [color (re-find (re-pattern "#[0-9a-f]{3,6}") line)]
(if (some? color) (swap! *colors conj color) (println line)))))))
(println (string/join "\n" (sort (set @*colors))))))
(defn reload! [] (main!))
at first I used a local variable called path
and it broke the global path
.. so I tried to print
[zilence@zpro ~]$ node
> require("path")
{ resolve: [Function: resolve],
normalize: [Function: normalize],
isAbsolute: [Function: isAbsolute],
join: [Function: join],
relative: [Function: relative],
_makeLong: [Function: _makeLong],
dirname: [Function: dirname],
basename: [Function: basename],
extname: [Function: extname],
format: [Function: format],
parse: [Function: parse],
sep: '/',
delimiter: ':',
win32:
{ resolve: [Function: resolve],
normalize: [Function: normalize],
isAbsolute: [Function: isAbsolute],
join: [Function: join],
relative: [Function: relative],
_makeLong: [Function: _makeLong],
dirname: [Function: dirname],
basename: [Function: basename],
extname: [Function: extname],
format: [Function: format],
parse: [Function: parse],
sep: '\\',
delimiter: ';',
win32: [Circular],
posix: [Circular] },
posix: [Circular] }
since you really have to go out of your way to create circular structures in clojure thats fine
While developing, we run into this exception a lot when a compile faills:
[:worker-error {:resources [[:shadow.build.classpath/resource "atlas_crm/ui/components/dialog.cljc"]], :shadow.cljs.devtools.server.system-bus/topic :shadow.cljs.devtools.server.system-msg/resource-update} java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__46278__46282$fn__46283$fn__46284$fn__46286]
it should log a proper warning with complete stack. I removed the prn
since thats not useful at all.
Ah ok no it only gives us this in the repl
No logfile in target/shadow-cljs
that might be an issue if you have the slf4j-nop
on the classpath, which means no logging at all.
No I have logback on the classpath
Oh lol
I know what it is thnx
17-11-30 12:21:13 UnknownHost WARN [shadow.cljs.devtools.server.util:286] - failed to handle server msg {:resources [[:shadow.build.classpath/resource atlas_crm/ui/components/dialog.cljc]], :shadow.cljs.devtools.server.system-bus/topic :shadow.cljs.devtools.server.system-msg/resource-update}
java.lang.Thread.run Thread.java: 748
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 617
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1142
java.util.concurrent.FutureTask.run FutureTask.java: 266
...
clojure.core/bound-fn*/fn core.clj: 1995
clojure.core/apply core.clj: 661
...
clojure.core/with-bindings* core.clj: 1965 (repeats 2 times)
clojure.core/apply core.clj: 657
...
shadow.build.compiler/par-compile-cljs-sources/fn/iter/fn/fn/fn compiler.clj: 726
shadow.build.compiler/par-compile-one compiler.clj: 667
shadow.build.compiler/generate-output-for-source compiler.clj: 621
shadow.build.compiler/maybe-compile-cljs compiler.clj: 572
shadow.build.compiler/maybe-compile-cljs/fn compiler.clj: 596
shadow.build.warnings/get-source-excerpt warnings.clj: 55
shadow.build.warnings/get-source-excerpts warnings.clj: 52
clojure.core/into core.clj: 6815
clojure.core/reduce core.clj: 6748
clojure.core.protocols/fn/G protocols.clj: 13
clojure.core.protocols/fn protocols.clj: 75
clojure.core.protocols/seq-reduce protocols.clj: 24
clojure.core/seq core.clj: 137
...
shadow.build.warnings/get-source-excerpts/iter/fn warnings.clj: 41
shadow.build.warnings/get-source-excerpts/iter/fn/fn warnings.clj: 41
java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__46278__46282$fn__46283$fn__46284$fn__46286
It gives us this in the logging, we do log warnings. I seems to fail on initializing some class
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/warnings.clj#L41
It seems to break on a macro.. and also if we import the same thing twice by accident
try [email protected]
. only change is that it now catches Throwable since NoClassDefFoundError is not an exception
I tried that version and this is the result:
Exception in thread "async-dispatch-2"
java.lang.ExceptionInInitializerError
at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:253)
at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:253)
at shadow.cljs.devtools.server.util$print_build_failure.invokeStatic(util.clj:61)
at shadow.cljs.devtools.server.util$print_build_failure.invoke(util.clj:59)
at shadow.cljs.devtools.server.util$print_worker_out.invokeStatic(util.clj:79)
at shadow.cljs.devtools.server.util$print_worker_out.invoke(util.clj:63)
at shadow.cljs.devtools.server.util$stdout_dump$fn__49338$state_machine__7021__auto____49343$fn__49346.invoke(util.clj:119)
at shadow.cljs.devtools.server.util$stdout_dump$fn__49338$state_machine__7021__auto____49343.invoke(util.clj:119)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7039.invoke(ioc_macros.clj:986)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__1082$fn__1083.invoke(channels.clj:95)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace
at clojure.lang.Compiler.currentNS(Compiler.java:7397)
at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1310)
at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:843)
at clojure.lang.LispReader.read(LispReader.java:275)
at clojure.lang.LispReader.read(LispReader.java:206)
at clojure.lang.LispReader.read(LispReader.java:195)
at clojure.lang.RT.readString(RT.java:1871)
at clojure.lang.RT.readString(RT.java:1866)
at shadow.cljs.devtools.errors$user_friendly_error$fn__49243.<clinit>(errors.clj:254)
yes I did
I will try it again, just to be sure
[email protected]
at least fixes the java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace
Yes I do, alright I will try that version out
This is what i get with version 2.0.111
Exception in thread "async-dispatch-8"
java.lang.ExceptionInInitializerError
at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:254)
at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:253)
at shadow.cljs.devtools.server.util$print_build_failure.invokeStatic(util.clj:61)
at shadow.cljs.devtools.server.util$print_build_failure.invoke(util.clj:59)
at shadow.cljs.devtools.server.util$print_worker_out.invokeStatic(util.clj:79)
at shadow.cljs.devtools.server.util$print_worker_out.invoke(util.clj:63)
at shadow.cljs.devtools.server.util$stdout_dump$fn__49342$state_machine__7021__auto____49347$fn__49350.invoke(util.clj:119)
at shadow.cljs.devtools.server.util$stdout_dump$fn__49342$state_machine__7021__auto____49347.invoke(util.clj:119)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7039.invoke(ioc_macros.clj:986)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__1082$fn__1083.invoke(channels.clj:95)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: Can't resolve find-ns
at clojure.lang.Util.runtimeException(Util.java:221)
at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1315)
at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:843)
at clojure.lang.LispReader.read(LispReader.java:275)
at clojure.lang.LispReader.read(LispReader.java:206)
at clojure.lang.LispReader.read(LispReader.java:195)
at clojure.lang.RT.readString(RT.java:1871)
at clojure.lang.RT.readString(RT.java:1866)
at shadow.cljs.devtools.errors$user_friendly_error$fn__49246.<clinit>(errors.clj:254)
but the *ns*
binding seems to be the cause since I changed that and the error changed
try [email protected]
. I removed that binding completely, maybe nrepl just doesn’t like doing that.
On it.
It works now!
Thanks a lot @thheller, works perfectly!
I’m puzzling through an issue: Using shadow-cljs cljs-repl :id
outputs response as I’d expect, but within Emacs/cider, after connecting and running (shadow.cljs.devtools.api/nrepl-select :id-of-build)
, responses come back, but they are always a string.
I’ll play around with it. Didn’t realize you’d already done the same. I’ll let you know if I come up with anything. Thanks!
or rather this https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/pprint.clj#L77-L85
either way .. I guess I’ll need to read-string
the result I get back from the CLJS repl