Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize file URLs to paths? #27

Closed
silverwind opened this issue Jun 10, 2021 · 3 comments
Closed

Normalize file URLs to paths? #27

silverwind opened this issue Jun 10, 2021 · 3 comments

Comments

@silverwind
Copy link
Contributor

silverwind commented Jun 10, 2021

Node 16 uses file:// URLs in stack traces, I wonder whether this module should attempt to normalize these to file system paths using fileURLToPath to shorten the output and keep it consistent with previous node versions.

Error: Some error message
    at myFunction (file:///path/to/file.js:356:45)
    at Array.map (<anonymous>)
    at myOtherFunction (file:///path/to/file.js:386:45)
    at runMicrotasks (<anonymous>)

Not directly related but runMicrotasks seems also something this module could hide.

@sindresorhus
Copy link
Owner

Do you know why they changed it? Normal paths would look better and also be Command-clickable in many terminals. Maybe worth opening an issue on Node.js on this first?

@bmeck
Copy link

bmeck commented Aug 18, 2021

@sindresorhus those URLs show up in ESM based modules since ESM doesn't necessarily come from a file; CJS only uses file paths to define their location when telling V8 where the source text lives, but full URLs are used for ESM so V8 shows the full URL in Error stacks.

@silverwind
Copy link
Contributor Author

silverwind commented Aug 18, 2021

I guess it's fine to leave the file URLs, it's closer to browser APIs and I see a general movement towards URLs for filesystem operations in the ecosystem too, reinforced by the ESM loader dealing only with URLs itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants