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

Bazel Deprecation #207

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .bazelignore

This file was deleted.

2 changes: 0 additions & 2 deletions .bazelrc

This file was deleted.

1 change: 0 additions & 1 deletion .bazelversion

This file was deleted.

6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ deploy:
cache:
directories:
- node_modules
before_install:
- BAZEL_VERSION=0.28.0
- BAZEL_DEB="bazel_${BAZEL_VERSION}-linux-x86_64.deb"
- wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/${BAZEL_DEB} -O "${BAZEL_DEB}"
- sudo dpkg -i ${BAZEL_DEB}
- rm ${BAZEL_DEB}
install:
- npm install
script:
Expand Down
22 changes: 0 additions & 22 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,22 +0,0 @@
load("@npm_bazel_typescript//:defs.bzl", "ts_config")

package(default_visibility = ["//visibility:public"])

exports_files([
"tsconfig.json",
])

filegroup(
name = "generate_ts",
srcs = [
"//proto:generate",
"//proto/examplecom:generate",
"//proto/othercom:generate",
],
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [],
)
92 changes: 4 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,94 +33,10 @@ npm install ts-protoc-gen@next

### bazel

<details><summary>Instructions for using ts-protoc-gen within a <a href="https://bazel.build">bazel</a> build environment</summary><p>

Prerequisites:
- Setup [rules_nodejs](https://github.com/bazelbuild/rules_nodejs) in your project

Then, include the following in your `WORKSPACE`:

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# NOTE: Setup rules_nodejs

http_archive(
name = "ts_protoc_gen",
# NOTE: Update these values to the latest version
sha256 = "355bd8e7a3d4889a3fb222366ac3427229acc968455670378f8ffe1b4bfc5a95",
strip_prefix = "ts-protoc-gen-14d69f6203c291f15017a8c0abbb1d4b52b00b64",
urls = ["https://github.com/improbable-eng/ts-protoc-gen/archive/14d69f6203c291f15017a8c0abbb1d4b52b00b64.zip"],
)

load("@ts_protoc_gen//:defs.bzl", "typescript_proto_dependencies")

typescript_proto_dependencies()
```

Also make sure you have the following in your `package.json`:

```json
{
"dependencies": {
"google-protobuf": "^3.6.1",
"@improbable-eng/grpc-web": "0.8.0",
"browser-headers": "^0.4.1"
},
"devDependencies": {
"@bazel/karma": "0.27.8",
"@bazel/typescript": "^0.27.7",
"@types/google-protobuf": "^3.2.7",
"typescript": "^3.1.1"
}
}
```

> Run `yarn install` to generate the `yarn.lock` file.

Finally, in your `BUILD.bazel`:

```python
load("@ts_protoc_gen//:defs.bzl", "typescript_proto_library")

proto_library(
name = "test_proto",
srcs = [
"test.proto",
],
)

typescript_proto_library(
name = "test_ts_proto",
proto = ":test_proto",
)
```

You can use the `test_ts_proto` as a `dep` in other `ts_library` targets. However, you will need to
include `google-protobuf`, `@improbable-eng/grpc-web`, and `browser-headers` at runtime yourself. See
`//test/bazel:pizza_service_proto_test_suite` for an example.

#### IDE Code Completion
If you'd like to get code completion working for the generated protos in your IDE, add the following to your `tsconfig.json`:

```
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
# Replace <workspace-name> with the name of your workspace
"<workspace-name>/*": [
"*", # Enables absolute paths for src files in your project
"bazel-bin/*" # Enables referencing generate protos with absolute paths
]
}
}
}
```

> NOTE: This has only been tested in IntelliJ with the bazel plugin

</p></details>
The bazel rules have been moved to a separate project [here](https://github.com/Dig-Doug/rules_typescript_proto).
There is a
[migration guide](https://github.com/Dig-Doug/rules_typescript_proto/blob/master/docs/migrating_from_ts_protoc_gen.md)
for existing users.

## Contributing

Expand Down
39 changes: 0 additions & 39 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,6 @@ workspace(
name = "ts_protoc_gen",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "a95b7f17b0b0e74b02f82ac14da3053d430c1abe99c6727c7abebda3bde3034b",
strip_prefix = "rules_nodejs-0.33.1",
urls = [
"https://github.com/bazelbuild/rules_nodejs/archive/0.33.1.tar.gz",
],
)

load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)

load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

load("@npm_bazel_karma//:package.bzl", "rules_karma_dependencies")

rules_karma_dependencies()

load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")

web_test_repositories()

load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories")

browser_repositories()

load("@npm_bazel_typescript//:defs.bzl", "ts_setup_workspace")

ts_setup_workspace()

load("@ts_protoc_gen//:defs.bzl", "typescript_proto_dependencies")

typescript_proto_dependencies()
13 changes: 0 additions & 13 deletions bin/BUILD.bazel

This file was deleted.

Loading