workspace(name = 'lang') http_archive( name = "build_bazel_rules_typescript", url = " https://github.com/bazelbuild/rules_typescript/archive/0.21.0.zip ", strip_prefix = "rules_typescript-0.21.0", ) # Fetch our Bazel dependencies that aren't distributed on npm load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies") rules_typescript_dependencies() # Setup TypeScript toolchain load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") ts_setup_workspace() # Setup the Node.js toolchain load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install") node_repositories() # Setup Bazel managed npm dependencies with the `yarn_install` rule. yarn_install( name = "npm", package_json = "//:package.json", yarn_lock = "//:yarn.lock", )
package(default_visibility = ["//visibility:public"]) load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") ts_library( name = "app", srcs = ["test.ts"], deps = ["//lexer", "//parser", "//interpreter"], ) load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle") rollup_bundle( name = "bundle", entry_point = "test.js", deps = [":app"], )
package(default_visibility = ["//visibility:public"]) load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") ts_library( name = "parser", srcs = glob(["*.ts"]), deps = ["//lexer"], )
yarn
./node_modules/.bin/bazel query --output=graph ... | dot -Tpng > graph.png
./node_modules/.bin/bazel build :bundle
node bazel-bin/bundle.js forty-three
# Don’t forget yarn add -D @bazel/ibazel ./node_modules/.bin/ibazel build :app
{ "name": "bazel-demo", "license": "MIT", "scripts": { "build": "bazel build :bundle", "watch": "ibazel build :app" }, "devDependencies": { "@bazel/bazel": "^0.19.1", "@bazel/typescript": "0.21.0", "typescript": "^3.1.6" } }