{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/rules_nodejs/issues/362","repository_url":"https://api.github.com/repos/bazelbuild/rules_nodejs","labels_url":"https://api.github.com/repos/bazelbuild/rules_nodejs/issues/362/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/rules_nodejs/issues/362/comments","events_url":"https://api.github.com/repos/bazelbuild/rules_nodejs/issues/362/events","html_url":"https://github.com/bazelbuild/rules_nodejs/issues/362","id":368430186,"node_id":"MDU6SXNzdWUzNjg0MzAxODY=","number":362,"title":"[Suggestion] adding support for npm_run / yarn_run","user":{"login":"UlysseM","id":4748171,"node_id":"MDQ6VXNlcjQ3NDgxNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/4748171?v=4","gravatar_id":"","url":"https://api.github.com/users/UlysseM","html_url":"https://github.com/UlysseM","followers_url":"https://api.github.com/users/UlysseM/followers","following_url":"https://api.github.com/users/UlysseM/following{/other_user}","gists_url":"https://api.github.com/users/UlysseM/gists{/gist_id}","starred_url":"https://api.github.com/users/UlysseM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UlysseM/subscriptions","organizations_url":"https://api.github.com/users/UlysseM/orgs","repos_url":"https://api.github.com/users/UlysseM/repos","events_url":"https://api.github.com/users/UlysseM/events{/privacy}","received_events_url":"https://api.github.com/users/UlysseM/received_events","type":"User","site_admin":false},"labels":[{"id":674339028,"node_id":"MDU6TGFiZWw2NzQzMzkwMjg=","url":"https://api.github.com/repos/bazelbuild/rules_nodejs/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-10-09T22:56:01Z","updated_at":"2018-10-24T17:48:56Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi,\r\n\r\nI mentioned during the bazelcon the usecase of porting existing package.json workflow to bazel, when it's necessary to hook output files into the bazel pipeline, without spending much time on maintaining or refactoring old legacy code.\r\n\r\nOur web team is used to npm scripts that produce some artifacts when running \"npm run build\", and test things using \"npm run test\".\r\n\r\nWhile we used genrule / sh_test to invoke a shell scripts that imports node and npm into $PATH, before running the command, I think it would be beneficial to have it included by default, to ease the migration with some team.\r\n\r\n```\r\nnpm_run(\r\n    name = \"artifacts\",\r\n    srcs = glob([\"srcs/**/*\"]) + [ \"package.json\", \"bower.js\", \"whatever.js\"],\r\n    data = \"@something//:node_modules\",\r\n    cmd = \"build\",\r\n    outs = [ \"dist/js/output.js\", \"dist/css/output.css\")],\r\n)\r\n```\r\n\r\nWould be the same as running:\r\n\r\n```\r\ngenrule (\r\n    ...\r\n    cmd = \" export PATH=path with node and npm:$$PATH && npm run build\",\r\n    outs = [...],\r\n)\r\n```\r\n\r\nAdditionally, there could be another rule such as npm_run_test and yarn_run_test that would be a bazel test rule, and don't take the input as parameter."},"comment":{"url":"https://api.github.com/repos/bazelbuild/rules_nodejs/issues/comments/432761097","html_url":"https://github.com/bazelbuild/rules_nodejs/issues/362#issuecomment-432761097","issue_url":"https://api.github.com/repos/bazelbuild/rules_nodejs/issues/362","id":432761097,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjc2MTA5Nw==","user":{"login":"UlysseM","id":4748171,"node_id":"MDQ6VXNlcjQ3NDgxNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/4748171?v=4","gravatar_id":"","url":"https://api.github.com/users/UlysseM","html_url":"https://github.com/UlysseM","followers_url":"https://api.github.com/users/UlysseM/followers","following_url":"https://api.github.com/users/UlysseM/following{/other_user}","gists_url":"https://api.github.com/users/UlysseM/gists{/gist_id}","starred_url":"https://api.github.com/users/UlysseM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UlysseM/subscriptions","organizations_url":"https://api.github.com/users/UlysseM/orgs","repos_url":"https://api.github.com/users/UlysseM/repos","events_url":"https://api.github.com/users/UlysseM/events{/privacy}","received_events_url":"https://api.github.com/users/UlysseM/received_events","type":"User","site_admin":false},"created_at":"2018-10-24T17:48:55Z","updated_at":"2018-10-24T17:48:55Z","author_association":"CONTRIBUTOR","body":"I think most of the performance impact in my scenario comes from importing @myyarn//:node_modules (especially since bazel is running inside a linux docker container on a mac in our case).\r\nThe copy operation is fairly fast.\r\n\r\nAs for watch, I don't think it would be compatible as it only copies once. Unless you want to watch yourself the work directory and copy the change to the tmpdir where the jest watcher works. Since the watch feature is designed for devs anyway, I'd suggest sticking to the 'npm/yarn' command, and using only bazel for builds / ci?\r\n\r\nThe overall suggestion I'm advocating for is to allow bazel to run scripts that provide the artifacts needed for other bazel rules, as well as allowing test scripts.\r\nIt means that the original 'script' would still be callable by yarn / npm."}}
{"actor":{"display_login":"UlysseM"}}