adonisjs / discussion

Discussing about new features and sharing random thoughts: ⚠️ Not every request will be accepted
51 stars 5 forks source link

Automatically install addons #58

Open assertchris opened 6 years ago

assertchris commented 6 years ago

The new 4.0 slim build is really lean 🎉

Perhaps we could consider automatically installing addons when their usage is detected, for instance:

action({ session, request, response })

We can define a context getter, which installs @adonisjs/session when the server is running in development mode. It could trigger a special exception, which prompts the user to restart what they were doing following a development server reload (as part of installing the addon). Similarly, we could define Edge globals (like csrfField) which automatically install Shield when in development mode.

Similarly, we could install whatever the recommended WS provider is, when someone uses the adonis make:controller SocketController → "For Websocket channel" command.

There are two benefits to this. The first is that developers can see helpful errors for when they are using functionality they haven't installed the providers for. The second is that those providers can automatically be installed for them, in certain situations; making their lives a whole lot easier.