figwheel-main

figwheel-main http://figwheel.org
GGfpc 2020-07-20T09:14:21.101900Z

Hi, I'm having some trouble with figwheel. I have two files in my src folder which figwheel is set to watch, and one of those files is my :main. The issue is that figwheel only includes the :main in the global javascript file that includes all else (and that we link in the html). How can I fix this?

GGfpc 2020-07-20T09:15:07.102Z

If I open the browser console I also only see the :main javascript file in my project folder

bhauman 2020-07-20T12:30:53.103Z

@ggfpc12495 if I understand you correctly that is how figwheel is supposed to work

bhauman 2020-07-20T12:31:18.103400Z

but I’d need to now more before I can help you further

bhauman 2020-07-20T13:05:00.104500Z

@daniel975 one good way to debug the production build is to compile to :whitespace not :advanced and then see what the error is

bhauman 2020-07-20T13:05:23.105Z

I’d really love to know what problem you are having. I’m probably missing something basic

GGfpc 2020-07-20T16:24:24.105100Z

So what I mean is that I have two html files for two different pages, index and login. For each one of those I have a cljs file, index.cljs and login.cljs. My :main in the figwheel config is myproject.index. When figwheel loads, both index.cljs and login.cljs are compiled into js, but the myproject-dev.js which is what (as far as I know) needs to be linked in the html files only includes index.js and not login.js so my login page has no javascript

bhauman 2020-07-20T18:42:40.105300Z

you would need to require the login.js for it to be present @ggfpc12495

bhauman 2020-07-20T18:43:47.105600Z

Also of interest is the :extra-mains functionality https://figwheel.org/docs/extra_mains.html

bhauman 2020-07-20T18:45:34.105900Z

An interesting thought

bhauman 2020-07-20T18:46:51.106100Z

@daniel975 yeah there is something wrong with your setup.

GGfpc 2020-07-20T18:51:28.106300Z

Oh I see, so a normal workflow If I wanted to have multiple cljs files would have me require all of them in the :main one whether directly or transitively?

bhauman 2020-07-20T22:39:30.106500Z

to different entry points mean two different builds

bhauman 2020-07-20T22:40:22.106700Z

so for instance you could have one main file that requires both of your current mains and then decides which one to render based on perhaps some information on the page

bhauman 2020-07-20T22:40:46.106900Z

that way you would have one build

bhauman 2020-07-20T22:41:20.107100Z

or you could have to builds ie two .cljs.edn files and then run two instances of figwheel

bhauman 2020-07-20T22:41:35.107300Z

or you can use extra-mains

bhauman 2020-07-20T22:42:40.107500Z

Of all these the first suggestion of having a single main that requires your two mains and then make a decision which one to render, is the easiest