Unfortunately it is not that simple to add.

Dynamic load is simply not possible due to the restrictions of the browser 
(all IO is async). A static load could be possible but I'm not convinced 
that it would actually change much. 3 second recompile time seems pretty 
excessive but it might actually be caused by the default "recompile all 
dependents" behavior where a change in a file triggers a recompile of all 
the files that required that which then also trigger recompiles and so on. 
Basically in the case of an "API" namespace it potentially recompiles your 
entire project on every change. Splitting the API namespace up into smaller 
ones but still exposed as one will still trigger this so it would not 
change anything. You should try `:recompile-dependents false` in your 
config and see if that improves the recompile performance. shadow-cljs for 
example is much faster in recompiles because it limits recompiles to direct 
dependents not all them, which is usually enough but still doesn't help if 
every single namespace in your project directly requires that "API" 
namespace.

A more Clojure-esque REPL driven approach via `load-file` can also be a 
whole lot faster than automatic file-watch + hot-reload.

I do agree that keyword aliasing becomes a bit of an issue but 
unfortunately there is no "fix" for that currently. A couple more votes 
might help push this along? [1]

Do you actually have an API surface of 1700 lines of code though? Splitting 
the code into multiple impl namespaces and only exposing actual public API 
selectively seems like a pretty good strategy apart from the keyword issue?



[1] https://dev.clojure.org/jira/browse/CLJ-2123


On Wednesday, October 10, 2018 at 11:17:07 AM UTC+2, Tom Locke wrote:
>
> I'm working on a library, for which I would like to expose a single 
> namespace to users. I don't want users (including myself!) to have to 
> remember this function comes from foo-lib, this one comes from 
> foo-lib.utils etc.
>
> Internally, however, I would very much like to split my code up into 
> separate files. This is not just for convenience (although I do find 
> smaller files much more convenient), but has a material impact on my 
> productivity. A single long file takes a few seconds to compile (usually in 
> figwheel). These pauses really add up and make the overall experience feel 
> sluggish.
>
> In Clojure this is a non-issue -- a namespace can be split into multiple 
> files using load and in-ns. We don't have those in ClojureScript.
>
> I have tried various approaches to breaking my library up into multiple 
> namespaces, while keeping the single namespace API, but none are 
> satisfactory. I can expose symbols just by def-ing them in the main 
> namespace, e.g. (def foo my-utils/foo). This is inconvenient for editing 
> (e.g. go to definition), but the real stumbling block is namespaced 
> keywords, which I use a lot. As users of the library must use the keywords 
> also, I need them to be in the main namespace. This means my utility 
> namespaces (which cannot require the main namespace due to circular 
> dependencies) would have to use the long-hand keyword syntax (i.e. no :: ). 
> This is too high a price and I am back to everything in a single namespace.
>
> Is this issue affecting others? My guess is people just impose multiple 
> namespaces on the consumers of libraries, or are stuck with cumbersome, 
> large namespaces.
>
> I came across this old thread, which is related. It didn't get very far: 
> https://groups.google.com/forum/#!topic/clojure/MwGV6GDN9p8
>
> Thanks very much
>
> Tom
>
> P.S. I have seen people mentioning "sub second compiles" in figwheel. I am 
> seeing, e.g. more than 3 seconds to compile a 1,700 file. Does that sound 
> typical? (2012 MacBook Pro)
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to