This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-27
Channels
- # announcements (11)
- # asami (7)
- # babashka (140)
- # beginners (58)
- # calva (12)
- # clj-kondo (5)
- # cljsrn (9)
- # clojure (60)
- # clojure-australia (8)
- # clojure-boston (1)
- # clojure-europe (35)
- # clojure-france (2)
- # clojure-germany (5)
- # clojure-italy (8)
- # clojure-nl (7)
- # clojure-sweden (14)
- # clojure-uk (23)
- # clojurescript (16)
- # community-development (2)
- # cursive (7)
- # datomic (6)
- # docker (1)
- # emacs (4)
- # fulcro (11)
- # graalvm (5)
- # honeysql (6)
- # jobs (6)
- # jobs-discuss (36)
- # lsp (19)
- # malli (7)
- # meander (8)
- # off-topic (18)
- # pathom (16)
- # practicalli (33)
- # re-frame (43)
- # react (2)
- # remote-jobs (11)
- # sci (83)
- # shadow-cljs (55)
- # tools-deps (48)
Where is the best place to set NODE_ENV? Do I just put a line of (set! js/NODE_ENV (if goog.DEBUG "development" "production")
in my entry point? Is there a way to say this in the shadow-cljs.edn?
hi, can we make this work somehow with shadow https://www.npmjs.com/package/babel-plugin-assign-directive ?
idk its outdated, its possible to add directive with a macro , im more interesting in how we can use babel plugin for generated js code with shadow
or probably it could be not a bubel plugin, i mean we need access to js code to be able to change it in runtime
I am not sure I fully understand. If I generate my js code with shadow-cljs, why would I take the output of that and try using another approach to modify it? Why not just modify at the beginning
I know lots of tooling on how to modify js code from js, but that is in js land entirely
we need to get this
user.i_use_worklet*=*function(){var _f*=*function _f(){*return* console.log("Hey I'm running on the UI thread");};_f._closure*=*{console*:*console};_f.asString*=*"function(){const{console}=this._closure;{return console.log(\"Hey I'm running on the UI thread\");}}";global.__reanimatedWorkletInit(_f);*return* _f;}();
from this
user.i_use_worklet*=*function(){"worklet";*return* console.log("Hey I'm running on the UI thread");};
I know I would write something custom with this https://www.npmjs.com/package/falafelhttps://www.npmjs.com/package/falafel 😄
@andre I don't know how this works at all but maybe you want to write the worklet code directly in JS and just use it from CLJS? or do you really need to write those in CLJS?
so my idea is to run re-frame event handlers in a separate thread, so yeah it should be cljs code
it'll also agressively inline functions and so on so the code is never what you wrote after :advanced
also I don't have a clue how worklets actually work but I'd assume it would require a lot of serialization
so running re-frame event handlers seems like an absolute no go for me? too much overhead serializing the app-db back and forth?
https://www.npmjs.com/package/babel-plugin-assign-directive the github repo for this doesn't exist anymore so I think this never actually worked? can't see how this would work with any other CLJS tool either as :advanced
or even :simple
would be the major hurdle here
so the only way I see this working is with actual JS functions just called from CLJS but not passing through CLJS tooling, just metro
a custom worklet-fn special form could be created to create the code you need but yeah its applications are very limited and I don't expect this to ever work for functions using CLJS datastructures anywhere. basic JS types maybe work though.
@borkdude first of all this has nothing to do with shadow-cljs, you'd get those warning for regular CLJS as well if you were to enable them. so the only difference is that shadow-cljs defaults to having them enabled automatically vs. manually. You can either use (set! *warn-on-infer* false)
somewhere above those forms if you know they are safe and can be renamed (which they likely can)
@thheller Adding an extra local type hint solved the warnings. I don't understand why because that type hint was already on the return tag of the function. But thanks. It was reported by a shadow-cljs users, I have never seen this warning before.
yeah if you set that to true you should get the warnings with the regular cljs compiler too
basically shadow-cljs just sets that to true by default for local files (ie. files not in .jar)
I do remember some weird issue with return type hints but not sure. I think in some places it was a little inconsistent and (defn ^Return foo [] ...)
worked but (defn foo ^Return [] ...)
didn't
Hello. I have another question, probably quite stupid again, but I'm banging my head against this for a few hours. I'm trying to adapt this example: https://github.com/reactchartjs/react-chartjs-2/blob/master/example/src/charts/Line.js
(ns my-app.views
(:require ["react-chartjs-2" :refer [Line]]))
(defn chart []
[:> Line
{:data {:labels ["1" "2" "3" "4" "5" "6"]
:datasets [{:label "# of Votes"
:data [12 19 3 5 2 3]
:fill false
:backgroundColor "rgb(255, 99, 132)"
:borderColor "rgba(255, 99, 132, 0.2)"}]}
:options {:scales {:yAxes [{:ticks {:beginAtZero true}}]}}}])
But I get this error:
error when calling lifecycle function my-app.core/mount-root Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `my-app.views.chart`.
Line
seems to be undefined and I don't know why. Both "chart.js": "^3.1.1"
and "react-chartjs-2": "^3.0.2"
are in my package.json. I'm quite sure it was working yesterday, but don't know what I've changedI've added nouislider-react
to the project, but I just removed it and it's still not working. What should I look for in the exports? I'm not too familiar with JS modules and exports, but I found this in node_modules/react-chartjs-2/dist/index.js
:
var Line = React.forwardRef(function (props, ref) {
return React__default.createElement(ChartComponent, Object.assign({}, props, {
type: 'line',
ref: ref,
options: props.options || {}
}));
});
but I don't think that's the issue if it was working, more likely a typo or similar issue
I guess it was a caching issue. I deleted everything and restored it from git and restarted shadow-cljs. Now it's working. Thank you anyway!