Hi @virk and @romain.lanz, sorry to bother you.
I know IoC Container is very powerful but it breaks the nature programming style of NodeJs, especially we lost IDE type hint cause we using
use() function instead
I’m trying my best to find a way to keep my development joy during working with AdonisJs, so there is my solution and hope you could give me some advices
How to Use
jsconfig.json to make vscode could give us path autocompletion and type hint, just like to
require other libraries.
module-alias package to make
require() resolver happy
npm i --save module-alias
"App" : "./app"
require('module-alias/register') to the top of
It works! Just try like this:
const User = require('App/Models/User')
const cat = await User.query().first()
If you don’t want to change all of your
require(), just add
const use = require to your
/server.js. It works but I not sure if it is the right way to do.
Thanks for your patient
If you think it’s useful, please consider to use custom
require resolver to rewrite IoC Container based on native
require() function. I think it will make AdonisJs more elegant and also make us happier.