Repository navigation
feat: decouple @bazel/worker from rules_typescript - #2918
Conversation
e762d0c to
1f6b904
Compare
|
I would like to hear your thoughts and the points that I should improve |
|
The variations of TS generation for .proto files is pretty confusing for sure. I like the comparison table on the bottom of your readme. https://github.com/thesayyn/protoc-gen-ts#alternatives However you only use it as a build-time dependency within our repo to generate those files, not a runtime dependency for our users, so the bar is a lot lower on stability. We'll very rarely change the worker_protocol.proto so we'll rarely need to run the tool. If your repo disappears we could find another generator, or worst case we could edit the files by hand if a field or two gets added to the worker_protocol.proto in the future. The bigger concern to figure out first is if this is a breaking change, then we can't land it yet. I'd rather not start a 5.x branch yet since I'll have to cherry-pick and manage two branches for 6 months until the next major - usually we only start that process a couple months before the release. So I guess we'd like to explore how to make this non-breaking. Either by restoring back-compat or distributing it alongside the existing implementation. |
|
Hmm, then I would vote that we make this non-breaking change and make this reflect the current API. Once we land this, I could send another PR which we could get landed in the next major release. I will send another commit to restore backward compatibility. |
|
Some of the tests are failing. will pick them tomorrow |
|
Now some packages (those have worker support) have a direct dependency on |
|
@alexeagle I would very much appreciate your thoughts on how I could make these packages depend on the worker package and make the tests pass |
|
I'm on mobile, but check the examples/BUILD file? |
|
Unfortunately |
c979d9f to
ab116a4
Compare
bc316cf to
30fe075
Compare
30fe075 to
0bdb75d
Compare
|
@alexeagle ready for a review. and got all the tests passing |
| "devDependencies": { | ||
| "@types/node": "12.12.50", | ||
| "protobufjs": "6.10.1", | ||
| "google-protobuf": "^3.6.1", |
There was a problem hiding this comment.
if the example has to change, that means it's a breaking change...
There was a problem hiding this comment.
I have no clue how I can make this non-breaking change... may be you have something on your mind.
There was a problem hiding this comment.
also, I have no idea why this was needed in the first place. Shouldn’t rules_nodejs list this as a dependency even if the repository is consumed from the source?
I only added this because the tests were yelling at me
I believe that the problem lies somewhere else.
There was a problem hiding this comment.
Shouldn’t this be handled by rules_nodejs_dev_dependencies? perhaps something similar? as I don’t rely on the consumer's npm repository, I don’t see why this should be listed as a dependency by the consumer.
There was a problem hiding this comment.
rules_nodejs_dev_dependencies is only for when you want to consume our rules from source. normal users shouldn't need it. but since this is the examples/from_source it actually does make sense here
There was a problem hiding this comment.
should I add it to this example? or shall we make separate PR for this?
There was a problem hiding this comment.
sorry it was my mistake, as it's building rules_nodejs from source it's expected that our dev dependencies leak through. So far we have the rules_nodejs_dev_dependencies for starlark dependencies, but we don't have anything for npm dependencies (in theory it should be the root package json but we don't actually publish @bazel/javascript we treat it as private)
There was a problem hiding this comment.
Hmm. That’s what I was expecting. so is this okay to have this change?
| @@ -0,0 +1,333 @@ | |||
| /** | |||
| * Generated by the protoc-gen-ts. DO NOT EDIT! | |||
There was a problem hiding this comment.
if you're going to check in a generated file, we should at least have a test that asserts it's up-to-date
how hard is it to leave the generated file in bazel-out and not check in as a source file?
There was a problem hiding this comment.
there are some reasons behind this
- have IDE recognize the file
- somehow rules_proto does not work on windows. it throws an error with a message "bazel-out is not an external or internal command" which probably has something to do with how rules_proto tries to invoke protoc. so the windows tests are going to fail. I have seen it before.
- generating this file every time is not an option since ts_project won’t pick it up. it might create cycling dependency between worker and typescript package since they are relying on each other to build (not sure though)
I would prefer to add a generated_file_test and make an assertion. this test would be disabled on windows though because of the problem I have described above.
There was a problem hiding this comment.
generated_file_test (or bazel_skylib diff_test) with a windows CI exclusion SGTM
There was a problem hiding this comment.
also the comment up here should include the bazel run command that updates the file content (in the unlikely case that worker_protocol.proto changes)
There was a problem hiding this comment.
have the assertion test in place: //packages/worker:copy_worker_protocol
There was a problem hiding this comment.
I couldn’t put the update command comment into the generated file. the assertion fails. so instead I put it into the build file. I hope that's fine
alexeagle
left a comment
There was a problem hiding this comment.
looking really close :)
| @@ -0,0 +1,333 @@ | |||
| /** | |||
| * Generated by the protoc-gen-ts. DO NOT EDIT! | |||
There was a problem hiding this comment.
generated_file_test (or bazel_skylib diff_test) with a windows CI exclusion SGTM
| @@ -0,0 +1,333 @@ | |||
| /** | |||
| * Generated by the protoc-gen-ts. DO NOT EDIT! | |||
There was a problem hiding this comment.
also the comment up here should include the bazel run command that updates the file content (in the unlikely case that worker_protocol.proto changes)
|
I believe that this is ready for another review. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
@bazel/workeruses an old version of bazel worker protocol and coupled withrules_typescriptwhich is not maintained anymore.Since the used protocol is old, it lacks some of the new features such as
cancellationandmultiplex-workers.Issue Number: #1306
What is the new behavior?
protoc-gen-ts.google-protobuf.cancellationbut we have to introduce some breaking changes such asrunOneBuildreturning a cancel callback to handle the cancellation and taking a callback argument to call when the task is complete. similar to what we see on bundlers like webpack and rollup.consoleis passed torunOneBuildcallback to let the consumer have an API to write debug messages and feel right at home.Does this PR introduce a breaking change?
Other information
the new protocol file is generated by using protoc-gen-ts which is mostly maintained by me and a few open source contributors hence I am not sure if you would like to rely on a third-party project. might be a deal-breaker for you.
additionally, in this PR I have only changed things to make room for the incoming support for multiplex workers.