Fork me on GitHub
#shadow-cljs
<
2019-05-21
>
bbss04:05:41

I'm hitting an error with shadow-cljs release and I'm not sure what is causing it. shadow-cljs watch still works fine.

thheller06:05:02

@bbss since you are using lein I'd suspect a bad closure-compiler version?

bbss06:05:26

okay, sounds reasonable, how can I specify?

thheller06:05:54

first check via lein with-profiles +cljs deps :tree

thheller07:05:40

should be

[com.google.javascript/closure-compiler-unshaded "v20190325"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]

bbss07:05:12

[thheller/shadow-cljs "2.8.36"]
   [com.bhauman/cljs-test-display "0.1.1"]
   [com.cognitect/transit-clj "0.8.313"]
   [com.cognitect/transit-cljs "0.8.256"]
   [com.google.javascript/closure-compiler-unshaded "v20190325"]
   [com.wsscode/pathom "2.2.7" :exclusions [[org.clojure/data.json] [fulcrologic/fulcro] [camel-snake-kebab]]]
     [com.wsscode/spec-inspec "1.0.0-alpha2"]
     [edn-query-language/eql "0.0.3"]

bbss07:05:24

might be here, my shadow-cljs version is older than cli I'm using

thheller07:05:45

that looks like it should

bbss07:05:09

[thheller/shadow-cljs "2.8.36"] -> [org.clojure/google-closure-library "0.0-20190213-2033d5d9"] -> [org.clojure/google-closure-library-third-party "0.0-20190213-2033d5d9"]

thheller07:05:28

what is your :modules config? the exception looks like something isn't quite right with the modules

bbss07:05:43

