Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Figwheel main support #403

Open
tslocke opened this issue Dec 4, 2018 · 29 comments
Open

Request: Figwheel main support #403

tslocke opened this issue Dec 4, 2018 · 29 comments

Comments

@tslocke
Copy link

tslocke commented Dec 4, 2018

Since this looks like it will be the future of figwheel, it would be great to have a +figwheel-main in addition to the current +figwheel, for those like me, struggling to understand the best way to configure things.

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

My understanding is that Figwheel main is meant for standalone usage, and Figwheel plugin is used from Leiningen. @bhauman am I correct on that? :)

@bhauman
Copy link

bhauman commented Dec 11, 2018

They are completely different code bases. Figwheel main is often used from Leinigen.

https://figwheel.org/docs/installation.html

@tslocke
Copy link
Author

tslocke commented Dec 11, 2018

I believe Figwheel Main is "The" Figwheel going forward, in terms of ongoing maintenance, new features etc.

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

I'm a bit unclear on the relationship between the two at the moment, @bhauman would you recommend switching over to Figwheel main, will both projects be maintained?

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

I see, thanks for the heads up

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

Looking at the docs page, it doesn't look like there's any integration with Leiningen though. I really liked the option for keeping Figwheel config in project.clj, is this just not going to be possible going forward?

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

@bhauman is it possible to pass the config to Figwheel main as an explicit parameter? If that was the case, I would write a Lein plugin that could start it that way. While understand the benefit of Figwheel being able to run standalone and have its own config, I think there's value in having integration with Leiningen as it's the most widely used built tool.

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

@bhauman the docs suggest using an alias like {"fig" ["trampoline" "run" "-m" "figwheel.main"]} to run Figwheel. That means the configuration has to be kept externally and managed outside project.clj. I don't see any option to be able to keep the config together. I strongly prefer having all the configuration in one place because then I can control the options via profiles.

I don't really see any downside to supporting this functionality. The plugin could literally just run figwheel.main and pass it the config it reads from project.clj. Am I missing anything as to why this would be problematic or not desirable?

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

I understand all that, but I'm asking why both ways can't be supported if it's just a matter of exposing the entry point in Figwheel. This seems to be very prescriptive, and while it's a great choice for a lot of situations, I think it would be nice to allow users to decide how their project configuration works. Allowing for a lein plugin doesn't detract from the current approach, and people can switch between them trivially if they want to.

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

@bhauman another problem with this approach is that it's no longer possible to share cljs compiler config. This is error prone because you have to remember to make changes in two places now. I really hope you'll reconsider to allow supplying Figwheel configuration explicitly even if it's not your personal preference. Please consider that everybody has different use cases, and different priorities for their build process. I'm not asking for a plugin, just the ability to make one so that I can use the tool in a way that fits best with my current setup.

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

Luminus is a template, people can easily make other templates that fit their workflow. Right now it's not possible to me to use Figwheel main in a way that doesn't fit with your preference.

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

but my configuration lives in project.clj because I need it to create the uberjar.

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

For context, the applications my team works on have both client and server components. The applications are packaged as jars for releases containing all the build artifacts. In our scenario, it makes a lot of sense to have a central configuration file instead of duplicating it across multiple ones.

@bhauman
Copy link

bhauman commented Dec 11, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 11, 2018

I'm trying to learn it, but I'm running into problems around the workflow, and as far as I can tell there aren't adequate solutions to those. Currently, the usage from Leiningen appears to be strictly worse than it was with figwheel-lein. In my case start up speed is not of interest, and being able to keep a single configuration in one place provides a lot of value.

I also don't see how it's faster to launch from lein as a separate process as an alias. I still have to wait for lein to start, and then wait for Figwheel main to start after. Is that not the case?

@lacarmen
Copy link
Member

I ran into similar issues as @yogthos trying to use figwheel.main.

While I understand your reasons for the changes, @bhauman, there are use cases that worked with "old" figwheel that are no longer supported by figwheel.main. If you're going to recommend that devs make the switch then existing workflows should be supported going forward.

