Fork me on GitHub

how do I run clojurescript tests with clj? I have tests set up but dont understand how to run them

Steve Pegoraro04:09:29

Hi all, what is the preferred way of working with CLJS and node.js? I’m currently using shadow-cljs and CIDER, I select shadow and node-repl when prompted which gives me a working REPL. However I encounter this issue: • I create some namespace that has an error in it (e.g. I forgot to require a var from another namespace) • Then I try to require it from the REPL • It correctly notifies me of my mistake: WARNING - :undeclared-var • I then go and fix the error and save the source file • I try to require it again but the warning appears again • This happens no matter what I do to the original source file until I restart the REPL

Steve Pegoraro04:09:26

Is there some caching happening that I’m not aware of maybe?


looks like a bug. feel free to open an issue, can't investigate more right now


Hi, is there a way speed up cljs compilation on ci by reusing some caches from prev compilation? if so - which folders i need to reuse?


or to be more precise - what is path for the :aot-cache ?


Can't say for the vanilla compiler, but shadow-cljs uses .shadow-cljs dir within the project. Regarding :aot-cache - this function from cljs.analyzer seems relevant:

(defn ^File cache-base-path
      (cache-base-path path nil))
     ([path opts]
      (io/file (System/getProperty "user.home")
        ".cljs" ".aot_cache" (util/clojurescript-version)
        (build-affecting-options-sha path opts))))


thank you so much! so ~/.cljs/aot_cache , roger regarding the .shadow-cljs - is it safe to reuse/share it?


No clue. I'm trying to reuse it across Heroku dyno builds and I think it works.


Also, not ~/.cljs/aot_cache but ~/.cljs/.aot_cache - notice the extra dot.


thanks too bad it is in the home dir, gitlab ci doesnt like it


You should be able to override the user.home property. But it might affect other things.


Although if your CI doesn't like ~ in general, then it's probably fine to override that property.


I’ll try first to cache .shadow-cljs


caching .shadow-cljs removed about 1 minute for me thank you!

👍 2

I have the following inside let […]:

          (.. contract
              (deploy (clj->js 
                         {:arguments [ipfs 
                                      (:percentage db) 
                                      (:min-to-raise db)
                                      (:bid-start db) 
                                      (:bid-end db) 
                                      (:payments-start db)
                                      (:payments-end db)
                                      (:payments-interval db)]
                          :data (.-bytecode (js/JSON.parse resp))})))
(.. contract-deploy
              (send (clj->js {:from ego}) 
                    (fn [err tx-hash] 
                      (prn "err is " err
                           "tx hash is " tx-hash))))
coverted from the following js from web3 docs:
    data: '0x12345...',
    arguments: [123, 'My String']
    from: '0x1234567890123456789012345678901234567891',
    gas: 1500000,
    gasPrice: '30000000000000'
}, function(error, transactionHash){ ... })
but I’m getting this error for the second expression
Uncaught TypeError: Cannot read property 'length' of null
    at require.formatParam (index.js:224)
    at eval (index.js:100)
    at (<anonymous>)
    at require.encodeParameters (index.js:94)
    at eval (index.js:439)
    at (<anonymous>)
    at (index.js:438)
    at (index.js:701)
    at (index.js:720)
    at switch__60994__auto__ (events.cljs:157)


Is your environment browser or Node?


Then just enable breaking on every exception and debug it.


the js land code makes no sense in relation to the cljs world


You mean the existing JS code or the JS code into which your CLJS was compiled?


the js code that’s throwing the exception. It’s the code from the web3js library


called from cljs


Well, that's something you have to learn to deal with then. But something that's passed into encodeParameters is not right. Might be your :data above is wrong.


Hi, how can I call a javascript function with varargs in ClojureScript, like:



I know in Clojure, I can pass last argument as array.


Regular apply should also work, I think.


It's seems regular apply won't work, because (.-foo obj) doesn't have a binding with obj. I just tried js-invoke it works. I'll try this prototype.apply, thanks for your help!


Hi! I’m experimenting with storybook, struggling to get a non-trivial example up and running. If I make a story with basically just reagent in it it works fine. But as soon as I require namespaces that pull in large third party namespaces, storybook takes forever to compile (webpack/babel) and often just crashes with out of memory. Using the approach outlined here Anyone with pointers? First thing that comes to mind for me is that i really don’t need babel to transpile anything, but not sure if that’s what causes this. I have tried several different things to skip files on webpack and babel, no luck so far


@ingesol "large third party" CLJS lib or JS lib?


@thheller CLJS. Like specter.js


Just in case (and sorry if I have mentioned it to you before, I don't recall) - beware of Specter usage in the browser since it increases the bundle size significantly.


Thanks, but I confirmed this isn't specifically about specter

👍 2

in the past there were issues with code becoming too large for webpack. in react-native I worked around it by effectively hiding it so it doesn't get processes at all


the same might be possible for storybook too


Sounds like the sensible solution, yes. I really should learn more about how webpack and babel works. In this case it seems like the value of processing all files with those tools is pretty minimal for a lot of storybook users, but it is included by default anyway.


Or actually I’m not 100% sure. But specter is one that triggers the warning The code generator has deoptimised the styling .


@ingesol that all seems very strange to me - ideally any usage of Storybook would just avoid needing to look at the CloureScript


I think they're writing stories & components in CLJS


it still shouldn't matter in dev? I don't think any CLJS should get processed by Webpack


if the storybook site is built via webpack at dev time, it needs to load the compiled JS of your stories and components right?


well the API of the whole thing is dynamic, I don't see how Webpack has anything to do w/ it


(I could be missing some other details but it seems to me this should work w/o processing CLJS)


Curious if this is a known issue but escaping forward slash on literal regex appears to be giving me an exception (I'm assuming the compiled JS code is invalid)?

#object[SyntaxError SyntaxError: Unexpected token ';']
Is there a way to get the generated JS code without evaling it in CLJS? (I'm on version "1.10.866" ).


Unrelated but is there a way to get what would be outputted JS code from a CLJS expression in REPL? I would in essence want the JS code as a string (or some other form that hasn't been eval'd).


Not sure about REPL but you can use for that.

👍 2