Fork me on GitHub
#clojurescript
<
2017-10-08
>
dominicm00:10:49

@jeaye to my knowledge, 16 doesn't work yet

dominicm00:10:23

@jeaye you can use the reagent alpha too I think

jeaye00:10:56

Ah, right. 16 is out, but not yet working with reagent. Ok, I'll downgrade to rule that out.

jeaye00:10:10

I don't think it's the problem here, but it'd be a problem, for sure.

jeaye00:10:30

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.

jeaye00:10:53

Good call though, @dominicm.

jeaye00:10:41

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.

jeaye01:10:28

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

Chris Bidler02:10:40

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

Chris Bidler02:10:33

in my index.html I have this:

<!-- Clojurescript -->
    <script src="js/app.js"></script>
    <script>myproject.core.main();</script>

Chris Bidler02:10:12

And when I run my production build and hit index.html with a browser, I get Uncaught ReferenceError: myproject is not defined

Chris Bidler02:10:08

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?

jeaye02:10:19

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?

jeaye02:10:08

Thus, when including it, main is called.

Chris Bidler03:10:02

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 ^:exported

Chris Bidler03:10:37

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

mfikes03:10:49

@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.

Chris Bidler03:10:06

@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. 😄

Chris Bidler04:10:28

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?

Chris Bidler04:10:59

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.

Chris Bidler04:10:46

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"

mfikes12:10:38

@chris_johnson I'm wondering if you have code that is being subjected to DCE.

genec13:10:27

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.

Chris Bidler14:10:56

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. :)

lovuikeng15:10:07

@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

lovuikeng15:10:06

Proto-REPL is another interesting project which allows visual insight on data modeling https://atom.io/packages/proto-repl

genec16:10:58

@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.

Chris Bidler18:10:49

@genec That actually sounds like kind of a good use case for AWS Step Functions

Chris Bidler18:10:19

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

genec22:10:08

@chris_johnson That's a really good idea, I hadn't thought of doing that. Thanks.