Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
A rudimentary example
Browse files Browse the repository at this point in the history
The start of an example of how to use bazeltsc in your own project.
  • Loading branch information
mmorearty committed Nov 6, 2017
1 parent 1ddbbb1 commit 7a0c0af
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/.gitignore
@@ -0,0 +1,2 @@
bazel-*
node_modules/
15 changes: 15 additions & 0 deletions example/BUILD
@@ -0,0 +1,15 @@
package(default_visibility = ["//visibility:public"])

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

nodejs_binary(
name = "bazeltsc",
entry_point = "bazeltsc/bin/bazeltsc",
)

# outputs are x.js, x.js.map, x.d.ts
tsc(
name = "x",
srcs = ["x.ts"]
)
14 changes: 14 additions & 0 deletions example/WORKSPACE
@@ -0,0 +1,14 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
tag = "0.1.0", # check for the latest tag when you install
)

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

# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
# your npm dependencies. You must still run the package manager.
node_repositories(package_json = ["//:package.json"])

16 changes: 16 additions & 0 deletions example/package.json
@@ -0,0 +1,16 @@
{
"name": "btsctest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Mike Morearty (https://github.com/mmorearty)",
"license": "ISC",
"devDependencies": {
"bazeltsc": "1.0.0",
"typescript": "^2.6.1"
}
}
5 changes: 5 additions & 0 deletions example/x.ts
@@ -0,0 +1,5 @@
export class X {
foo(n: number) { console.log(`This is X.foo ${n}`); }
}

new X().foo(7);

0 comments on commit 7a0c0af

Please sign in to comment.