-
-
Notifications
You must be signed in to change notification settings - Fork 19
Warn about --type with shebang
#37
Conversation
Refs: nodejs/modules#180 PR-URL: #6 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: nodejs/modules#180 PR-URL: #6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: nodejs/modules#180 PR-URL: #6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: nodejs/modules#180 PR-URL: #6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
PR-URL: #6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
PR-URL: #6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
4514848 to
968c8f1
Compare
|
@jkrems can you please rebase |
Follow-up to #35
744065f to
12905b0
Compare
|
Applied on top of latest |
|
i'd word this a little bit stronger. using arguments in hashbangs is something that should be avoided in general. |
| Works with stdin, `--eval`, `--print` as well as standard execution. | ||
| Works with stdin, `--eval`, `--print` as well as standard execution | ||
| when envoking `node` explicitly. | ||
| Does not work reliably when running via shebang (`#!/usr/bin/env 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 perhaps (like io.js provided both iojs and node binaries) node provide a node-esm or similar binary, so they can use that in the shebang instead?
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.
Yeah, I assume that'll be where it's heading. The question would be: Would this make a better general command / should it replace node as the "default" binary people would run?
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.
Only if they're invoking node on an extensionless ESM file - if the file has an extension, or if it's CJS, then node would still be preferred.
Since package.json bins can have extensions, this really only affects executable one-off ESM scripts, which won't be the majority (but are still an important use case)
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.
Right, but if node-esm always works (after porting your code to ESM) and node works most of the time - why would you ever tempt fate and use 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.
i wouldn't bet on another binary for this --mode option, given opposition to the design of the option, and the weight of an extra binary for very little configuration.
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.
@jkrems it wouldn't work on CJS files, and i'd expect it to throw if you tried to run with --type=esm on a file that had a non-esm file extension - the better question would be why would you tempt fate and use the alternative :-)
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.
How about something like:
| Does not work reliably when running via shebang (`#!/usr/bin/env node`) | |
| Note that this flag is not a reliable solution for shebang scripts (`#!/usr/bin/env node -m`) due to multiple arguments not being supported in POSIX environments. |
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.
it'd be anything that respects exec(3), so most POSIX platforms
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.
Sure, updated to posix.
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.
Feel free to update the commit directly. This PR is just me suggesting a fix to an earlier PR, I don't have any personal attachment to the exact wording. :)
0dbed6b to
621a632
Compare
621a632 to
d89e9ee
Compare
d89e9ee to
22339db
Compare
b84c079 to
a4955e2
Compare
a4955e2 to
7c92011
Compare
9301a06 to
e721cd2
Compare
484d1fb to
7efc53d
Compare
c7fa700 to
d69f765
Compare
335d584 to
9a343ce
Compare
3a00b51 to
bc101f6
Compare
fd5b55a to
3a40599
Compare
6fe40a4 to
d9cdfd8
Compare
|
I think this is no longer relevant now that we no longer have a flag that applies to files? |
|
Correct, closing! :) |
Follow-up to #35
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes