This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-23
Channels
- # announcements (10)
- # babashka (7)
- # beginners (31)
- # boot (4)
- # calva (8)
- # chlorine-clover (19)
- # cider (12)
- # clj-kondo (27)
- # cljsrn (7)
- # clojure (68)
- # clojure-colombia (2)
- # clojure-europe (47)
- # clojure-italy (16)
- # clojure-nl (4)
- # clojure-spec (13)
- # clojure-uk (39)
- # clojurescript (103)
- # code-reviews (8)
- # community-development (2)
- # conjure (38)
- # core-async (37)
- # cursive (2)
- # datascript (1)
- # datomic (31)
- # figwheel-main (22)
- # fulcro (18)
- # jobs (2)
- # jobs-discuss (6)
- # juxt (3)
- # keechma (1)
- # lambdaisland (6)
- # malli (30)
- # meander (20)
- # off-topic (29)
- # reagent (1)
- # reitit (16)
- # shadow-cljs (4)
- # tools-deps (70)
- # xtdb (19)
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.
It is for loading development time side effects. You wouldn't advanced compile a dev build
actual code uses https://github.com/borkdude/dynaload to load it, if it exists.
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?How to deeply access object using goog.object?
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: https://github.com/cljsjs/packages/pulls
@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
Hello. Was wondering if we have some native app development using CLJS, any help on that ?
I don't know if it is native enough, but expo has a cljs template for react native https://expo.io/ 🙈
@kartikeypokhriyal You may want to check out #cljsrn
@thheller if you have a pointer to a small example dependency project or something that does this, I will absolutely do that
I think the claim from https://clojurescript.org/guides/webpack is that... if I use a deps.edn
file, I can then just use... any npm dependency, and import it using :require
?
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
or maybe I am super old school, and need to migrate https://github.com/littleredcomputer/sicmutils to deps.edn to use any of this
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.
@thheller is this the only trick? :global-exports '{react React}
provides too
@sritchie09 see http://widdindustries.com/cljs-npm-libraries/ for a bit more info on cljsjs authoring. but basically 'yes' to your question
nice, looking now
@henryw374 okay, this is excellent
I do have one question if you have a moment -
take a library like https://github.com/MikeMcl/decimal.js/
(this is probably quite simple) this exposes Decimal
at the top level, ie, js/Decimal
if I change this so I can do [cljsjs.decimal :as d]
, how do I call the constructor?
or does the alias always replace js
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
amazing! so this is the diff
(deps-cljs :name "cljsjs.decimal"
:provides ["decimal", "cljsjs.decimal"]
:requires []
:global-exports '{decimal Decimal})
whoops, editing
one thing I've done here that might not match the best style,
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
yes, nice
this example seems to be slightly different
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
:provides ["highlight.js" "cljsjs.highlight"]
makes sense, and is similar
yes, I'll make that change to each of these, that's great advice
but we have that provides, and then :global-exports '{highlight.js hljs}
oh, wait, nm
I get it
hljs
is the exported object from the library itself, got it
boom, brilliant
@thheller and looks like no :name
entry is required, now
@thheller does the same advice apply, for npm package compatibility, if I'm pulling the source directly from, say, a github release?
or would you recommend NOT doing that, and redoing the PR to download the npm release and repackage it
@henryw374 it doesn't quite work:
(deps-cljs :provides ["decimal.js", "cljsjs.decimal"]
:requires []
:global-exports '{decimal.js Decimal})
with that,
I see
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)')]
though if I do this:
(:require ["decimal.js" :as d])
then (d. 1)
works great
ah! yes
I thought @dnolen might have shipped his change just now 😉
that fails too
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
interesting, I wonder if react is broken too, given
(deps-cljs :provides ["react" "cljsjs.react"]
:requires []
:global-exports '{react React})
broken == noone uses this
nice, since you can always do js/React
and of course js/Decimal
works
excellent, thank you all for the enlightenment!
and for saving these packages
@dnolen that works; I also have to alias it, it seems
(new cljsjs.decimal x)
and (cljsjs.decimal. x)
both fail with (:require [cljsjs.decimal])
with Can't find variable: cljsjs
but succeed with (:require [cljsjs.decimal :as d])
and (d. 1)
probably the .
causing problems
@sritchie09 I think so. my recent learn which helps with these problems: https://clojurescript.org/reference/repl-options#repl-verbose
hey, nice
https://github.com/cljsjs/packages/pull/2123/files#diff-9624c5a24789f4c09d412e5e1e1fec1bR37
what a nice win
@sritchie09 hrm that sounds like a bug for sure
thanks again for the help, all. I went ahead and upgraded big.js and bignumber.js to the new style too
along with the other 4 I had pushed