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

feat: decouple plugins from framework. #22

Open
brent-hoover opened this issue Jun 17, 2024 · 3 comments
Open

feat: decouple plugins from framework. #22

brent-hoover opened this issue Jun 17, 2024 · 3 comments
Assignees
Labels
tech-debt Just my catch-all term for work that makes the app better but doesn't add a user feature

Comments

@brent-hoover
Copy link
Contributor

Right now your plugins need to be in a very specific place in the structure of the project for them to work. Most people using a framework will want to keep their custom plugins separate from the framework code. A couple of issues now:

  1. Global imports of things like logger and GlobalContext are done through explicit path. Is there some way to do a type of virtual package where these can all be imported from @phoenix/phoenix-framework?

  2. Right now it iterates over the plugins directory, but it should be able to import these from anywhere. The optimal setup from a developers perspective is that their custom code can live in a completely different repository. Reaction solved this with having npm packages but this was always a difficult solution as it involved either publishing packages to your own private npm or github, or using something like pnpm to have "virtual" packages.

Should spend some time looking at what other people are doing since this is a pretty critical feature. At some point will probably involve publishing a package that can be imported from and that each plugin just needs to call a "register" function.

@brent-hoover brent-hoover added the tech-debt Just my catch-all term for work that makes the app better but doesn't add a user feature label Jun 17, 2024
@brent-hoover
Copy link
Contributor Author

I am going spend a little more time investigating what other frameworks do but I think the approach will be essentially what we ended up with RC.

We create an cli app that can:

  1. Create a skeleton app
  2. Create an example app (this will be our commerce app)
  3. Skeleton out a plugin

The framework package will import a "register" function that they will pass everything into (models, etc). In each app will be a pluginloader that iterates over all the plugins and calls their index and in the index they will call the register function. This will be like the 25 line loader in the RC app so none of that logic lives in the app, but in the framework

Possibly I can use my work on the RC cli app.

Also it's going to be time to think of a better name for the package than phoenix-framework although I suppose while no one is using it it doesn't really matter

Not sure what makes the most sense if we want to go with a monorepo approach and have both the cli app and package in this repo or if it's just simpler to keep them separate. Again, I will spend a little more time investigating what other people are doing.

@brent-hoover
Copy link
Contributor Author

I notice that Adonis just uses npm init to init a project rather than having to install a cli. Also I noticed that expressoTS also is Bun compatible.

@brent-hoover brent-hoover self-assigned this Jul 6, 2024
@brent-hoover
Copy link
Contributor Author

brent-hoover commented Jul 6, 2024

@aldeed This is the thing I will work on next, would like to get your thoughts

Also any thoughts on how to best structure the repo to possibly keep the CLI, the template app and the main framework that will be published as a package all in the same repo?

Also might want to move the Event System and the RBAC to separate plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Just my catch-all term for work that makes the app better but doesn't add a user feature
Projects
None yet
Development

No branches or pull requests

1 participant