-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
esm: make specifier flag clearly experimental #30678
esm: make specifier flag clearly experimental #30678
Conversation
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented.
/cc @nodejs/modules |
I believe that not having this flag prefixed by |
13f726a
to
db9f3ec
Compare
It now gives a reasonable warning if you attempt to use both flags at the same time. |
--> | ||
|
||
Sets the resolution algorithm for resolving ES module specifiers. Valid options | ||
are `explicit` and `node`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're changing the name I wonder if it might make sense to change the name of the extension searching resolution to --experimental-specifier-resolution=legacy
or --experimental-specifier-resolution=compat
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe --experimental-specifier-resolution=require
to make it obvious what it is emulating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure there was some distaste towards the implication that the flag was for legacy compatibility - the flag exists to test an alternative that could be a viable way forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would --experimental-specifier-resolution=detect
capture the semantics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to go with what we have though, and have approved the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require
or commonjs
or detect
all would be acceptable to me; legacy
would not. (leaving it as "node" is also fine ofc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errr, if you want a new name, why not implicit
to mirror explicit
?
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
I don't think we should be changing the values. It might not be ideal, but
at least this PR should be non disruptive as it is backwards compatible.
If we are going to change the values I think it would make sense to do
before officially supporting the feature if we go that route
…On Wed, Nov 27, 2019, 5:57 PM Guy Bedford ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In doc/api/cli.md
<#30678 (comment)>:
> @@ -223,6 +209,20 @@ added: v13.1.0
Enable experimental support for a package using `require` or `import` to load
itself.
+### `--experimental-specifier-resolution=mode`
+<!-- YAML
+added: REPLACEME
+-->
+
+Sets the resolution algorithm for resolving ES module specifiers. Valid options
+are `explicit` and `node`.
I'm happy to go with what we have though, and have approved the PR.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30678?email_source=notifications&email_token=AADZYV5JYOO6HN3EQYGNGILQV33PJA5CNFSM4JSDAMT2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCNHZH6Q#discussion_r351528532>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADZYV7DUJZJKOUAA37IFZ3QV33PJANCNFSM4JSDAMTQ>
.
|
We could document / support a new name but keep the old name "node"
supported but undocumented. Thoughts?
I like implicit
…On Wed, Nov 27, 2019, 7:07 PM Wesley Wigham ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In doc/api/cli.md
<#30678 (comment)>:
> @@ -223,6 +209,20 @@ added: v13.1.0
Enable experimental support for a package using `require` or `import` to load
itself.
+### `--experimental-specifier-resolution=mode`
+<!-- YAML
+added: REPLACEME
+-->
+
+Sets the resolution algorithm for resolving ES module specifiers. Valid options
+are `explicit` and `node`.
errr, if you want a new name, why not implicit to mirror explicit?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30678?email_source=notifications&email_token=AADZYV62DIZJP5ROWMJ74U3QV4DS3A5CNFSM4JSDAMT2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCNH5FNI#discussion_r351542524>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADZYVZT5PUIS7BO7RQG5ITQV4DS3ANCNFSM4JSDAMTQ>
.
|
implicit/explicit sounds great to me. |
I would just keep If anything I would just call the flag |
e6af0a6
to
118171c
Compare
I've fixed up broken tests I think this should be good to go @GeoffreyBooth do you really think we need such a verbose flag? Especially since we are adding "experimental" I think it makes sense tot have the flags be slightly different |
--> | ||
|
||
Sets the resolution algorithm for resolving ES module specifiers. Valid options | ||
are `explicit` and `node`. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -110,10 +110,14 @@ function resolve(specifier, parentURL) { | |||
if (ext === '.js' || (!format && isMain)) | |||
format = getPackageType(url.href) === TYPE_MODULE ? 'module' : 'commonjs'; | |||
if (!format) { | |||
if (esModuleSpecifierResolution === 'node') | |||
if (experimentalSpeciferResolution === 'node') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we emit the warning on the use of the flag or only when it is active?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to prefer the pattern in general of having the warning on first use of the feature. That's what we're looking at doing for the other experimental modules features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem is this might not catch all usage though - because we have branches in the C++ resolver which check this which may not still catch this path (this path is specifically for non JS file extensions).
So we should either bring the warning to the C++ code, or we should make it a general warning on startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is getting the warning into C++ layer blocking this from landing or should we do it in a follow up?
&EnvironmentOptions::experimental_specifier_resolution, | ||
kAllowedInEnvironment); | ||
AddOption("--es-module-specifier-resolution", | ||
"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact, leaving no description on a flag stop it from printing when you run node -h
MAGIC!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably adopt the same for the aliasing of --experimental-loader
and --loader
actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an alias, shouldn't it be using AddAlias()
rather than AddOption()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally implemented it that way but couldn't figure out how to enforce behavior that both the alias and the actual command couldn't be used at the same time
Ended up manually implemented this here.
There was weird behavior depending on the order of arguments, so I opted to do this instead of hunting down how to get the same behavior as an alias. Is there a better way to do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally implemented it that way but couldn't figure out how to enforce behavior that both the alias and the actual command couldn't be used at the same time
Ended up manually implemented this here.
There was weird behavior depending on the order of arguments, so I opted to do this instead of hunting down how to get the same behavior as an alias. Is there a better way to do it?
¯\_(ツ)_/¯ cc @addaleax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally implemented it that way but couldn't figure out how to enforce behavior that both the alias and the actual command couldn't be used at the same time
I guess we could add a special kind of alias for this, but … why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, I think this could use at least Implies()
to clarify the relation between the two options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If y'all are happy with just shipping this as is, it is a one off and something that will eventually get removed.
Windows CI rebuild: https://ci.nodejs.org/job/node-test-commit-windows-fanned/31952/ |
Landed in ee953d8 |
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: #30678 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: #30678 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: #30678 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: #30678 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
--es-module-specifier-resolution
is the only flagged portion of theESM implementation that does not have the word experimental in the flag
name. This commit changes the flag to:
--experimental-specifier-resolution
--es-module-specifier-resolution
remains as an alias for backwardscompatibility but it is no longer documented.
There is a failing test with this PRtest/es-module/test-esm-specifiers-both-flags.mjs
. There is not yet handling to ensure both flags can't be used at the same time... unsure the best way to do this with the alias.It does fail with the wrong message though, and doesn't fail when arguments are in the opposite direction. This might be an unrelated bug in the options parser.