This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-02
Channels
- # announcements (12)
- # asami (5)
- # aws (3)
- # babashka (12)
- # beginners (86)
- # calva (14)
- # chlorine-clover (3)
- # cider (13)
- # clara (8)
- # cljdoc (1)
- # cljfx (2)
- # cljsrn (1)
- # clojure (69)
- # clojure-berlin (6)
- # clojure-czech (14)
- # clojure-dev (17)
- # clojure-europe (76)
- # clojure-france (14)
- # clojure-nl (43)
- # clojure-norway (6)
- # clojure-spec (7)
- # clojure-uk (13)
- # clojurescript (4)
- # code-reviews (1)
- # conjure (16)
- # cursive (2)
- # data-science (3)
- # datascript (1)
- # datomic (41)
- # events (4)
- # fulcro (9)
- # hugsql (3)
- # instaparse (5)
- # jobs (3)
- # malli (1)
- # mid-cities-meetup (1)
- # nrepl (22)
- # off-topic (25)
- # onyx (1)
- # pedestal (3)
- # remote-jobs (3)
- # shadow-cljs (61)
- # sql (22)
- # xtdb (12)
Is it possible to include dependency only on nodejs? Something like (:require-node)?
only via https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading
I am a bit confused with the missing runtime error. I have a node-test build that I ran with node, but that doesn't yield a runtime, or at least not one I could yet connect to.
Hello all! I'm working on a little prototype web app built on top of AWS Amplify, and I've hit an interesting problem when applying advanced optimisations.
Amplify generates code for you that defines the attributes of models that can be found in your GraphQL backend. In my case the generated models/index.js
file contains this:
// @ts-check
import { initSchema } from '@aws-amplify/datastore';
import { schema } from './schema';
const { Product, ListedProduct, List } = initSchema(schema);
export {
Product,
ListedProduct,
List
};
The schema file is a JavaScript file with lots of data…
export const schema = {
"models": {
"Product": {
In development I can require these models from Clojurescript with (:require ["../models/index" :as model])
, and things like model/Product
work just fine.
In production, with advanced compilation, the value of model/Product
is undefined
. In fact, all three of the models I'm playing with are undefined.
(js/console.log "Models:" #js {:List model/List
:ListedProduct model/ListedProduct
:Product model/Product})
That logs this in Firefox:
Models:
{…}
List: undefined
ListedProduct: undefined
Product: undefined
<prototype>: Object { … }
grocer.cljs:272:48
I'm fairly sure this is some dead code elimination/var renaming taking place during advance compilation.
I initially expected some property was being renamed, which is why Amplify wouldn't initialise the DataStore
it provides, but given these vars resolve to nothing…
yeah closure will rename this code. you can either create externs or access the names by string
something like https://github.com/applied-science/js-interop j/get-in
or so
So I can't do something like this:
(ns foo
(:require ["../models" :as models]))
(.subscribe DataStore models/Product)
In externs/<build>.txt
I need to add something like this?
# Fix Amplify's models being undefined :)
models/Product
@U05224H0W I love you! That did it. 💥
thanks, I found this, but I am not yet sure how to use it for the purpose I need the repl
that will start a repl, right? then you can develop and require your code as desired
I need to somehow connect it to my editor, right? because "no one actually types in the repl, who would do that" I saw this on twitter. And copy pasting lots of stuff is difficult anyway
i think if you put the nrepl options in the shadow config it will start up with that stuff and you should be able to connect as normal
I usually have to do a ConjureConnect to the nrepl port and then ConjureShadowSelect to select the build/namespace I am connecting to. But this second part doesn't work
If I write ConjureShadowSelect it tells me that the watch for the build is not running. Which is not true, it's running, but it's a node-test build.
So, just to be clear, I don't think either tool is wrong in any way, I just don't know what I don't know that would connect it.
@ashnur I don't have a clue about the conjure parts. shadow-cljs node-repl
will launch it as will (shadow.cljs.devtools.api/node-repl)
(from CLJ)
if ConjureShadowSelect
asks for a build id that would be :node-repl
(but it needs to be started elsewhere first
ok, I started the node repl, and tried to connect to 3334 port which seem to work, but if I try to evaluate the buffer, it just throws errors
right, sorry, I did do that. I selected :node-repl as you said. The evaluation certainly works, I think I have a new problem now, not related to either conjure or shadow. Thanks
I'm using an js-joda
via an npm module and my target is :browser
. Unfortunately the js-joda
code contains calls to the ES2016 feature .includes
function (on Array) instead of indexOf
which fails in IE11. I've tried all sorts of shadow-cljs config combinations wtihout any luck, e.g. :js-options {:babel-preset-config {:targets {:ie 11}}
or :compiler-options {:rewrite-polyfills true}
which I believe only writes polyfills for ES6+ anyway.
Has anybody managed to configure shadow-cljs such that an ES2016 feature is re-written or polyfilled for ES5 compatibility?
https://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_options (for reference)
or just add the polyfill via external lib like https://polyfill.io/v3/
Thanks, both of you. I believe I've tried the correct :output-feature-set
and other config options already, but I'll double check. Just to confirm, I don't need the babel-preset-config
at all?
I will probably fallback to adding the polyfill manually, I was just convinced that shadow-cljs would take care of it and found that idea attractive. Anyway, let me go away and check my config again. Perhaps some of the config options I've got in there are interfering with each other. Thanks
Hmm... no, I can't get it to work. Perhaps the includes
call isn't being detected properly, as you say. For completeness, the offending lines in the third-party code are chained calls, so perhaps that makes it harder to detect https://github.com/js-joda/js-joda/blob/a1a635a7e4e506dfa7a9eedcc932571bdba9c1b2/packages/locale/src/format/cldr/CldrDateTimeTextProvider.js#L226