That still does not allow you to do anything you couldn't do via the ns 
form directly. require outside ns is a misleading topic and is still 
completely static. It was just added to allow compiling scripts that don't 
have a ns form. You still can't do conditionals or run any other code 
inbetween them.

The reason that dynamic require is not possible in CLJS is that there is no 
sync/blocking IO in Browser JS. In Clojure you can simply do the work and 
return once everything is loaded properly. In JS you can't do that because 
you have to go async/non-blocking for the IO to load the files. So all of 
the remainder of the program would continue running and loading only start 
once the program yielded control back to the runtime. In addition to that 
the Closure Compiler doesn't really support dynamic requires in :advanced 
optimizations.


On Monday, February 11, 2019 at 11:40:35 PM UTC+1, Yuri Govorushchenko 
wrote:
>
> > Now I understand that 'require' in cljs is intended as a repl-only 
> thing  which expands to an ns form: 
> https://clojurescript.org/guides/ns-forms#_the_require_and_require_macros_macros
>
> It should be OK to have several requires at the top of the file. Source: 
> https://anmonteiro.com/2016/10/clojurescript-require-outside-ns/.
>

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