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

Using Femto as a library #47

Closed
alfonsogarciacaro opened this issue Jul 23, 2019 · 8 comments
Closed

Using Femto as a library #47

alfonsogarciacaro opened this issue Jul 23, 2019 · 8 comments

Comments

@alfonsogarciacaro
Copy link
Contributor

This is an awesome tool! Thanks and congratulations to you both @Zaid-Ajaj and @MangelMaxime!

Did you get feedback about people using it? I'm assuming it's probably much easier for users if Femto is run automatically by Fable instead of adding an extra build step... Yes, I know I said I didn't want to add this kind of features to Fable, but if you maintain the tool and Fable just needs to call it, I'm happy with it 😉

Would it be possible to also include the option of referencing and calling Femto as a library. Fable could call it after running dotnet restore and display warnings to the user if something is found.

@MangelMaxime
Copy link
Collaborator

This means that Femto would be a requirement for Fable now.

Should Fable stop if Femto detects an invalid configuration?

If Femto is embedded in Fable, how will the user launch Femto resolution mechanism?

@alfonsogarciacaro
Copy link
Contributor Author

Yes, Femto would be a Fable dependency. But for now I'm just thinking to make it a very soft one and we can see if it's worth to tighten the integration later. Something like:

  1. Fable calls dotnet restore (it does it right before parsing .fsproj)
  2. Fable now calls Femto
  3. Femto does its magic
  4. If a problem is detected, Femto emits a warning (but Fable doesn't stop) and shows brief instructions about how to solve it
  5. Fable continues business as usual

@MangelMaxime
Copy link
Collaborator

Fable now calls Femto

We could make Fable call the Femto CLI so the user can invoke the Femto CLI himself if needed. And activate Femto using a Femto: true in the Fable config for example.

If a problem is detected, Femto emits a warning (but Fable doesn't stop) and shows brief instructions about how to solve it

That's where I have a problem. Unless Fable output the warning in the webpack log so the user got the info easily. Because if this is at the beginning it can be out of sight for example, Fable compile more than 60 files in my project and so if it's logged at the beginning I can miss the message.

@Zaid-Ajaj
Copy link
Owner

Thanks @alfonsogarciacaro happy to hear from you, it's been a while 😄

We can publish it as a library but I would need expose the functions that don't log anything to the console and instead generate just the required resolution actions (already there).

There is also the option to include the compiled binaries and call it as an external CLI tool the same way you call Fable but extra information you get back from Femto if #17 (JSON output) is fixed. Another option is to call femto --version to check if the user has it installed globally and instrument it (as a global tool) from Fable... all doable options

The only problem I see now is that compile times will blow up because Femto fetches the npm versions per library from the npm registry to compare the required ranges against the installed ones which takes on my machine 1s - 1.5s per package so it adds up for a large project with many dependencies especially because you don't need to check the dependencies you need every time you compile your app (The counter argument is that you do this only once before starting webpack dev server)

@Zaid-Ajaj
Copy link
Owner

BTW Femto does dotnet restore as part of project cracking too but doesn't log anything to the console about it

@MangelMaxime
Copy link
Collaborator

I discovered today that resolving one package version takes around 0.7 seconds which means if we have 10 packages to will take 7 seconds to complete.

These results are calculated using npm (yarn takes around 0.4 seconds to resolve a package).

So I am not sure if this is a good idea to run Femto from Fable. I think it should be the user who runs femto when he set up/upgrade libraries his deps. Just like it's the user who run paket and yarn|npm.

@Zaid-Ajaj
Copy link
Owner

@alfonsogarciacaro Any feedback on this issue? I agree @MangelMaxime that it is probably not a very good idea to run femto on every compilation and that running it by hand will most likely be the easiest route (now even easier with femto install <package> and femto uninstall <package> )

@alfonsogarciacaro
Copy link
Contributor Author

Yeah, if it's going to make the build slower and the warnings can easily get out of sight probably it's not worth it. I'll close the issue, thanks a lot for your answers!

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

3 participants