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

package.json bin #1

Open
boopathi opened this issue Apr 27, 2016 · 4 comments
Open

package.json bin #1

boopathi opened this issue Apr 27, 2016 · 4 comments
Labels

Comments

@boopathi
Copy link

boopathi commented Apr 27, 2016

If the package has a CLI that uses ES6 imports, how should we declare that the CLI is ES6 module ?

"bin.module": {} or "module.bin": {}

or, should the "modules.root" take care of that internally, how should that work?

Update:

Also, for node --module cli.js, one can simply specify - #!/usr/bin/env node --module and execute that as ./cli.js.

But if you run node cli.js it would be script mode instead of module mode and would throw.

@bmeck
Copy link

bmeck commented Apr 27, 2016

bins are symlinked, the module system still eventually resolves it to an absolute path. From there you can find the package.json. A bin to support both CJS and ES entry would most likely look like:

// bin/app.js
require('../');

and in the case of this proposal the package.json would route to the proper place.

@caridy
Copy link
Collaborator

caridy commented Apr 27, 2016

@boopathi as @bmeck said, this is not a problem, the resolution process proposed here handles that case.

@wycats
Copy link
Collaborator

wycats commented Apr 27, 2016

@caridy @bmeck not all bins are symlinked directly to a .js file; it's not that uncommon to create bins that just use the shebang line and require the destination file (for example bower: https://github.com/bower/bower/blob/master/bin/bower).

We could simply disallow bins that aren't symlinked that are standard modules, and this seems necessary for the file extension approach. In the package.json approach, we could use the same rules for bins as we use for other modules ("if there is only module, treat bins as standard modules, otherwise use modules.root or modules")

@jdalton
Copy link

jdalton commented Jun 8, 2016

A note to clarify bin usage should be added to the proposal.

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

No branches or pull requests

5 participants