-
Notifications
You must be signed in to change notification settings - Fork 30k
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
import.meta.resolve(…)
is documented to return a string, but returns a URL
object
#49695
Comments
Yes, this is a bug, thank you for flagging it. |
I think it should match deno / browsers behavior and return a url string. |
Ugh much as it pains me, it is spec'ed to return a url string. Not what anybody wanted, but it is what it is. Maaaybe something else coming. |
all the fuzz in #48994 is really only about Personally, I would consider switching away from using |
Sure, do you want to open an issue on https://github.com/wintercg/proposal-common-minimum-api/ to propose something? Or to just start a discussion. |
Already did: wintercg/proposal-minimum-common-api#5 |
Looking good on nightly! > ./node /tmp/test.mjs
21.0.0-nightly202309229718a9465c
file:///private/tmp/rel |
Also looking good in > echo "console.log(process.versions.node); console.log(import.meta.resolve('./rel'));" > /tmp/test.mjs
> node /tmp/test.mjs
20.8.0
file:///private/tmp/rel |
…node` 20.6. This was previously available: - returning a `Promise`, - behind a flag, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - synchronous, - unflagged without a parameter, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node` 20.6. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node`. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node`. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node`. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node`. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node`. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
…node`. This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (nodejs/node#49695).
PR-URL: nodejs#49698 Fixes: nodejs#49695 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
PR-URL: nodejs#49698 Fixes: nodejs#49695 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
PR-URL: nodejs/node#49698 Backport-PR-URL: nodejs/node#50669 Fixes: nodejs/node#49695 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
PR-URL: nodejs/node#49698 Backport-PR-URL: nodejs/node#50669 Fixes: nodejs/node#49695 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
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:
The following prints a
URL
object:(
import.meta.resolve('./rel')) instanceof URL
also evaluates totrue
.)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 likebun
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
The text was updated successfully, but these errors were encountered: