Skip to content

Commit

Permalink
support bazel build
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyi committed Feb 8, 2018
1 parent 087d25e commit 015e27e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.vscode
node_modules
node-debug.log
package-lock.json
.idea/
npm-debug*
lib/
test/ts_test/generated
test/ts_test/build
test/js_test/generated
test/js_test/build
bazel-*
12 changes: 0 additions & 12 deletions BUILD

This file was deleted.

21 changes: 21 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package(default_visibility = ["//visibility:public"])
exports_files(["tsconfig.json"])

# NOTE: this will move to node_modules/BUILD in a later release
filegroup(
name = "node_modules",
srcs = glob(["/".join([
"node_modules",
pkg,
"**",
ext,
]) for pkg in [
"google-protobuf",
"typescript",
"@types",
] for ext in [
"*.js",
"*.json",
"*.d.ts",
]]),
)
18 changes: 12 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
http_archive(
workspace(name = "ts_protoc_gen")

git_repository(
name = "build_bazel_rules_nodejs",
url = "https://github.com/bazelbuild/rules_nodejs/archive/defc6449af919b7388e64467df27ceba95b4a33b.zip",
sha256 = "bbfc7372d92e23e36eabc2530ccfadb2534ec4e35bf51c20894c909895c2f6bb",
strip_prefix = "rules_nodejs-defc6449af919b7388e64467df27ceba95b4a33b",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
tag = "0.4.0",
)

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

node_repositories(package_json = ["//:package.json"])

local_repository(
git_repository(
name = "build_bazel_rules_typescript",
path = "node_modules/@bazel/typescript",
remote = "https://github.com/bazelbuild/rules_typescript.git",
tag = "0.10.0",
)

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

ts_setup_workspace()
22 changes: 22 additions & 0 deletions bin/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")

nodejs_binary(
name = "protoc-gen-ts",
data = [
"@//:node_modules",
"@//src",
],
entry_point = "ts_protoc_gen/src/ts_index",
args = ["--node_options=--expose-gc"],
)

nodejs_binary(
name = "protoc-gen-js_service",
data = [
"@//:node_modules",
"@//src",
],
entry_point = "ts_protoc_gen/src/js_service_index",
args = ["--node_options=--expose-gc"],
)
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@types/google-protobuf": "^3.2.4",
"@types/mocha": "^2.2.40",
"@types/node": "^7.0.5",
"@bazel/typescript": "^0.0.10",
"babel": "^6.5.2",
"chai": "^3.5.0",
"mocha": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package(default_visibility=["//visibility:public"])
package(default_visibility=["@//bin:__pkg__"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")

ts_library(
Expand Down

0 comments on commit 015e27e

Please sign in to comment.