This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-17
Channels
- # announcements (3)
- # babashka (3)
- # beginners (53)
- # biff (2)
- # calva (16)
- # cider (1)
- # clj-commons (1)
- # clj-kondo (97)
- # clj-on-windows (137)
- # clojure (49)
- # clojure-europe (63)
- # clojure-gamedev (1)
- # clojure-nl (2)
- # clojure-norway (50)
- # clojure-uk (4)
- # clojurescript (36)
- # core-async (28)
- # datomic (32)
- # emacs (22)
- # events (1)
- # graalvm (8)
- # honeysql (6)
- # jobs (2)
- # lambdaisland (5)
- # malli (6)
- # nbb (31)
- # off-topic (171)
- # pathom (14)
- # rdf (2)
- # reitit (4)
- # releases (2)
- # scittle (19)
- # shadow-cljs (46)
- # sql (6)
- # squint (6)
noobish question: What's the right way to require another cljs file / script into an nbb script? Do i need to load-file
and also add it to the ns definition require form? Want to have some util functions defined in a separate (adjacent) file and pull them in. For some reason this is working locally but doesn't when running in a node docker image in CI
@larzeitlin Just require
or via :require
in the ns form
Node docker image in CI: What does the directory look like of the project and are you executing it from the local directory of that project?
so I'm calling yarn nbb from the root of the project specifying the cwd in the yarn command eg: yarn --cwd test/e2e nbb run_tests.cljs
. Doing this both locally and in CI
If I do this locally it works fine but only if I (load-file ...)
as well as require
In CI i get could not find namespace ...
regardless
all nbb script files are in test/e2e/
along with a package.json
even locally running from e2e directory I get could not find namespace
you can get the error by running yarn install
and then yarn nbb run_tests.cljs
thanks for having a look 🙏
oh yeah, sorry - i just pulled it out of the project. Can rename the root directory e2e and it should match up
What I mean is that when you are in directory $cwd
and your namespace is called e2e.foobar
, then the source should look like this: $cwd/e2e/foobar.cljs
, not $cwd/foobar.cljs
But you can probably "fix" this by adding the parent directory to the classpath with nbb --classpath ..
So it's better to do this:
(ns e2e.run-tests
(:require [nbb.core :refer [load-file await]]))
(require '[login-test])
(require '[map-test])
;; or:
(await (load-file "login_test.cljs"))
(await (load-file "map_test.cljs"))
Maybe nbb could support (:require ["./foo.cljs"])
as well ;) But that would be similar to load-file
makes sense. Just checking that the ns renames (and not running load-file in parallel) fixes things
all fixed! Many thanks @U04V15CAJ 🙏 will file an issue for load-file
auto-await