:main     {:target     :browser
                     :output-dir "resources/public/js/main"
                     :asset-path "/js/main"
                     :build-hooks [(gsv.api.mutations/recalc)]
                     :modules    {:shared {:entries []}
                                  :web-shared {:entries []
                                               :depends-on #{:shared}}
                                  :worker-shared {:entries []
                                                  :depends-on #{:shared}}
                                  :app {:entries [gsv.client]
                                        :depends-on #{:web-shared}}

                                  :fetch-worker {:entries [gsv.fetch-worker]
                                                 :depends-on #{:worker-shared}
                                                 :web-worker true}
                                  :filter-worker {:entries [gsv.filter-worker]
                                                  :depends-on #{:worker-shared}
                                                  :web-worker true}}

thheller07:05:59

hmm that looks ok

thheller07:05:42

the exception looks like the compiler pass responsible for moving keywords

thheller07:05:50

can't find a common module to place a keyword in

thheller07:05:11

but in your case it should be always finding :shared at the very least

bbss07:05:02

hmm, any type of change I did that could have brought this about?

thheller07:05:23

not a clue. the error looks like targetModule is null which shouldn't really happen

thheller07:05:07

/**
   * Finds the deepest common dependency of two modules, including the
   * modules themselves.
   *
   * @param m1 A module in this graph
   * @param m2 A module in this graph
   * @return The deepest common dep of {@code m1} and {@code m2}, or null if
   *     they have no common dependencies
   */
  public JSModule getDeepestCommonDependencyInclusive(

thheller07:05:20

so it should only return null if there is no common module

thheller07:05:26

but it should always be at least shared

thheller07:05:45

try adding an explicit :shared dependeny to all :modules maybe?

thheller07:05:00

maybe something isn't right with transitive deps?

thheller07:05:20

eg. :app {:entries [gsv.client] :depends-on #{:web-shared :shared}}

bbss07:05:01

Trying that.

bbss07:05:05

just adding it to :app wasn't enough but adding that to the other worker modules seems to have done the trick! Thanks @thheller!

thheller07:05:25

hmm strange

thheller07:05:50

would have expected the logic the account for transitive deps but I guess it doesn't

bbss07:05:04

maybe I ran it in the wrong window.. šŸ˜•

bbss07:05:07

give me a moment

bbss07:05:34

no, that does seem to be the case šŸ™‚

Mikko Koski09:05:22

Hi all šŸ‘‹ Is there something I'm missing here? I have my code under src/ and tests under test/ and I added them both to source-paths but yarn shadow-cljs compile test just doesn't find the test namespace under test/. All seems to work fine and the test namespace is found when I move the test namespace under src. Here's my shadow-cljs.edn:

;; shadow-cljs configuration
{:source-paths ["src" "test"]

 :deps true

 :builds
 {:flex-cli {:target :node-script
             :output-to "target/main.js"
             :main sharetribe.flex-cli.core/main}
  :test {:target    :node-test
         :output-to "target/tests.js"
         :autorun   true}}}
And when I run yarn shadow-cljs compile test it doesn't find any tests:
āžœ  flex-cli git:(master) āœ— yarn shadow-cljs compile test
yarn run v1.9.4
warning package.json: No license field
$ /Users/mikko/Documents/Projects/sharetribe/flex-cli/node_modules/.bin/shadow-cljs compile test
shadow-cljs - config: /Users/mikko/Documents/Projects/sharetribe/flex-cli/shadow-cljs.edn  cli version: 2.8.37  node: v10.11.0
shadow-cljs - starting via "clojure"
[:test] Compiling ...
========= Running Tests =======================

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
===============================================
[:test] Build completed. (27 files, 1 compiled, 0 warnings, 1,63s)
āœØ  Done in 10.35s.
The test file under test/sharetribe/flex-cli/hello_world_test.cljs looks like this:
(ns sharetribe.flex-cli.hello-world-test
  (:require [cljs.test :refer-macros [deftest is]]))

(deftest failing
  (is (= "hello" "world")))
So what I'm expecting is that the yarn shadow-cljs compile test would find and run the test which should fail. What I actually see is that the compile doesn't find the test. Any tips what am I doing wrong or how to debug further? Thanks!

Mikko Koski10:05:16

Ahaa! Found it. :deps true was the reason here. Turning it to false fix it and now the test is found.

Mikko Koski10:05:41

And of course then I need to set :paths in deps.edn

Nik08:01:45

I'm having a similar problem that tests are not found when running npx shadow-cljs compile test && node out/node-tests.js shadow-cljs.edn

{:source-paths ["src/main"
                "src/test"]

 :dev-http {8020 "public"
            8021 "out/test"}
 :builds {
          :test {:target :node-test
                 :output-to "out/node-tests.js"}
          :browser-test {:target :browser-test
                         :test-dir "out/test"}}}
I don't have deps.edn adding :deps false didn't help. In visual studio code (with appropriate extensions) clicking on run button beside the test (or namespace) gives same result
; Running tests for the following namespaces:
;   demo.app-test

; No tests found. šŸ˜±, ns: 0, vars: 0

thheller08:01:48

and where are the actual test files? and what are their names?

thheller08:01:36

this doesn't seem to be shadow-cljs running the tests? seems to be vscode/calva?

thheller08:01:02

shadow-cljs doesn't emit any emojis ever, so this No tests found. :scream:, ns: 0, vars: 0 is not from shadow-cljs

thheller08:01:03

can you give an example test? it only finds cljs.test/deftest?

Nik08:01:30

@thheller actual test file copied from shadow-cljs docs src/test/demo/app_test.cljs

(ns demo.app-test
  (:require [cljs.test :refer (deftest is)]))

(deftest a-failing-test
  (is (= 1 2)))
terminal output
āžœ  Arthya git:(cash-only) āœ— pnpm shadow-cljs compile test
shadow-cljs - config: /Users/nik/Repo/Arthya/shadow-cljs.edn
shadow-cljs - connected to server
[:test] Compiling ...
[:test] Build completed. (50 files, 1 compiled, 0 warnings, 0.35s)


āžœ  Arthya git:(cash-only) āœ— node out/node-tests.js       

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
I couldn't figure out the reason so was trying different things (including vscode)

thheller08:01:24

shadow-cljs - connected to server means shadow-cljs is already running elsewhere. is it possible this has been running since before you added src/test to :source-paths, or the tests for that matter?

1
thheller08:01:16

if so restart that

Nik08:01:27

ohh! @thheller I run the shadow-cljs in server mode usually, restarting fixed it

thheller08:01:55

yeah changes to :source-paths or :dependencies requires restarting the server

1
Nik08:01:33

I'm now so used to things in clj world just working that restart didn't make it as debug step šŸ˜…

thheller08:01:35

yeah I still need to figure out how to automate that away šŸ˜‰

1
Mikko Koski10:05:16
replied to a thread:Hi all :wave: Is there something I'm missing here? I have my code under `src/` and tests under `test/` and I added them both to `source-paths` but `yarn shadow-cljs compile test` just doesn't find the test namespace under `test/`. All seems to work fine and the test namespace is found when I move the test namespace under `src`. Here's my `shadow-cljs.edn`: ;; shadow-cljs configuration {:source-paths ["src" "test"] :deps true :builds {:flex-cli {:target :node-script :output-to "target/main.js" :main sharetribe.flex-cli.core/main} :test {:target :node-test :output-to "target/tests.js" :autorun true}}} And when I run `yarn shadow-cljs compile test` it doesn't find any tests: āžœ flex-cli git:(master) āœ— yarn shadow-cljs compile test yarn run v1.9.4 warning package.json: No license field $ /Users/mikko/Documents/Projects/sharetribe/flex-cli/node_modules/.bin/shadow-cljs compile test shadow-cljs - config: /Users/mikko/Documents/Projects/sharetribe/flex-cli/shadow-cljs.edn cli version: 2.8.37 node: v10.11.0 shadow-cljs - starting via "clojure" [:test] Compiling ... ========= Running Tests ======================= Ran 0 tests containing 0 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (27 files, 1 compiled, 0 warnings, 1,63s) āœØ Done in 10.35s. The test file under `test/sharetribe/flex-cli/hello_world_test.cljs` looks like this: (ns sharetribe.flex-cli.hello-world-test (:require [cljs.test :refer-macros [deftest is]])) (deftest failing (is (= "hello" "world"))) So what I'm expecting is that the `yarn shadow-cljs compile test` would find and run the test which should fail. What I actually see is that the compile doesn't find the test. Any tips what am I doing wrong or how to debug further? Thanks!

Ahaa! Found it. :deps true was the reason here. Turning it to false fix it and now the test is found.

thheller11:05:17

if you set :deps true the :source-paths from shadow-cljs.edn do not apply and only use the ones defined in deps.edn

Mikko Koski11:05:27

Yeps, that seems to be the case and makes totally sense now

Nik08:01:45
replied to a thread:Hi all :wave: Is there something I'm missing here? I have my code under `src/` and tests under `test/` and I added them both to `source-paths` but `yarn shadow-cljs compile test` just doesn't find the test namespace under `test/`. All seems to work fine and the test namespace is found when I move the test namespace under `src`. Here's my `shadow-cljs.edn`: ;; shadow-cljs configuration {:source-paths ["src" "test"] :deps true :builds {:flex-cli {:target :node-script :output-to "target/main.js" :main sharetribe.flex-cli.core/main} :test {:target :node-test :output-to "target/tests.js" :autorun true}}} And when I run `yarn shadow-cljs compile test` it doesn't find any tests: āžœ flex-cli git:(master) āœ— yarn shadow-cljs compile test yarn run v1.9.4 warning package.json: No license field $ /Users/mikko/Documents/Projects/sharetribe/flex-cli/node_modules/.bin/shadow-cljs compile test shadow-cljs - config: /Users/mikko/Documents/Projects/sharetribe/flex-cli/shadow-cljs.edn cli version: 2.8.37 node: v10.11.0 shadow-cljs - starting via "clojure" [:test] Compiling ... ========= Running Tests ======================= Ran 0 tests containing 0 assertions. 0 failures, 0 errors. =============================================== [:test] Build completed. (27 files, 1 compiled, 0 warnings, 1,63s) āœØ Done in 10.35s. The test file under `test/sharetribe/flex-cli/hello_world_test.cljs` looks like this: (ns sharetribe.flex-cli.hello-world-test (:require [cljs.test :refer-macros [deftest is]])) (deftest failing (is (= "hello" "world"))) So what I'm expecting is that the `yarn shadow-cljs compile test` would find and run the test which should fail. What I actually see is that the compile doesn't find the test. Any tips what am I doing wrong or how to debug further? Thanks!

I'm having a similar problem that tests are not found when running npx shadow-cljs compile test && node out/node-tests.js shadow-cljs.edn

{:source-paths ["src/main"
                "src/test"]

 :dev-http {8020 "public"
            8021 "out/test"}
 :builds {
          :test {:target :node-test
                 :output-to "out/node-tests.js"}
          :browser-test {:target :browser-test
                         :test-dir "out/test"}}}
I don't have deps.edn adding :deps false didn't help. In visual studio code (with appropriate extensions) clicking on run button beside the test (or namespace) gives same result
; Running tests for the following namespaces:
;   demo.app-test

; No tests found. šŸ˜±, ns: 0, vars: 0