This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-27
Channels
- # announcements (10)
- # aws (5)
- # babashka (91)
- # beginners (15)
- # biff (3)
- # calva (5)
- # clerk (24)
- # cljdoc (63)
- # clojure (69)
- # clojure-denver (1)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (50)
- # clojure-uk (2)
- # clojurescript (2)
- # community-development (6)
- # cursive (3)
- # datomic (4)
- # events (2)
- # fulcro (8)
- # gratitude (1)
- # hyperfiddle (19)
- # jobs-discuss (36)
- # nbb (21)
- # pathom (16)
- # portal (6)
- # re-frame (14)
- # reagent (1)
- # reitit (1)
- # releases (3)
- # remote-jobs (2)
- # shadow-cljs (56)
- # sql (15)
I'm trying to call local javascript code from file f.js on nbb project. I tried (:require ["./f" :refer [someFunction]]
and was expecting it to load from the nbb project root dir, where nbb.edn is located, but since there is a "src" folder configuration in nbb.edn it's loading the root from there. It's a little different from nodejs loading mechanism. (I've tested with : nbb (global) and pnpx nbb (local) both are loading from "src")
What is the advised way to javascript code co-exist on a nbb project ?
Embarassing. You're right.
(traverse ast #js {:FunctionDeclaration identity }) is generating the following error:
:message "c.call is not a function", :data {:type :sci/error, :line 29, :column 5, :message "c.call is not a function", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 29, :column 5, :ns #object[Ur js-cljs.astutils-test],
It's a babel function https://babeljs.io/docs/babel-traverse that is imported as ["@babel/traverse" :as traverse]
It expects an object with methods. I've stripped the code and passed identity just for testing.
I did (js/console.log traverse) and it is a function. The code is executed with nbb --debug -cp test -m nextjournal.test-runner
"@babel/traverse$default" same result
["@babel/traverse" :refer [default]]
invoking (default)
instead of traverse gives same message c.call is not a function
Interesting,
Now the import is as ["@babel/traverse$default" :as traverse] and I actually hit the function by doing ((j/get traverse :default ) )
So two defaults one from require one from calling
user=> (require '["@babel/traverse" :as t])
nil
user=> t/
t/Hub t/NodePath t/Scope t/__esModule t/default t/visitors
It's working
https://gist.github.com/geraldodev/001b3dc5f8888cd9e8847d45d185c1fd it's from a test
safetyfull defaults
Joking, two defaults