Open RedMser opened 4 years ago
I'm not sure how I feel about using sexy-require (overriding require sounds like a meh solution), an easier solution could just be to define a global "absolutePath" and use it like that:
require(`$(global.rootPath)/core/models/guild.js`);
Or may create a global "requireAbsolute" function?
It is possible to override require() so that absolute paths work. It still allows for a relative and node_modules syntax like normal, but additionally allows a prefixed slash for absolute paths (starting at project root).
We would need to decide whether all places should use that syntax, or only where
../../../../
makes code unreadable. I would additionally be fine with rewriting the linked library, as it seems a bit inefficient and includes additional syntax that we might want to think twice about.It also needs to be well-documented in our code style rules, potentially even enforced via custom eslint rule (if we decide to use it everywhere possible).