Ask questionsProposal: Support loading package by own "name"

This has been discussed before, but I think it's a good time to consider it now.

A very common problem in Node.js applications is the backtracking problem where you have to always reference modules through ../../components/name.js.

Since we're loading the package.json when checking the module boundary, we thus also know the package.json "name" that any given module is in.

What we could do is support loading a package by its own package.json "name" by default.

This would allow conventions where users just set a package.json name and can then use import "pkgname/components/name.js" instead.

It's a very small feature that seems like it could solve a pain point quite elegantly.

Would be nice to discuss this further at the next meeting.


Answer questions SMotaal

On second thought, circumventing parent paths to the first "node_module/*" potentially addresses the concern about creep for published packages, specifically.

But can we say for certain that resolving the signifier is always going to be clear cut, or do things like symbolic links, flags… etc. leave potential for complicated edge cases?


Related questions

No questions were found.
Saleh Abdel Motaal SMotaal Mississauga, Ontario, Canada One of those who have perfected the art of fault, the patience to dwell, and to appreciate beauty in uncertain chaos.
Github User Rank List