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

Split pow project into 2 projects (one for ecto stuff, other to the rest) #603

Open
sezaru opened this issue Feb 26, 2021 · 4 comments
Open

Comments

@sezaru
Copy link

sezaru commented Feb 26, 2021

Phoenix allows us to create a project with or without Ecto support, the idea is that if you can better separate your project into multiple libraries. This is exactly what I do, I have a BusinessDB library that contains all about my business database, including the user's table which I use pow helper functions to create its fields.

This project is used in multiple other projects, some of them have the Phoenix framework, and some not. But since pow itself depends on phoenix, all these projects end up with phoenix as a dependency too.

This doesn't have any problems, but it is annoying since the release will be bigger and I will receive runtime warnings like this one:

warning: Phoenix now requires you to explicitly list which engine to use
for Phoenix JSON encoding. We recommend everyone to upgrade to
Jason by setting in your config/config.exs:

    config :phoenix, :json_library, Jason

And then adding {:jason, "~> 1.0"} as a dependency.

If instead you would rather continue using Poison, then add to
your config/config.exs:

    config :phoenix, :json_library, Poison

  (phoenix 1.5.7) lib/phoenix.ex:38: Phoenix.start/2
  (kernel 7.2) application_master.erl:277: :application_master.start_it_old/4

So I was wondering what would be your opinion to split pow into 2 projects, pow_ecto and pow.

pow_ecto would contain all Ecto dependencies, functionality, queries, and helper functions.
pow would contain all the rest and would depend on pow_ecto.

That way I would be able to make BusinessDB depend on pow_ecto instead of pow and not have phoenix as a dependency.

@danschultzer
Copy link
Collaborator

Sorry for the late reply, I'm swamped with work, recently became a father, and a lot of other life events. Trying to get as much done on Pow as I can in my limited free time, and can't wait till this period is over to get back at a 100% with open source 😄

This is an excellent question! From the very beginning I was experimenting with automatically compile only as needed files since this is a very large project: #2

I would love to cut down both compile time and have zero dependencies if you don't need them in your project. I think I didn't get it to work properly in umbrella projects, and also wasn't sure if it was wise to do it that way. I will take another look at it, but seeing how core elixir libraries usually set up, your suggestion makes the most sense. Just got this preference for the OTP style of having most everything packed in, rather than a lot of dependencies.

Please feel free to take a stab at it if you'd like. I'm not sure when I'll have proper time to take a look at this, so I would appreciate any help to get this rolling. It shouldn't be too difficult to separate into two libraries, but if going down this path, then I think it should be separated into all the three main groups, ecto, phoenix, and plug.

@sezaru
Copy link
Author

sezaru commented Mar 25, 2021

Hey @danschultzer, thanks for the response.

I do have an interest in trying something like this. But I gonna be honest with you, it is not something I will be able to do very soon, I'm preparing to launch my startup so I too don't have too much free time.

But if it is ok with you, we can keep this issue open and then tackle it later when I have more free time.

@arnimikelsons
Copy link

Congratulations on becoming a father. I hope all is well.

@zachdaniel
Copy link

Some Ash (https://www.ash-elixir.org/) users have expressed interest in using Pow backed by Ash resources, and while I haven't looked overly deeply into the project, I think Pow could very likely end up being the de facto authentication tooling for Ash, via an ash_pow extension. One user (@simpers) has started the work to implement this, and progress has stalled primarily because of this lack of separation. In addition to the changes listed above, this would require that pow not depend on pow_ecto, but rather push that dependency onto the user. In the same way that there is ecto and ecto_sql and in order to use ecto with postgres you use both dependencies in your application. I think that myself or other Ash users would be interested in making PRs to this effect, but I want to make sure it aligns with your vision of things @danschultzer.

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

4 participants