Fork me on GitHub

what is a preferred way to do :preload under :advanced? getting a:

WARNING: :preloads should only be specified with :none optimizations


my guess like this is the way (it works), but the warning is to tell me I should not preload anything.

Toni Dahl07:07:22

It is for loading development time side effects. You wouldn't advanced compile a dev build


In my case, I would like to load sci.core to ensure it gets compiled in.


actual code uses to load it, if it exists.

Toni Dahl07:07:00

Hmm, I think in that case you'll have to require sci.core manually. Dynaload is not familiar to me


Hi folks, trying to upgrade shadow-cljs from 2.8.93 to 2.10.17 when watching the main app module locally I'm getting the following build errors:

Closure compilation failed with 2 errors
--- node_modules/@firebase/util/dist/index.cjs.js:31
@define must be initalized on a static qualified name in global or module scope
--- node_modules/@firebase/util/dist/index.cjs.js:35
@define must be initalized on a static qualified name in global or module scope
Seems like it's a GCP related error for the firebase module. The aforementioned lines in the module's file look like this
     * @define {boolean} Whether this is the client Node.js SDK.
    NODE_CLIENT: false,
     * @define {boolean} Whether this is the Admin Node.js SDK.
    NODE_ADMIN: false,
Any ideas?


@luis644 please open an issue. I don't have time to look into this now.

👍 3
Karol Wójcik10:07:25

How to deeply access object using goog.object?



Sam Ritchie12:07:12

the slog is done! complex.js, fraction.js, decimal.js, and of course odex-js, Colin Smith's library for numerically solving ordinary differential equations in JS, all (almost) available on cljsjs. See the recent 4 PRs:


@sritchie09 you should really set those up using the "new" form of foreign libs that just enables requiring npm-like so that it just works automatically with :target :bundle and shadow-cljs


(:require ["complex.js" :as comp]) (comp/stuff ...) should work. don't make it based on js/Complex.


also it's just around the corner that you can really avoid js/Foo altogether, even if you've loaded code via a script tag and ClojureScript never saw it


js/Foo is on the way out, and I won't miss it 🙂

🎉 12

What will be used instead?

kartikey pokhriyal14:07:52

Hello. Was wondering if we have some native app development using CLJS, any help on that ?

André Oliveira14:07:05

I don't know if it is native enough, but expo has a cljs template for react native 🙈


@kartikeypokhriyal You may want to check out #cljsrn


David is giving us secret glimpses into the future!!!


I never imagined js/ going away ... interesting.


it isn't going away .. you'll just get an alternative 😉

Sam Ritchie15:07:54

@thheller if you have a pointer to a small example dependency project or something that does this, I will absolutely do that

Sam Ritchie15:07:15

I think the claim from is that... if I use a deps.edn file, I can then just use... any npm dependency, and import it using :require?

Sam Ritchie15:07:32

that guide doesn't say anything about how to package a dependency for use in cljs, or even if I have to do that at all anymore

Sam Ritchie15:07:27

or maybe I am super old school, and need to migrate to deps.edn to use any of this

Sam Ritchie15:07:27

I actually DO like this build tooling work, but I cannot, with a solid amount of searching, find anything about how to package up these deps in any way other than cljsjs (which took some figuring out!) @thheller I'd be thrilled for a pointer, and happy to port these over


@sritchie09 just look at the cljsjs/react package. that has that setup. basically you need to configure some :provides and :global-exports or so, not entirely sure what myself.

Sam Ritchie15:07:48

@thheller is this the only trick? :global-exports '{react React}


@sritchie09 see for a bit more info on cljsjs authoring. but basically 'yes' to your question

Sam Ritchie15:07:53

nice, looking now

Sam Ritchie15:07:20

@henryw374 okay, this is excellent

Sam Ritchie15:07:26

I do have one question if you have a moment -

Sam Ritchie15:07:59

(this is probably quite simple) this exposes Decimal at the top level, ie, js/Decimal

Sam Ritchie15:07:24

if I change this so I can do [cljsjs.decimal :as d], how do I call the constructor?

Sam Ritchie15:07:40

or does the alias always replace js

Sam Ritchie15:07:43

and that's the only rule


cheers. yes the global export maps the namespace name to the global js object. so (new cljsjs.decimal) etc should work

Sam Ritchie15:07:25

