This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-02
Channels
- # beginners (130)
- # calva (3)
- # cider (13)
- # circleci (1)
- # cljsrn (19)
- # clojure (106)
- # clojure-europe (10)
- # clojure-losangeles (1)
- # clojure-nl (9)
- # clojure-uk (33)
- # clojurescript (16)
- # code-reviews (24)
- # conjure (11)
- # cursive (41)
- # data-science (9)
- # datomic (63)
- # fulcro (19)
- # graphql (12)
- # helix (4)
- # kaocha (2)
- # leiningen (3)
- # malli (8)
- # meander (1)
- # off-topic (17)
- # re-frame (16)
- # reitit (12)
- # sci (32)
- # shadow-cljs (73)
- # spacemacs (31)
- # sql (38)
- # tools-deps (26)
- # xtdb (28)
How possible is it to dynamically load cljs modules? Use case is I'm trying to make a plugin system for an electron app. I'd like to have everything run under advanced compilation and be able to pull in optional deps, hopefully without dragging multiple copies of the cljs std library in. Does the EMCA support (-ish) in shadow have any bearing on this? If not this channel is most likely to have the answer anyway 🙂 AFAICT this is pretty easily possible if I don't care about importing cljs core multiple times. I can just use ^:export on the important functions and then use emca import.
could you make a small js file that wraps require
at runtime?
oh wait, sorry, cljs modules not js modules.
@jatkin plugins systems are impossible if you use :advanced
. :advanced
is whole-program optimization so it removes everything that isn't used. as soon as one of your plugins would use something that was removed previously everything breaks.
multiple cljs.core
is also not a great idea since they won't be compatible with each other. so can't pass a {:foo "bar"}
map from one plugin to main or other plugin and expect that to work
I'm trying to use react-color
, but importing it from one of my namespaces gives me an error, which seems to be from:
failed to load module$node_modules$react_color$lib$components$common$index
Ok, that comes from this error (I think):
Uncaught TypeError: Cannot redefine property: Alpha
And maybe that's from this code?
Object.defineProperty(exports, 'Alpha', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Alpha).default;
}
});
I'm not sure if there's a way to exclude just this one react npm from the bootstrap build, or why it's a problem ...
I mean this specifically blows up only in that build - I have a normal app build and then the self-hosted one.
no clue. if you setup a reproducible example I can take a look otherwise you are on your own.
can't redefine sounds like it is already loaded but it is trying to load over itself
which shouldn't happen if you properly bootstrap/init and all of that but I don't know
Sure, I understand it's mysterious and not a priority for you. Just thought something might sound obvious!
The whole mechanics of the self-hosted build are more or less a mystery for me anyway.
I’m having an issue that my entry-point (init-fn) is missing in production builds. shadow-cljs compile app
works fine, but shadow-cljs release app
seems not to export my init funciton.
but not as a function. There is something like :
var shadow$provide = {};
(function(){
...
Aa("someapp.core.init",function(){var a=new U(null,1,5,W,[zD],null);
...
}).call(this);
I can see no difference to https://github.com/shadow-cljs/examples/tree/master/re-frame but obviously I’m missing something.
how are you using the function? or why don't use use :init-fn
instead? or when do you actually use it?
<html lang="en">
<head>
<meta charset='utf-8'>
<!-- ... -->
<script src="/js/compiled/main.js"></script>
</head>
<body>
<div id="app"></div>
<script>someapp.core.init();</script>
</body>
</html>
Can't find variable: someapp
… but now I see that there is an error way before and that might cause the that the init-method will not be defined, right?
I’m having a router in my app (reitit) and that seems to have an issue with compiler optimisations in production as it seems?
Chrome clojure devtools helped to find the error quickly. It was a debug statement (println "*** " (reitit.frontend.easy/href ::somethin))
on toplevel … bummer.
I seem to be hanging in an endless loop in watch where shadow-cljs is recompiling some files constantly. Anyone seen that before?
is something maybe touching your source files or so? so shadow-cljs writes something, something else watches the output and touches something which then triggers shadow-cljs to compile again?
I checked with inotifywatch (using linux here) that there are no modifications to my src tree. I am investigating a bit later today what is going on there.
Oh, can it have to do with me renaming my resources/ directory to resources-dev/ and I didn't notice since then? Looks like in shadow/build/classpath.clj it gets filtered.
If I delete the contents of cljs-runtime, while it is looping, it regenerates and stops. Maybe the pattern doesn't match correctly here.
i’m stuck somehow, i’ve added cljs-ajax as a dependency and no matter what i do, i cannot get the repl to recognize the library:
(require '[ajax.core :refer [GET]])
=> nil
(GET "")
=> #object[ReferenceError ReferenceError: Can't find variable: ajax]
not enough info to comment. need more context. what :target
? anything in the console? etc?
here’s my build:
:dev
{:target :react-native
:init-fn client.core/init
:output-dir "app"
:compiler-options {:closure-defines
{"re_frame.trace.trace_enabled_QMARK_" true}}
:devtools {:after-load steroid.rn.core/reload
:build-notify steroid.rn.core/build-notify
:preloads [re-frisk-remote.preload]}}
re: console, initially i tried running a shadow server and connecting via nrepl in cursive but tried dropping to a cljs-repl and ran the above in a non-user namespace