Adding a package involves an seemingly unnecessary step of adding it to the providers / aceProviders array inside start/app.js. This is currently part of the documentation of every single package.
It doesn't serve any real purpose since it can not even be used to verify if a package is actually being used or not (because it is usually aliased).
Proposal
It should be sufficient to install a package, without having to add it to the providers arrays.
How will providers be identified?
The module (provider package) needs to have the following section in "package.json"
Adonis-slim, adonis-api and adonis-fullstack receive a new script in package.json "postinstall": "node ace autodiscovery".
This makes use of npm's hooks and will automatically run after npm install. Alternatively, It can be added to adonis install to avoid adding the scripts, but I think there are many people who are used to doing npm install instead.
node ace autodiscovery will look into each package found in package.json and find all the identified providers (those that have an "adonisjs" key)
It will save the result in a gitignored file ./start/discovered-providers.json
when starting the server, adonis-framework (src/Ignitor/Bootstrapper.ts) will search in the json file from step 3 and register the providers automatically
The straight forward way
Identify the packages dynamically when starting the server. This takes approximately 100 ms on my windows machine on a project with 50 dependencies. The change requires low effort but will definitey slow down server start up time, which might be annoying during development.
Questions
What about nested packages?
Including nested packages has more drawbacks than benefits
Way more expensive operation
Looking at an installed package makes it unclear which providers get registered
What problem does it solve?
Adding a package involves an seemingly unnecessary step of adding it to the providers / aceProviders array inside start/app.js. This is currently part of the documentation of every single package. It doesn't serve any real purpose since it can not even be used to verify if a package is actually being used or not (because it is usually aliased).
Proposal
It should be sufficient to install a package, without having to add it to the providers arrays.
How will providers be identified?
The module (provider package) needs to have the following section in "package.json"
What is the process of autodiscovery?
There are two approaches
The performant way
"postinstall": "node ace autodiscovery"
. This makes use of npm's hooks and will automatically run afternpm install
. Alternatively, It can be added toadonis install
to avoid adding the scripts, but I think there are many people who are used to doingnpm install
instead.node ace autodiscovery
will look into each package found in package.json and find all the identified providers (those that have an "adonisjs" key)./start/discovered-providers.json
The straight forward way
Questions
What about nested packages?
Including nested packages has more drawbacks than benefits
Relevant links
Are you willing to work on it?
Yes