amazing! so this is the diff

Sam Ritchie15:07:26

(deps-cljs :name "cljsjs.decimal"
              :provides ["decimal", "cljsjs.decimal"]
              :requires []
              :global-exports '{decimal Decimal})

Sam Ritchie15:07:32

whoops, editing

Sam Ritchie15:07:31

one thing I've done here that might not match the best style,

Sam Ritchie15:07:50

1. this totally works, so thank you 2. I'm using "decimal" here, but the npm package is "decimal.js"


although note in the post I recommend having the cljsjs ns name be the same as the npm package name. (in this case decimal.js ? ) so that it'll also work for shadow users

Sam Ritchie15:07:38

this example seems to be slightly different

Sam Ritchie15:07:43

oh, thanks slack


@sritchie09 for this to have any use whatsoever for :target :bundle and shadow-cljs the provided name needs to match the npm package name

Sam Ritchie15:07:56

:provides ["highlight.js" "cljsjs.highlight"] makes sense, and is similar


I think the package name is decimal.js?

Sam Ritchie15:07:08

yes, I'll make that change to each of these, that's great advice

Sam Ritchie15:07:19

but we have that provides, and then :global-exports '{highlight.js hljs}

Sam Ritchie15:07:42

hljs is the exported object from the library itself, got it

Sam Ritchie15:07:46

boom, brilliant

Sam Ritchie15:07:05

@thheller and looks like no :name entry is required, now

Sam Ritchie15:07:53

@thheller does the same advice apply, for npm package compatibility, if I'm pulling the source directly from, say, a github release?

Sam Ritchie15:07:07

or would you recommend NOT doing that, and redoing the PR to download the npm release and repackage it

Sam Ritchie15:07:59

@henryw374 it doesn't quite work:

Sam Ritchie15:07:02

(deps-cljs :provides ["decimal.js", "cljsjs.decimal"]
              :requires []
              :global-exports '{decimal.js Decimal})

Sam Ritchie15:07:10

ERROR in (decimal) (example/core.js:29:25)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: undefined is not a constructor (evaluating 'new cljs.decimal(x)')]

Sam Ritchie15:07:46

though if I do this:

Sam Ritchie15:07:51

(:require ["decimal.js" :as d])

Sam Ritchie15:07:56

then (d. 1) works great


did you miss a js ? evaluating 'new cljs.decimal(x)

Sam Ritchie15:07:37

I thought @dnolen might have shipped his change just now 😉

Sam Ritchie15:07:43

that fails too

Sam Ritchie15:07:44

ERROR in (decimal) (example/core.js:29:19)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[ReferenceError ReferenceError: Can't find variable: cljsjs]


oh but in your global exports there's just the mapping from decimal.js. not from the cljsjs.decimal ns

Sam Ritchie15:07:04

interesting, I wonder if react is broken too, given

Sam Ritchie15:07:06

(deps-cljs :provides ["react" "cljsjs.react"]
                :requires []
                :global-exports '{react React})

Sam Ritchie15:07:35

broken == noone uses this


I think the cljsjs one is just there for backward compat

Sam Ritchie15:07:54

nice, since you can always do js/React

Sam Ritchie15:07:29

and of course js/Decimal works

Sam Ritchie15:07:40

excellent, thank you all for the enlightenment!

Sam Ritchie15:07:43

and for saving these packages


note for foreign libs the :provides is fake, it's just for idiomatic import


for every virtual provide you will need an entry in :global-exports


if you want to support idiomatic require for that provide

Sam Ritchie15:07:04

@dnolen that works; I also have to alias it, it seems

Sam Ritchie15:07:40

(new cljsjs.decimal x) and (cljsjs.decimal. x) both fail with (:require [cljsjs.decimal])

Sam Ritchie15:07:46

with Can't find variable: cljsjs

Sam Ritchie15:07:03

but succeed with (:require [cljsjs.decimal :as d]) and (d. 1)

Sam Ritchie15:07:01

probably the . causing problems


@sritchie09 I think so. my recent learn which helps with these problems:

Sam Ritchie15:07:28

what a nice win


@sritchie09 hrm that sounds like a bug for sure

Sam Ritchie17:07:02

thanks again for the help, all. I went ahead and upgraded big.js and bignumber.js to the new style too

Sam Ritchie17:07:09

along with the other 4 I had pushed