Description
Version
v20.6.1
Platform
Darwin Germain.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
https://nodejs.org/api/esm.html#importmetaresolvespecifier states:
Returns:
<string>
The absolute (file:) URL string for the resolved module.
The following prints a URL
object:
echo "console.log(process.versions.node); console.log(import.meta.resolve('./rel'));" > /tmp/test.mjs
node /tmp/test.mjs
(import.meta.resolve('./rel')) instanceof URL
also evaluates to true
.)
How often does it reproduce? Is there a required condition?
N/A
What is the expected behavior? Why is that the expected behavior?
The documentation and the behaviour match.
All browsers and deno
return a string, and it sounds like bun
would also prefer this. I don't feel strongly myself, although I feel matching browsers would be less surprising if I was learning the API from scratch — it's always possible translate between formats if needed, but the ecosystem benefits from consistent type signatures in several ways.
See #48994 for a related discussion about API ergonomics.
What do you see instead?
The documentation and behaviour mismatch.
Additional information
No response