@bhauman
Copy link

bhauman commented Dec 12, 2018

Often what happens to me in conversations like this is that I initially remember/feel that something is a not a good idea, without remembering the complete context and reasoning behind it. This is often because time has passed and I'm way out of the context that generated the initial thinking. When folks press me for why and I provide an incomplete answer hoping that it will suffice, knowing that I don't quite remember all the reasons. This is a bit lazy on my part as I'm not quite motivated to go back and revisit all my reasoning for this, and then take the time to write out all the trade offs the led me to that conclusion.

I ask folks to take my word for it and hope that it will suffice and then I experience frustration when it doesn't. This is not an ideal response. However communicating these things doesn't come easy to me, it takes more time than you may imagine.

In this particular case, the main reason for this trade-off is around the need to be able to read the build configuration from the project.clj. This is something that you need to be able to do if you want to start Figwheel from a REPL which includes cider-jack-in-cljs and using Cursive. In order for this important workflow to work well in figwheel-sidecar I had to create https://github.com/bhauman/simple-lein-profile-merge which made the workflow more possible but as we know doesn't work in every case. Quite frankly having to write that in the first place was an incredible pain. It's quite painful to extract profile applied data outside of the project.clj, and because its difficult to do and doesn't work sometimes it leads to very confusing situations when it doesn't work. So this compared to the simplicity of reading an EDN file seems like an interesting trade-off which decreases the complexity of whats needed to carry your configuration to figwheel, and increases the understanding of how the configuration is read and used.

While it's difficult to get data out of the project.clj it's trivial to get data into the project.clj by simply slurping/merging compile configuration files.

The state of things right now, is if you only add "figwheel-main" to your dev deps in the project.clj, and you setup the configuration as recommended in a dev.cljs.edn file you can have a CIDER cljs-repl with no other configuration, by simply doing cider-jack-in-cljs and selecting figwheel-main as an option. It has never been so easy to get a reliable Clojurescript REPL in Emacs.

Figwheel-main also works well with Cursive because of this simplicity.

And, as stated before, this also allows one to use Figwheel with deps tools as well.

For these reasons I advocate having the configuration outside of the project.clj. The relative benefit of having the production configuration be a convenient profile switch that prevents some duplication, compared to eliminating the need to use and maintain a monstrosity like simple-lein-profile-merge.

Especially considering that the potential duplication of config can be eliminated by simply reading the build config into the project.clj.

In response to the question about speed and Leinigen. Plugins are what make Leinigen slow. Whereas Leinigen is AOT compiled, plugins have to be resolved and loaded dynamically.

@yogthos
Copy link
Member

yogthos commented Dec 12, 2018

Thanks for the detailed response. I completely understand your reasoning for not wanting to maintain a library just to handle merging data between profiles. Reading config into project.clj would help with the duplication, but it would still be useful to pass that configuration to Figwheel as a parameter. In general, I do like that there is no inherent coupling between Figwheel and Leiningen right now.

I obviously wouldn't ask you to incur the burden of having to maintain complex tooling you don't use. However, I hope it's not too unreasonable to facilitate passing in the configuration explicitly as opposed to requiring that it's read from a file. I can see this being useful in a number of situations such as running Figwheel from the REPL with a synthesized config for example.

And the AOT vs plugins makes sense, although realistically I tend to already have plugins running from ~/.lein/profiles.clj and Figwheel isn't going to break the bank. At least with my workflow, I tend to just leave Figwheel running and might restart it a handful times a day.

@bhauman
Copy link

bhauman commented Dec 12, 2018 via email

@yogthos
Copy link
Member

yogthos commented Dec 12, 2018

Oh, that's exactly what I was looking for. 👍

@EmmanuelOga
Copy link

Hi! I was wondering if there was any updates in this area by any chance? Thanks!

@yogthos
Copy link
Member

yogthos commented Jan 28, 2020

I ran into a few snags with the classpath, and haven't had a chance to look into this since.

@dijonkitchen
Copy link
Contributor

May be related to #467 since I think figwheel-main might treat deps.edn as first class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants