Fork me on GitHub
<
2020-08-19
>
daslu04:08:17

(doesn't seem to help 😊 🙏 )

daslu05:08:54

It looks like browser caching was at least part of the problem, since on different browsers I got different behaviors. Now I cannot reproduce it, and everything seems to be fine. :thinking_face:

thheller08:08:21

@daslu :resouce-paths in not a thing in shadow-cljs.edn and wouldn't apply anyways since you have :lein true and all classpath management is done by project.clj. setting :optimizations in :dev only does absolutely nothing since :dev ALWAYS forces :none and that cannot be modified. you can also leave :devtools always in since it will be ignored in release builds.

thheller08:08:40

you should really consider bundling you CSS properly. putting a bunch of paths into :dev-http like that is not going to end well 😛

thheller08:08:45

FWIW watch and compile differ in that watch injects a bunch of extra REPL/hot-reloaded extra code, otherwise they should be the same

daslu08:08:38

@thheller thank you so much for this kind and detailed mentoring. This is really enlightening and helps so much. ❤️

thheller08:08:50

ah and also only use :dev-http since it will conflict with :devtools {:http-port ..} otherwise

👍 3
thheller08:08:32

{:lein true
:dev-http {8080 ["resources/public/"
"target"
"classpath:resources"
"classpath:resources/public"
"node_modules"
"node_modules/leaflet/dist"
"node_modules/mathjax/es5"
"node_modules/ag-grid-community"]}
:builds {:app {:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:target :browser
:modules {:main {:init-fn gorilla-notes.main/main!}}
:devtools {:after-load gorilla-notes.main/reload!}}}}

thheller08:08:37

that is the leftover config if all the invalid stuff is removed 😉

p-himik14:08:29

The :bootstrap target seems to be undocumented, and the anchor https://shadow-cljs.github.io/docs/UsersGuide.html#target-bootstrap (used by the very first mention of :bootstrap in the user's guide) is not attached to anything. Is it an intentional omission?

Sam Ritchie14:08:49

hey all! @mhuebert, question for you if you have a moment...

mhuebert14:08:24

hi @sritchie09! it does look like encore may be the issue here — in the source https://github.com/ptaoussanis/encore/tree/master/src/taoensso I see cljx files... is there another version somewhere ported to use cljc?

Sam Ritchie14:08:14

@mhuebert I don't think he has one, but of course I could fork it, or exclude. I will say that I went into the jar when debugging and deleted the cljx file, leaving only the generated cljs and clj files

Sam Ritchie14:08:26

and this same behavior still occurred

Sam Ritchie14:08:58

I can definitely try swapping that dependency and seeing if we have any luck, I'm only pulling it in transitively to do logging

mhuebert14:08:31

it probably is not selfhost compatible

mhuebert14:08:41

is it necessary?

Sam Ritchie14:08:35

I can exclude it with a little work by replacing the logging calls in sicmutils

mhuebert14:08:36

subtle tricks are often needed for selfhost compatible macros, see https://github.com/cgrand/macrovich

Sam Ritchie14:08:55

yes, I expect I'm going to have to do this too for sicmutils

Sam Ritchie14:08:08

which is totally fine! I've been aiming at Maria for a few weeks, and I'm so close...

mhuebert14:08:11

or you can try adding the encore clj namespace to the :exclude vector

mhuebert14:08:36

if you don’t need the macro available in the editor

Sam Ritchie14:08:38

let me try again, but compilation does fail, I believe

mhuebert14:08:30

is your code using encore directly or is it a transitive dep?

p-himik14:08:41

If encore is indeed not compatible with bootstrapped CLJS, maybe it's worth creating an issue in its repo.

Sam Ritchie14:08:00

okay, that triggers The required namespace "taoensso.encore" is not available, it was required by "taoensso/timbre.cljs".

Sam Ritchie14:08:14

agree that this merits an issue in their repo

Sam Ritchie14:08:54

btw I think we're chatting friday, with Jack and Dave, if you're free

3
Sam Ritchie14:08:06

I'm trying to get Maria working with https://github.com/littleredcomputer/sicmutils, so we can do physics, calculus etc in Maria

Sam Ritchie14:08:28

I'm hitting an issue that I've nailed down to something strange in the bootstrap build

Sam Ritchie14:08:11

basically, if I use this entry in shadow-cljs.edn, as the project currently uses:

:bootstrap
{:target :bootstrap
:output-dir "public/js/compiled/bootstrap"
:module-hash-names true
:entries [maria.user]
:exclude [cljs.js]}

Sam Ritchie14:08:02

then live evaluation in Maria works great! but the build breaks with this error:

[:bootstrap] Build failure:
The required namespace "" is not available, it was required by "taoensso/encore$macros.cljc". "clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ? + /live.html Sam Ritchie14:08:36 if I change the entries line to this: :modules {:main {:entries [maria.user]}} Sam Ritchie14:08:41 then the build can successfully complete... Sam Ritchie14:08:04 but I see this when I try to evaluate anything Sam Ritchie14:08:02 this reproduces on the sritchie/last_attempt branch here: https://github.com/sritchie/maria/tree/sritchie/last_attempt Sam Ritchie14:08:27 does anyone with knowledge of :bootstrap have any thoughts about what's going on, and why this bare :entries form is both required, but seems to get in the way of cljs compilation? thheller15:08:40 @sritchie09 :target :bootstrap does not support :modules so using it breaks stuff. :module-hash-names also has no effect. you just specify :entries and it will compile those to be available in self-hosted thheller15:08:50 you run into a namespace that requires java and that breaks compilation thheller15:08:39 you can maybe just exclude it so :exclude [cljs.js taoensso.encore] thheller15:08:13 its often the case that libraries contain macros that aren't self host compatible thheller15:08:57 all bootstrap relating things are severly lacking in documentation. mostly because I don't know how half the stuff works either and nobody else bothered to write anything. Sam Ritchie15:08:59 @thheller I'm taking a pass at swapping out the logging library - Sam Ritchie15:08:04 it's not that important, and might bebest Sam Ritchie15:08:12 excluding failed on me, unfortunately thheller15:08:55 failed how? Sam Ritchie15:08:39 oh, sorry, annoying lack of info Sam Ritchie15:08:50 timbre requires it, Sam Ritchie15:08:01 the logging library I was using, so excluding it caused a "encore not found" error thheller15:08:01 taoensso.encore definitely does not support self-hosted CLJS thheller15:08:18 you are using it in self-hosted? Sam Ritchie15:08:19 I've got a physics library converted to cljs, and I'm trying to make it available in the Maria environment Sam Ritchie15:08:38 which runs in self-hosted mode Sam Ritchie15:08:27 this MIGHT be the only issue... but probably there will be some macro problems inside the library Sam Ritchie15:08:37 not a big deal to convert to another logging library, of course thheller15:08:08 well the self-hosted variant is only needed if you actually compile something client side that uses it thheller15:08:22 like if you are trying to eval (encore/something foo) Sam Ritchie15:08:02 strangely, all I was trying to do was require sicmutils.env, which depends on namespaces that depend on timbre Sam Ritchie15:08:49 okay, interesting, maybe this is deeper than we think Sam Ritchie15:08:51 [:bootstrap] Build failure: The required namespace "" is not available, it was required by "taoensso/encore$macros.cljc".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
+ /live.html

Sam Ritchie15:08:56

this problem occurred on build

Sam Ritchie15:08:02

not on any eval -

Sam Ritchie15:08:59

sending the exclude error

thheller15:08:51

the above is expected. that namespace cannot be compiled for self-hosted.

Sam Ritchie15:08:01

wait a second, I may have misunderstood a suggestion -

mhuebert15:08:44

adding taoensso.encore to :exclude - next to cljs.js - was tried already?

Sam Ritchie15:08:50

I was excluding from the actual jar... I"m trying to add that ns to exclude now.

Sam Ritchie15:08:09

sorry about that! yes, I had excluded the transitive encore dep in deps.edn

thheller15:08:26

yeah I meant :exclude in the build config

Sam Ritchie15:08:57

this is promising, I see The required namespace "io.aviso.exception" is not available, it was required by "taoensso/timbre\$macros.cljc".

thheller15:08:13

same thing.

Sam Ritchie15:08:30

yup, chasing it down

thheller15:08:31

probably just exclude taoensso.timbre

Sam Ritchie15:08:08

we may a winner...

Sam Ritchie15:08:34

okay, boom, I think we have more errors, but that may get me past that one

Sam Ritchie15:08:14

okay, amazing, I think we're in business!!!

Sam Ritchie15:08:16

question for you both...

Sam Ritchie15:08:53

let's say I do have a macro that I want to use in Maria

Sam Ritchie15:08:29

#?(:clj
(defmacro bootstrap-repl!
"Bootstraps a repl or Clojure namespace by requiring all public vars from
sicmutils.env. From (This will only work at a repl in Clojurescript.)"
[]
(require '~['sicmutils.env
:refer
(into [] (keys (ns-publics 'sicmutils.env)))])))

Sam Ritchie15:08:44

this is probably a case where I need to use macrovich?

Sam Ritchie15:08:06

or perhaps just specifically refer this macro vs [sicmutils.env :as e :include-macros true]

Sam Ritchie15:08:29

YES! you're both geniuses, scholars, athletes, whatever you want to be

Sam Ritchie15:08:04

The lagrangian for a pendulum, it's alive

thheller15:08:42

you definitely want to stay away from macros doing anything with require

thheller15:08:54

thats black magic that doesn't work at all in CLJS

thheller15:08:12

you can however just modify the compiler-env directly if you want 😉

thheller15:08:21

thats probably easier

Sam Ritchie15:08:41

yup, I just inserted a monster require block

Sam Ritchie16:08:10

the only thing remaining is that the repl can't see any macros from env

Sam Ritchie16:08:23

#?(:clj
(defmacro with-literal-functions
[& args]
(f/with-literal-functions [email protected])))

Sam Ritchie16:08:16

@thheller it does look like I can access other macros here...

Sam Ritchie16:08:39

obh, obviously, gotta strip the :clj:`

thheller16:08:16

self-host macros is where my understanding of all of this ends. its weird and scary 😛

Sam Ritchie16:08:07

Sam Ritchie16:08:39

holy mackerel...

Sam Ritchie16:08:48

macros work too. thank you all!!!

6
Sam Ritchie16:08:20

for anyone curious, what this means is that we can now run all code and exercises from "Structure and Interpretation of Classical Mechanics" live in a browser, via Maria https://www.amazon.com/Structure-Interpretation-Classical-Mechanics-Sussman/dp/0262194554

Sam Ritchie16:08:21

Sussman wrote another book called Functional Differential Geometry, that implements all of the math of general relativity... all of that works too. The reason for this port is that I want to add the ability to take those equations above, and live-generate an animation, right when you evaluate the code... and have it update when you change things

Sam Ritchie16:08:36

2020-07-01 21.20.35.gif

Sam Ritchie16:08:39

you can write down a "lagrangian" that describes this system, but it's a bit frustrating to not get to see it work. so now with cljs we'll be able to!

thheller16:08:17

looks like black magic to me. math and physics are even scarier than self-host macros 😛

Sam Ritchie16:08:44

haha, I hear you and agree

Sam Ritchie16:08:06

that's the problem I'm trying to solve, making it less like black magic and more like a strange game engine (powering the Universe Game that we're all playing)

Sam Ritchie16:08:09

animation, math, code next to each other. pin function inputs to sliders, and watch everything change in sync, Bret Victor style... http://worrydream.com/#!/Tangle

Sam Ritchie16:08:12

okay, thanks again, all

mhuebert18:08:11

@sritchie09 fantastic that you got this working!

❤️ 3
daslu21:08:11

@sritchie09 that is wonderful!