node-express-boilerplate
node-express-boilerplate copied to clipboard
Proposal: let's use `rfr`
rfr allows to make all requires from the root of the project, reducing the cognitive load by avoiding to have in mind where is a file to realize where a required module lives.
From it's README page:
allows you to require modules in your project with
rfr('lib/module1.js')
instead of something like require('../../lib/module1.js')
I offer myself to make such a change should be the idea accepted.
@fernandocanizo sounds like a great idea. I like it!
How about requirejs? Doesn't it provide a similar feature?
Here is a little listing of different options to solve the "confusing path names" problem: https://gist.github.com/branneman/8048520
It concludes with using module-alias - which also has a much better track record and usage in current projects compared to rfr (not actually used) or requirejs (not used anymore)
And then I have to append that even that is now discouraged and the use of nodejs' native import-mapping (since v14.6.0, v12.19.0) is to be used instead (via https://github.com/ilearnio/module-alias/issues/113 )
Constant change. The only thing to be certain of ;)
There's a much simpler way to achieve this...
add jsconfig.json
to your root directory & then...
{
"compilerOptions": { "target": "es6", "baseUrl": "src" },
"include": [ "src" ],
"exclude": [ "node_modules" ]
}