Fork me on GitHub
#shadow-cljs
<
2017-10-06
>
thheller08:10:16

@mhuebert I’m doing a bit of cleanup. shadow.bootstrap is now shadow.cljs.bootstrap.browser

thheller08:10:04

also don’t need the cljs/js.cljs anymore, the default now works.

thheller08:10:37

the question now is whether the “bootstrap host” and “bootstrap support files” should be 2 separate builds

thheller08:10:10

the 2-in-1 build has a couple of issues and in theory you could share the support files on multiple builds

thheller08:10:27

“host” is the build that calls init and uses load

thheller08:10:43

the support files are actually just files then used by the “host”

thheller08:10:46

but they don’t really need to know anything about the host

mhuebert13:10:01

what are the issues with the 2-in-1 build?

mhuebert13:10:16

yes the sharing of support files is a big win actually

mhuebert13:10:58

with the way this is shaping up, one could rather simply build a service that would precompile large numbers of libraries, and put them at versioned urls cached indefinitely

mhuebert14:10:47

the output of the “self-host” build is just a directory of files (the index, sources, all that) whereas the “host” build is going to be a typical :browser build with live-reload and so forth

thheller16:10:21

yeah exactly

thheller16:10:37

the issue is that currently the self-host support files are an “afterthought”

thheller16:10:03

if you change one file that is not part of your actual build a re-compile will not be triggered

thheller16:10:16

same for macros, since they aren’t part of the actual build they will not trigger a rebuild

thheller16:10:39

the only danger with 2 builds is that you might run into issues when using different compiler versions

thheller16:10:00

but even then only if there were breaking changes to the analyzer data which is pretty rare

mhuebert17:10:06

for hosting/caching, as you allude the versioning should be by library+compiler (within ranges), this problem can be solved outside of shadow I think

mhuebert17:10:55

I don’t think it’s worth worrying too much at this point about trying to get live reload of self-hosted-only namespaces

mhuebert17:10:17

to me there is a big benefit in the basics just working reliably

thheller17:10:46

nah I don’t want to live-reload those, that is far too much work indeed. just triggering a re-compile would be enough.

mhuebert17:10:47

this is a huge improvement over the status quo

thheller17:10:09

I’m making a new :target option now

thheller17:10:27

so you have one :browser build which is the “host” and one :bootstrap build thats just the support files

mhuebert17:10:37

ah that’s perfect, so no :bootstrap-options

thheller17:10:39

which can be shared accross many “hosts”

thheller17:10:09

right :bootstrap-options basically move to {:target :bootstrap :entries ... :macros ... :excludes ... :output-dir "..."}

thheller17:10:23

and boot/init takes a new :path where to find those files

mhuebert17:10:08

i think we may end up revisiting the idea of a :no-follow option but let’s wait until doing real use cases and see what is actually necessary

mhuebert17:10:07

yeah that’s perfect, so :path could be on a server somewhere

thheller17:10:38

exactly, I can build-in permanent caching if you’d like

thheller17:10:06

eg. when compiling I can timestamp the files and then put the timestamped names into the index

mhuebert17:10:17

oh, excellent

thheller17:10:48

so if you request cljs.core it resolves to cljs.core.123124123.js or so

mhuebert17:10:48

this stuff can make a big difference out in the field because large asset size is unavoidable with self-host. i shed a tear at the network tab of maria

mhuebert17:10:24

when these files can be cached forever, that concern lessens

thheller17:10:53

yeah just need some proper http headers and it should cache very well

thheller17:10:02

+ with h2 the request count doesn’t matter so the user really only downloads what is needed

thheller17:10:16

not pre-bundled stuff where maybe 50% is unused

thheller17:10:27

:bootstrap-support
  {:target :bootstrap
   :output-dir "out/demo-selfhost/public/bootstrap"
   :entries [demo.macro reagent.core]
   :macros []}

thheller17:10:31

looks something like this then

thheller17:10:54

doesn’t need any devtools config and I just preset all the useful compiler options

thheller17:10:02

since it never needs to be optimized or so anyways

thheller17:10:18

could even make special source adjustments should that ever be required

thheller17:10:02

the “host” build shouldn’t need any special config

thheller17:10:04

well I could put the :bootstrap-path option into the “host” build, rather than in code if that is useful?

thheller18:10:58

one issue though .. the :js-options :resolve would really need to be shared

thheller18:10:36

hmm, maybe not

mhuebert18:10:19

is the :macros option still necessary?

mhuebert18:10:16

the :js-options :resolve may need to be consistent but not necessarily shared?

mhuebert18:10:46

(ie. if you publish a bootstrap build, it could have declared certain :resolves which it expects to be available?)

mhuebert18:10:55

may not fully understand the nuances there

mhuebert19:10:04

i’m not quite sure what the :bootstrap-path option means. i would expect to copy the output-dir path from my bootstrap build and use that with boot/init

thheller19:10:33

:macros is not needed anymore no, only for very special cases probably

thheller19:10:29

the issue with :resolve is that the names are not constant, so if you configure your build to use a global for "react" you get a variable module$react in your build

thheller19:10:02

but if that resolves differently in the bootstrap support files it could be module$node_modules$react$react or so

thheller19:10:23

that would load 2 different reacts again

thheller19:10:50

since the build provided module$react but not the other the loader would load it

thheller19:10:11

but JS deps will be tricky regardless

thheller19:10:56

so I think I have everything

thheller19:10:14

re :bootstrap-path

thheller19:10:28

if you specify it in the config you don’t need to provide it to boot/init

thheller19:10:48

just a matter of where to configure it really, in code or in build config

thheller19:10:58

ok pushed the update

thheller19:10:12

:bootstrap-host would be your normal app which “hosts” the compiler

thheller19:10:25

:bootstrap-support are the support files, all written into one directory

thheller19:10:38

the shadow.cljs.bootstrap.browser ns has been updated accordingly

thheller19:10:25

API is pretty much the same except for the :path option

thheller19:10:27

:js-options should match for now, need to think about this more

thheller19:10:50

worst case is you load everything twice, which might be bad if you host interacts with it in any way

thheller19:10:01

say you detect if the returned value is something from react

thheller19:10:58

watch for :target :bootstrap probably doesn’t work correctly yet

thheller19:10:09

need to teach it about self-host macros first

thheller19:10:59

in shadow-cljs release mode the file names will be hashed

thheller20:10:42

hmm 2.1mb for the release host app with :simple, scary when used to :advanced 😉