This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-03
Channels
- # adventofcode (91)
- # announcements (7)
- # aws (3)
- # babashka (69)
- # beginners (46)
- # calva (30)
- # cider (12)
- # clj-kondo (88)
- # cljs-dev (11)
- # cljsrn (1)
- # clojure (195)
- # clojure-dev (21)
- # clojure-europe (2)
- # clojure-italy (13)
- # clojure-nl (56)
- # clojure-spec (4)
- # clojure-sweden (6)
- # clojure-uk (27)
- # clojurescript (179)
- # core-async (2)
- # cryogen (1)
- # cursive (2)
- # data-science (1)
- # datomic (57)
- # fulcro (15)
- # graalvm (9)
- # instaparse (6)
- # joker (18)
- # juxt (9)
- # leiningen (6)
- # off-topic (20)
- # other-languages (10)
- # pathom (5)
- # re-frame (20)
- # reitit (2)
- # rewrite-clj (5)
- # shadow-cljs (78)
- # sql (34)
- # tools-deps (128)
- # uncomplicate (16)
- # vim (6)
Hi all, I’m trying out shadow for some CLJS projects I have, it looks great so far. I have one question: I’m building code to deploy to AWS Lambda. I’m using :optimizations :simple
, and I’d expected that to produce a single JS file. But it’s producing my :output-to
file in a way that references a ton of other files under .shadow-cljs/builds
- is that normal? Can I make it produce a single file without going to advanced optimisations?
Actually @U0510KXTU gave me the solution here, use release instead of compile.
@thheller I was testing with 2.8.76
, but 2.8.77
also has the same behaviour - defines are not being overridden, and devtools are not active (I'd guess because the define/s to enable the devtools aren't being overridden).
I know you don't really deal with Java, and still you need to configure it on every machine that you'd like to build your code..
the answer is no. shadow-cljs is written in Clojure and uses the Google Closure Compiler (written in Java). The Java requirement will stay.
it does. but it is like 10x slower and also not extensible in the way the java version is
not sure where "there" is but lumo
is an entirely different project with entirely different goals. dunno if it even supports "builds" nowadays, the focus was always scripting AFAICT
Oof okay, apparently I was wrong about devtools working in 2.8.68
. In that version the websocket connects, but the browser doesn't appear to notice updates when shadow recompiles changed files. It appears that that stopped working for me in 2.8.56
. 😕
@mel.collins I'm working on that currently. I only verified in release builds and that did work fine
why do you use :npm-module
? I'm likely going to remove it given that it causes the most issues out of any builds
@thheller that seems to fix the defines, and the websocket is back! However, the hot reloading that stopped working in 2.8.56 is still broken. I thought it might be how I used my react components, but I don't get console logs about subscriptions being replaced (by re-frame) either.
maybe I can try setting one up later ... don't have any ideas about what might be happening right now
I don't have a simple example, no. 😞 The only project I have is our main app, which is huge!
I'm new to Clojure(script) and I'm trying to get some clarity on how to run tests. I'm building a Fulcro application and I want the tests to be integrated with my editor, so I can run them from Vim and get the results right there.
I have:
• :deps {:aliases [:dev]}
in shadow-cljs.edn
• :paths ["src/app" "src/test"]
in the top level of deps.edn
• src/test/sheluchin/poker/core_test.cljs
with these contents:
(ns sheluchin.poker.core-test
(:require
[cljs.test :refer-macros [deftest is testing run-tests]]))
(deftest test-numbers
(is (= 1 1)))
(run-tests)
It's unclear to me which option I should be using for running the tests: node.js, browser, or karma. Is it absolutely necessary to define a build target specifically for testing, or can I forego that for the time being? What command should I be using to run the tests? If I just eval the (run-tests)
form, it doesn't seem to pick up on updates to that file, so if I change the test to (is (= 2 1))
, save the file, and re-eval the (run-tests)
form, all the test still shows as passing.I can work with 2.8.55 for the time being, so no rush. @thheller Let me know if you need more info or testing from my side. Thanks for your work
@alex.sheluchin hot-reload in general only picks up changes from files used in the actual build (so no tests). you can use the :browser-test
target for tests
or I guess you could add the tests via :devtools {:preloads [your.foo.core-test]}
in the regular build. that would make them hot-reload as well
Ah, so even if I explicitly (require 'sheluchin.poker.core-test)
after updating the file, it doesn't get picked up unless I shadow-cljs restart
?
to reload you'd do (require 'sheluchin.poker.core-test :reload)
otherwise it'll not load anything if its already loaded
Fair enough, I won't go against the grain on that; I'll just set up the separate build target for testing.
With a :browser-test
build target, what's the usual way to run the tests? I'm guessing it's like everything else and has CLI and REPL equivalents?
Yep, it's a Fulcro webapp, but I want the results in my shell so I don't have to look at the browser. I understand that I need to have the builds active and need to have dev tools open to interact with the environment, but once that's done, I can receive the results in the shell as well as them being printed in the console?
Okay, thanks for the advice and info. This should be enough for me to try a few things and see if I can get something to work how I want it. Much appreciated.
if you want to run the tests from the REPL as part of your main build then just try the :preloads
thing I mentioned
I'll provide some feedback after I figure out a setup that works for me. At this point I just want the testing to play nice with vim-fireplace and there's no definitive guide on that just yet. Thanks again.
[1:1]~cljs.user=> (require 'sheluchin.poker.core-test :reload)
Testing sheluchin.poker.core-test
Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
nil
[1:1]~cljs.user=> (load-file "sheluchin/poker/core_test.cljs")
[:result {:type :repl/error, :ex #error {
:cause "file not on classpath"
:data {:file-path "sheluchin/poker/core_test.cljs"}
:via
[{:type clojure.lang.ExceptionInfo
:message "file not on classpath"
:data {:file-path "sheluchin/poker/core_test.cljs"}
:at [shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]}]
:trace
[[shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]
[shadow.cljs.repl$repl_load_file_STAR_ invoke "repl.clj" 227]
[shadow.cljs.repl$repl_load_file invokeStatic "repl.clj" 301]
[shadow.cljs.repl$repl_load_file invoke "repl.clj" 299]
[shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 426]
[shadow.cljs.repl$process_read_result invoke "repl.clj" 406]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invokeStatic "impl.clj" 797]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invoke "impl.clj" 751]
[shadow.cljs.devtools.server.worker.impl$eval15200$fn__15201 invoke "impl.clj" 828]
[clojure.lang.MultiFn invoke "MultiFn.java" 234]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773$fn__14781 invoke "util.clj" 285]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773 invoke "util.clj" 284]
[shadow.cljs.devtools.server.util$server_thread$fn__14772 invoke "util.clj" 257]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 834]]}}]
[1:1]~cljs.user=>
+08:07 $ npx shadow-cljs classpath | tr ':' '\n'
shadow-cljs - config: /home/alex/repos/clojure-stuff/fulcrologic/poker/shadow-cljs.edn cli version: 2.8.64 node: v8.11.1
src/app
src/test
...
+08:08 $ tree src/test/
src/test/
└── sheluchin
└── poker
└── core_test.cljs
I can require the namespace and it works fine, but load-file complains that the file is not in the classpath, although it clearly is.[2:1]~cljs.user=> (load-file "src/test/sheluchin/poker/core_test.cljs")
[:result {:type :repl/error, :ex #error {
:cause "file not on classpath"
:data {:file-path "src/test/sheluchin/poker/core_test.cljs"}
:via
[{:type clojure.lang.ExceptionInfo
:message "file not on classpath"
:data {:file-path "src/test/sheluchin/poker/core_test.cljs"}
:at [shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]}]
:trace
[[shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]
[shadow.cljs.repl$repl_load_file_STAR_ invoke "repl.clj" 227]
[shadow.cljs.repl$repl_load_file invokeStatic "repl.clj" 301]
[shadow.cljs.repl$repl_load_file invoke "repl.clj" 299]
[shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 426]
[shadow.cljs.repl$process_read_result invoke "repl.clj" 406]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invokeStatic "impl.clj" 797]
[shadow.cljs.devtools.server.worker.impl$do_repl_rpc invoke "impl.clj" 751]
[shadow.cljs.devtools.server.worker.impl$eval15200$fn__15201 invoke "impl.clj" 828]
[clojure.lang.MultiFn invoke "MultiFn.java" 234]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773$fn__14781 invoke "util.clj" 285]
[shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773 invoke "util.clj" 284]
[shadow.cljs.devtools.server.util$server_thread$fn__14772 invoke "util.clj" 257]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 834]]}}]
[2:1]~cljs.user=>
Ah, I was thinking about upgrading shadow-cljs but I wasn't too confident if it would continue to be compatible with the Fulcro version I'm on.
the only thing you need to watch out for is dependency conflicts when using deps.edn but generally it should be fine
or just (load-file "/Users/whoever/projects/that-project/src/test/sheluchin/poker/core_test.cljs")
Okay, guess that's homework for tonight or tomorrow. Looking forward to upgrading. Thanks! Off to work now.
Just getting started with shadow-cljs, so please forgive me in case I am missing something.
Migrating to shadow-cljs requires getting rid of all foreign-deps and hence, cljsjs deps, right?
@eliraz.kedmi no it does not