Fork me on GitHub
jon rostran22:08:38

is it possible to import cljs in a clj build hook file ?


sorry I don't understand the question


what do you mean by "import cljs"

jon rostran22:08:21

a build hook file importing a function in the cljs source-paths and invoking it


what does that mean?


CLJ only runs the JVM code, it cannot invoke CLJS/JS code no

jon rostran22:08:54

I have a function written in a cljs file with the cljs file ext. the hook file is written in cljc ext and I need to grab a function in the cljs file to use in the cljc hook file


don't know why your hook is cljc but it sound like you are trying to do something that is not possible?


maybe try to describe what you are trying to do more?


what does this function do?

jon rostran22:08:15

I have a hooks.main file

jon rostran22:08:39

and it calls hiccup html, I need to grab a component in the cljs side and call it inside hiccups html


what do you mean by "call it inside". this is CLJS code, so it is meant to run in the browser?


if you are trying to use hooks to do some kind of server side rendering stop, they are not meant to do that and can't do that

jon rostran22:08:26

I need to call the function that wraps the component inside hiccup’s html form

jon rostran22:08:37

so that it returns a string for example

jon rostran22:08:08

it’s means to compile to an index.html file

jon rostran22:08:15

it’s meant*

jon rostran22:08:30

but I need to insert a component when the index.html builds

jon rostran22:08:40

since I already have it written somewhere else


what do you mean by "insert a component"?


I mean a component is a dynamic thing that runs in the browser (I assume)


but again .. this sounds like you are trying to do server-side rendering


which hooks shouldn't do and really cannot do properly


or I just fundamentally do not understand what you are asking 😛

jon rostran22:08:27

I mean that when the hook runs and invokes hiccups html, I want to write a symbol that references a reagent component definition written in cljs, then I want that fn call to return inside the html hiccup form, I want to eval it and return when the build calls html

jon rostran22:08:24

said component is just hiccup markup doesn’t have anything fancy


so you want to take the html this component generates and dump it statically into a .html file


this is generally called server-side rendering. this is not supported and build hooks cannot do that and really absolutely should not do that

jon rostran23:08:19

the build hook outputs a static index.html file, in that file I want to include that component written in cljs/reagent


yes, you keep saying that but it doesn't make sense 😛

jon rostran23:08:59

I think what u said earlier is what I’m trying to do

jon rostran23:08:29

anyway, is this possible? tried requiring the cljs with reader conditional

jon rostran23:08:37

but doesn’t work


no, fundamentally not possible with reader conditionals


and also not possible in build hooks


I mean everything is possible but this is not what build hooks are designed to do


so you are better off doing is elsewhere

jon rostran23:08:57

ok, I guess my build hook will be used strictly to prepare a static index.html to then mount the app


I mean you can make a :node-script build that takes your CLJS code and uses react-based server side rendering to create that index.html


that is totally doable


but combining this with build hooks doesn't make sense and shouldn't be done