There's a proposal on stage 2 to add a "function hiding" directive:
https://github.com/tc39/proposal-function-implementation-hiding. That would allow library authors to hide implementation details of internal functions and classes, and it has some benefits (described in the proposal). This proposal also has a side-effect of making observability tools less accurate, and it could hide bugs in libraries where the functions are hidden, making it harder to detect those bugs in production. Tools like
Sentry would become less valuable in these scenarios.
Stripping out the directive from libraries with a tool like babel could be possible, but many Node.js applications don't use those tools.
If the proposal goes to Stage 3, would it be possible to have a flag (or maybe an API) on V8 to bypass that directive, so that Error.prototype.stack and Error.prototype.captureStackTrace would show the original stack trace instead of the redacted one? A flag would probably be more appropriate and performant. If the V8 team is open to have this flag but is not interested/doesn't have the bandwidth to implement it, I'd be happy to help.