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
Fix bazel building #71
Conversation
…ojects to pull in the protoc plugin through bazel
This also indirectly fixes a bug that happens if a Bazel project tries to use this npm package (it has breaking Bazel files and a workspace in it). |
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.
Thank you for raising this PR, whilst we do not yet use bazel for our front end projects at Improbable we do plan to one day, and improvements like the one you have contributed here both strengthen the bazel ecosystem and move us closer to our goal
I've requested the following changes:
-
There are many unrelated changes to the generated example code. Please can you revert these and verify that you are building with protoc 3.2.0.
-
Please can you explain your reasoning behind switching from yarn to npm
-
(Optional) Is there a way to improve the Travis CI build to ensure that the bazel build is generating valid artefacts to avoid mistakes like the one you had to fix?
Thanks again for your contribution
WORKSPACE
Outdated
remote = "https://github.com/bazelbuild/rules_typescript.git", | ||
tag = "0.10.0", | ||
# installs our node_modules | ||
yarn_install( |
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'm a little confused by this rule as ts-protoc-gen does not use yarn to manage dependencies? I'm guessing this rule provides interoperability with npm?
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.
Yes it is interoperable.
The reason for Yarn is because rules_nodejs recommends it.
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.
Can you revert back to npm please
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.
Just pushed the commit to use rules_nodejs' npm_install. Works perfectly! 😝
], | ||
entry_point = "ts_protoc_gen/src/ts_index", |
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.
Whoops, good catch. I'm surprised this didn't fail CI, is there a way we can automatically test for errors like this?
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'm actually surprised it wasn't caught either, not sure why, and I don't really have the resources to tell you why.
The previous change bazel build //...:all
is a good way to ensure bazel builds - it would also end up running tests you eventually create with bazel.
*/ | ||
proto.examplecom.RepeatedPrimitiveMessage.prototype.getMyFloatList = function() { | ||
return /** @type {!Array.<number>} */ (jspb.Message.getRepeatedFloatingPointField(this, 2)); | ||
return /** @type {!Array<number>} */ (jspb.Message.getRepeatedFloatingPointField(this, 2)); |
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.
Which version of protoc are you using? I ask because ideally this generated code should not have changed as it is unrelated to your bazel changes.
Our CI currently uses protoc v3.2.0.
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.
v3.5.1
@@ -35,7 +35,6 @@ | |||
"@types/lodash": "^4.14.106", | |||
"@types/mocha": "^2.2.46", | |||
"@types/node": "^7.0.52", | |||
"@types/text-encoding": "0.0.32", |
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.
👍
generate.sh
Outdated
@@ -6,10 +6,12 @@ set -e | |||
EXAMPLES_GENERATED_DIR=examples/generated | |||
|
|||
echo "Ensuring we have NPM packages installed..." | |||
npm install | |||
# npm install | |||
yarn |
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.
Why the change from npm to yarn?
I have a strong (mostly personal) for this project to remain using npm.
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.
As mentioned earlier, rules_nodejs recommends it.
…uture changes to rules_nodejs as they prefer yarn
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.
🚀
This is awesome, thanks for contributing! |
Changed Bazel to use self managed
node_modules
.Now other Bazel projects can build the
protoc-gen-ts
plugin using Bazel!example use case:
Workspace
Now the
protoc-gen-ts
binary is available using the following Label:@ts_protoc_gen//bin:protoc-gen-ts
This PR will ready the repo for a custom Bazel rule that does most of the heavy lifting.