This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-15
Channels
- # beginners (56)
- # boot (4)
- # cider (22)
- # clara (10)
- # cljs-dev (50)
- # cljsrn (27)
- # clojure (27)
- # clojure-conj (4)
- # clojure-dev (3)
- # clojure-italy (17)
- # clojure-nl (12)
- # clojure-norway (3)
- # clojure-spec (10)
- # clojure-uk (137)
- # clojurescript (132)
- # cursive (4)
- # datascript (2)
- # datomic (109)
- # devcards (2)
- # editors (1)
- # emacs (4)
- # euroclojure (2)
- # events (4)
- # figwheel (1)
- # fulcro (15)
- # jobs (1)
- # jobs-discuss (4)
- # juxt (3)
- # leiningen (2)
- # off-topic (21)
- # onyx (13)
- # other-languages (8)
- # pedestal (6)
- # re-frame (22)
- # reagent (5)
- # reitit (1)
- # ring-swagger (3)
- # shadow-cljs (75)
- # sql (6)
- # tools-deps (2)
- # vim (1)
- # yada (8)
I’m having trouble using javascript libraries from a browser repl with shadow-cljs. The following fails in a browser repl but works in a node repl.
[2:1]~cljs.user=> (require '[moment :as m])
nil
[2:1]~cljs.user=> (m)
ReferenceError: module$node_modules$moment$moment is not defined
anyone know why the two would be different?
@nickmbailey hmm it works for me?
$ shadow-cljs browser-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn cli version: 2.4.4 node: v9.4.0
shadow-cljs - connected to server
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (136 files, 35 compiled, 0 warnings, 6.93s)
[10:1]~cljs.user=> JS runtime connected.
[10:1]~cljs.user=> (require '["moment" :as m])
nil
[10:1]~cljs.user=> m
#object[g]
[10:1]~cljs.user=> (m)
#object[oa Fri Jun 15 2018 08:16:14 GMT+0200]
@nickmbailey figured it out. there is a bug when you using a symbol instead of a string. (require '["moment" :as m])
works but (require '[moment :as m])
doesn't. https://github.com/thheller/shadow-cljs/issues/318 (fixed in 2.4.5
)
I was playing with it, and found a few things that might worth fixing:
1. sorting by name seems broken: https://www.dropbox.com/s/fggshabqdr8jv8j/Screenshot%202018-06-15%2010.00.21.png?dl=0
2. maybe its a mac problem, but see the outline on the header when I click, you can turn that off by css outline: none
I just tried running it, but got an exception:
did cljs got updated or something?
oh, ok, I was going to update that, but I think that would break as well right? 😛
don't anticipate any breaking changes ... unlike Closure which seems to have a few with every release
still getting that error =/ bumped CLJS and Closure, double checked the lein deps
, only the newest closure is there
[org.clojure/clojurescript "1.10.312"]
[com.google.javascript/closure-compiler-unshaded "v20180610"]
same thing, I can't compile with the newest shadow at all anymore
tried, also deleted .shadow-cljs
, but still getting the same problem
I'm going to check again my deps, might be something there
the deps seem right, not sure what else to look for
I was sure I had updated shadow, but seems not, and I was generating my deps list without shadow profile
thanks for hanging with me on this, yeah, the issue was I forgot to update shadow in the project.clj
but coming back to the report, I got this now:
shadow-cljs - config: /Users/wilkerlucio/Development/nubank/shuffle/shadow-cljs.edn cli version: 2.4.5 node: v8.11.2
shadow-cljs - running: lein with-profile +shadow run -m shadow.cljs.devtools.cli --npm run shadow.cljs.build-report app output.html
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
Failed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 3964606])
at [Source: (FileInputStream); line: 1, column: 3969231]
Failed reading cache for shuffle.chat.views.message: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 256687])
at [Source: (FileInputStream); line: 1, column: 257415]
Failed reading cache for cljs.spec.gen.alpha: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 118722])
at [Source: (FileInputStream); line: 1, column: 138937]
Failed reading cache for shuffle.chargeback.commons.purchases-widgets: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 180112])
at [Source: (FileInputStream); line: 1, column: 184263]
Failed reading cache for cljs.stacktrace: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 74864])
at [Source: (FileInputStream); line: 1, column: 126007]
Failed reading cache for shuffle.widgets.chargeback.ready.details: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 56211])
at [Source: (FileInputStream); line: 1, column: 56715]
Failed reading cache for shuffle.chargeback.commons.chargebacks-widgets: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 42573])
at [Source: (FileInputStream); line: 1, column: 45439]
Failed reading cache for fulcro.logging: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 41860])
at [Source: (FileInputStream); line: 1, column: 43739]
I was hoping it ends at some point, but seems like it's just hanging now
my CPU is low, but I'm waiting more, its been a couple minutes already
this is a big app, does it usually takes much longer than release builds?
no should be about the time of a release build (thats what it does in the background)
ha, just finished 🙂
and I can't see the time it took because of warnings and long output 😛
thats fine, I can time it out later, one thing I found strange is that I got a lot of blank entries, and I think it's missing a lot of files from the project
maybe it got the top ones
but it goes like this at some point: https://www.dropbox.com/s/x1du7j9a4ncjlkj/Screenshot%202018-06-15%2010.37.18.png?dl=0
I counted here, 676 blank lines
@thheller awesome! thanks for the quick fix
@wilkerlucio @thheller that happens to me when i use https://date-fns.org/. Its structure is several smaller sub-folders that can each be separately required, so I assume when shadow tries to find out the library name, it doesn’t actually find anything.
@levitanong thx, there indeed seems to be something funky in there. filenames however seem to work fine, its just missing the package name/version
Yeah, if i open it up the dropdown, it works fine.
so @thheller I don't remember if I can or cannot at the moment have multiple entry points in the same namespace for :azure-app
❓
@thheller any idea how one might use rebel readline with the shadow-cljs clojurescript repl?
@richiardiandrea you can. currently no code splitting is performed
@colindresj I didn't have time to look into that yet. might not be easy at the moment
Yeah I spent a little bit of time on it and it felt not straightforward. Wanted to check if I was missing something. Not a big deal
Does shadow have a method for importing CSS files, similar to how JS does it? i.e. import "../node_modules/[NAME_OF_YOUR_LIBRARY]/lib/styles.css";
@lee.justin.m ah of course. I ended up writing a tiny little build hook that is working well enough
(defn copy-files
{:shadow.build/stage :flush}
[build-state & {:keys [dest files]}]
(doseq [f files]
(let [input (io/file f)
input-name (.getName input)
output (io/file dest input-name)]
(io/make-parents dest input-name)
(println (format "Copying %s to %s" input output))
(io/copy input output)))
build-state)
This let's me copy the CSS into my public folder where I can then load it on the page
yea that works. i just use standard unix tools with npm scripts. imo you don’t need such tight integration with a monolithic build tool unless you’ve got a really big and complicated project. there’s something nice to just have simple scripts.
For sure. I like the idea of someone being able to look at shadow-cljs.edn and seeing "ah, this is pulling some CSS files out of a node module".
yea i get the appeal for sure. i’m often of of two minds on the issue: some times the pendulum is on dead simple unix solutions and sometimes i like the One File To Rule Them All approach
Yep, which is getting easier and easier thanks to projects like tools.deps and friends. I'm loving being able to pop off pretty sophisticated build solutions right inside Clojure. Really exciting direction.
All of my repl and build scripts leverage simple unix scripts relying on clj
. I'm liking it a lot.