This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-08
Channels
- # beginners (42)
- # boot (1)
- # cljs-dev (36)
- # clojure (24)
- # clojure-berlin (1)
- # clojure-greece (3)
- # clojure-italy (18)
- # clojure-russia (67)
- # clojure-spec (1)
- # clojure-uk (35)
- # clojurescript (30)
- # cursive (2)
- # data-science (2)
- # datomic (2)
- # emacs (6)
- # fulcro (1)
- # garden (1)
- # hoplon (8)
- # lumo (9)
- # off-topic (47)
- # onyx (6)
- # perun (2)
- # protorepl (5)
- # re-frame (10)
- # reagent (1)
- # shadow-cljs (19)
- # uncomplicate (140)
Ah, right. 16 is out, but not yet working with reagent. Ok, I'll downgrade to rule that out.
Ok, dropped those to 15.5.4, which was what the figwheel template put in. It, unfortunately, didn't change anything in that I still can't require react-data-grid
.
In an optimized build, looks like it's compiled to goog.require('module$home$jeaye$projects$re_frame_trace_server$node_modules$react_data_grid$index');
which seems odd.
Well, I'd love to know what's going on with that, but I've worked around it, for now, by using webpack as suggested here: http://blob.tomerweller.com/reagent-import-react-components-from-npm
so here is a beginner question for you - I have a project building with lein cljsbuild once min
where the min
profile contains :main "myproject.core"
and :optimizations :advanced
. In myproject.core
is a (defn ^:export main [] ...)
which does all the setting up and running of stuff, and in a Figwheel REPL environment this all works beautfully
in my index.html
I have this:
<!-- Clojurescript -->
<script src="js/app.js"></script>
<script>myproject.core.main();</script>
And when I run my production build and hit index.html
with a browser, I get Uncaught ReferenceError: myproject is not defined
The question is: in an :optimizations :advanced
world, what is the right way/best way to do the starting-of-the-app from some entrypoint, given that the method I have (which I was given, didn’t just arrive at on my own) seems pretty unhappy?
myproject.core.main
is likely being shortened to something like m.z.k
, which you can't predict. Rather than including the script and calling main, why not just call main in your script?
well, that sounds delightful but I’m not sure how do to that beyond what I’ve already got, which is specifying :main "myproject.core"
in my build profile and making sure that myproject.core/main
is ^:export
ed
I mean, I totally agree about the “likely being shortened” bit - app.js
is 40kLOC of minified Javascript that doesn’t contain the string myproject
, I just don’t know (after reading all of https://clojurescript.org/reference/compiler-options - twice!) what bit of gesture or intonation my summoning ritual is missing
@chris_johnson :main
should be irrelevant for :advanced
(see https://clojurescript.org/guides/quick-start#production-builds). Using ^:export
should indeed make the function callable from JavaScript (see https://clojurescript.org/reference/advanced-compilation#access-from-javascript): Even though myproject.core
and its properties will get minified, an un-minified reference will be established through the path myproject.core.main
. I believe Jeaye is suggesting placing a call (main)
at the bottom of your myproject.core
namespace as a workaround.
@mfikes Thank you for the comprehensive and easily-digestible reply. I’m trying that now (adding a call to (main)
at the bottom of my core.cljs
file) but even if it doesn’t work, your reply has reinforced some things I thought I understood about this corner of the ecosystem and then began to doubt when I saw the behavior I’m seeing today. 😄
so that wasn’t what’s wrong, however a colleague I reached out to separately tried building this project and immediately hissed, leapt back, and drew a ring of kosher salt around his laptop - apparently some of the “harmless warnings” I haven’t been able to dismiss by applying all the :exclusions
stanzas recommended by lein deps :tree
are …not harmless?
Possibly they are preventing my compiled code from making it into app.js
at all? Good times! I am fascinated to learn what comes next.
Summary of findings: I would pay a nontrivial sum to know how many of these exist in the wild: git commit -m ":advanced is too advanced, try :simple"
@chris_johnson I'm wondering if you have code that is being subjected to DCE.
Does anyone know if there's a project or anything similar to scratch or http://luna-lang.org in clojurescript? I'd like to create some visual programming examples for a talk I'm giving at work using clojurescript.
I absolutely agree that is likely, and I plan to investigate and figure out how to get back to building with advanced optimizations Soon™, but last night was one of those situations where someone else needed some graphs to reason about a ~150% spike in traffic to a platform immediately so I punted. :)
@genec for animation try http://quil.info/, for statistics try https://react.semantic-ui.com/views/statistic... have Light Table with Figwheel running while manipulating data at runtime should be interesting talk on visual intensive application
Proto-REPL
is another interesting project which allows visual insight on data modeling https://atom.io/packages/proto-repl
@lovuikeng thanks, I've used prototyped-repl and really like it. I'm really looking for something where the programming is done graphically, similar to scratch or luna-lang. I'm hoping to find something where I can embed some business domain logic into widgets and show the users how easy it would be to wire up their own business processes. Sadly, they don't want to learn to code, no matter how simple it is.
@genec That actually sounds like kind of a good use case for AWS Step Functions
throw your business logic in some JVM or Node lambda functions, wire them up, let the users build the flow chart with the Step Function GUI
@chris_johnson That's a really good idea, I hadn't thought of doing that. Thanks.