clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
p-himik 2021-03-27T06:58:34.303Z

Depends on what you mean by "access". It's possible to mention them so that the generated CLJS code ends up using them.

quadron 2021-03-27T08:45:24.303700Z

how do i do the following in clojurescript:

import {
  InitialStates,
  SECPTransferOutput
} from "avalanche/dist/apis/avm"

quadron 2021-03-27T08:45:26.303900Z

i'm using shadow-cljs

quadron 2021-03-27T08:45:59.304400Z

the aforementioned folder exists in the node_modules folder

quadron 2021-03-27T08:46:21.304700Z

it is a js package

quadron 2021-03-27T08:48:53.305300Z

the following works:

(js/require "avalanche/dist/apis/avm")
but is it the idiomatic way of working with npm modules?

quadron 2021-03-27T08:53:16.306300Z

what happens if i don't alias like following?

(require '["avalanche/dist/apis/avm" :as foo]) 

quadron 2021-03-27T08:54:24.306700Z

the following doesn't work for instance:

avalanche.dist.apis.avm/SECPTransferOutput

quadron 2021-03-27T08:54:41.307300Z

i assume i should always either refer or alias then?

thheller 2021-03-27T08:55:16.308100Z

because thats not the namespace that is generated for the string. not all strings can be translated to proper namespaces like that since the npm world does not follow the CLJ naming conventions

✔️ 1
thheller 2021-03-27T08:55:48.308300Z

so yeah, you need the alias

quadron 2021-03-27T08:55:51.308500Z

i suspected so

quadron 2021-03-27T08:55:52.308800Z

thx