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

Read through package.json bin entry when resolving entry_point #205

Closed
alexeagle opened this issue May 14, 2018 · 4 comments
Closed

Read through package.json bin entry when resolving entry_point #205

alexeagle opened this issue May 14, 2018 · 4 comments

Comments

@alexeagle
Copy link
Collaborator

This was suggested by some visitor last week (sorry I forgot who)

https://github.com/bazelbuild/rules_nodejs/blob/3a35786d8e78627f9e0783fbf45e1c960eaccdf8/examples/rollup/BUILD.bazel#L16 has an example of our typical pattern: you read the bin entry from the package.json and put that in the BUILD file.
It would be better to point to the package, or the package.json, and let the rule read the package.json to find the bin.
This would make it more robust (in case the bin changes in a new version of the package) and less boilerplate to ask Bazel to run an arbitrary program we fetched from NPM.

@nimerritt
Copy link
Contributor

Please don't make this the only option. package.json files are a NPM concept and not a Nodejs requirement.

@gregmagolan
Copy link
Collaborator

This is related to #302. With #302, yarn_install and npm_install will auto-generated nodejs_binary targets for executables in npm packages such as rollup. For cases where there are no templated_args (like the one referenced in the initial comment), you will be able to use the premade nodejs_binary targets in the form @<workspace>//:<package>/<binary>. For example, with a yarn_install(name = "npm", ...) where the package.json includes rollup, you will get an auto-generated nodejs_binary target @npm//:rollup/rollup

@alexeagle
Copy link
Collaborator Author

@gregmagolan I think we can close this now that we generate nodejs_binary for packages that have a bin in package.json?

@gregmagolan
Copy link
Collaborator

@gregmagolan I think we can close this now that we generate nodejs_binary for packages that have a bin in package.json?

I agree. entry_point is now also a label so you can easily create your own nodejs_binary and point the entry point to your node_modules such as entry_point = "@npm//:node_modules/rollup/bin/rollup"

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

No branches or pull requests

3 participants