node-express-boilerplate icon indicating copy to clipboard operation
node-express-boilerplate copied to clipboard

Proposal: let's use `rfr`

Open fernandocanizo opened this issue 3 years ago • 4 comments

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 avatar Apr 26 '21 22:04 fernandocanizo

@fernandocanizo sounds like a great idea. I like it!

How about requirejs? Doesn't it provide a similar feature?

hagopj13 avatar Jul 04 '21 09:07 hagopj13

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)

abernh avatar Oct 19 '21 11:10 abernh

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 ;)

abernh avatar Oct 19 '21 12:10 abernh

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" ] }

getdir avatar Mar 17 '22 07:03 getdir