Just stumbled across your post about this repo, so here are my 2 cents:
If you don't mind using VM specifics (i.e. v8 specifics, might not work out of the box with chakra for example), you can use internal stack properties to get the file path of the caller.
By now there are multiple implementations utilizing this, where the most used is callsites, followed by stack-trace.
Might not be the best solution in terms of performance (tbh: no clue), but for just "shimming" the JSON requires on start-up time, it should be sufficient.
This is pretty interesting, and I'll check that how this may be implemented in a module; callsites looks promising, but I like that stack-traces allows for error handling.
Just stumbled across your post about this repo, so here are my 2 cents:
If you don't mind using VM specifics (i.e. v8 specifics, might not work out of the box with chakra for example), you can use internal stack properties to get the file path of the caller.
By now there are multiple implementations utilizing this, where the most used is
callsites
, followed bystack-trace
.Might not be the best solution in terms of performance (tbh: no clue), but for just "shimming" the JSON requires on start-up time, it should be sufficient.