Created
August 14, 2017 23:27
-
-
Save alexeagle/d027a3b4e9e2640fe5645302791c8309 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package(default_visibility=["//visibility:public"]) | |
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") | |
ts_library( | |
name = "my_code", | |
srcs = glob(["*.ts"]), | |
) | |
filegroup(name = "node_modules", srcs = glob([ | |
"node_modules/**/*.js", | |
"node_modules/**/*.d.ts", | |
"node_modules/**/*.json", | |
])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const s: string = 's'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example", | |
"devDependencies": { | |
"rules_typescript": "alexeagle/rules_typescript#74a5bb2" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | |
# First, we bootstrap things by having Bazel download the nodejs rules. | |
# This depends on getting a resolution to | |
# https://github.com/pubref/rules_node/issues/19 so we can have a first-party | |
# bazelbuild/rules_nodejs (otherwise it's strange for first-party | |
# bazelbuild/rules_typescript to depend on third-party alexeagle/rules_nodejs) | |
# For now, I have a prototype under alexeagle/rules_nodejs | |
git_repository( | |
name = "build_bazel_rules_nodejs", | |
remote = "https://github.com/alexeagle/rules_nodejs.git", | |
commit = "4924d7b", | |
) | |
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") | |
node_repositories(package_json = "//:package.json") | |
# Now, we need both the runtime deps and the .bzl files for rules_typescript. | |
# Instead of having bazel fetch the rules, as you normally would, we want a | |
# single dependency that gives both compile-time and runtime dependencies. | |
# Note that it's okay that this path doesn't exist at first, bazel won't look at | |
# this until you try to build the first ts_* target. That's actually a nicer | |
# error message if you haven't installed. | |
# Users must add to package.json | |
# "devDependencies": { | |
# "rules_typescript": "alexeagle/rules_typescript#rules_nodejs" | |
# } | |
local_repository( | |
name = "build_bazel_rules_typescript", | |
path = "node_modules/rules_typescript", | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment