Skip to content

Instantly share code, notes, and snippets.

View alexeagle's full-sized avatar
🌿
Making a better Bazel

Alex Eagle alexeagle

🌿
Making a better Bazel
View GitHub Profile
const gulp = require('gulp');
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
const srcsToFmt = ['{src,test}/*.{js,ts}', '*.js'];
gulp.task(
'format:enforce',
() => gulp.src(srcsToFmt).pipe(
format.checkFormat('file', clangFormat, {verbose: true, fail: true})));
@alexeagle
alexeagle / a_b_c.ts
Created May 1, 2017 17:39
TypeScript path mapping in google3
export let c = 1;
# Other ts_library rules will use this custom compiler, which calls the
# TypeScript APIs to act like tsc, but adds capabilities like Bazel workers.
nodejs_binary(
name = "tsc_wrapped_bin",
data = [
":tsc_wrapped",
"@//:node_modules",
"@bytebuffer//:pkg",
"@protobufjs//:pkg",
"@long//:pkg",
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",
# This loads a built-in from the @bazel_tools repository, letting us
# fetch more rules from github.
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
# We have to fetch the NodeJS support, since Angular tooling runs in node.
git_repository(
name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
tag = "0.0.2",
)
package(default_visibility = ["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
ng_module(
name = "src",
srcs = glob(["*.ts"]),
deps = ["//src/hello-world"],
tsconfig = ":tsconfig.json",
)
sh_binary(
name = "sh",
srcs = [":repro.sh"],
data = [":some_data"],
)
load(":rule.bzl", "my_rule")
my_rule(name = "a")
@alexeagle
alexeagle / .bazelrc
Created October 16, 2017 19:10
Recommended Bazel flags
###############################
# Directory structure #
###############################
# Don't create bazel-* symlinks in the WORKSPACE directory.
# These require .gitignore and may scare users.
# Also, it's a workaround for https://github.com/bazelbuild/rules_typescript/issues/12
# which affects the common case of having `tsconfig.json` in the WORKSPACE directory.
#
# Instead, you should run `bazel info bazel-bin` to find out where the outputs went.

Summary

TypeScript meeting notes discussing microsoft/TypeScript#13408 resulted in microsoft/TypeScript#19126 and I'm concerned this is the wrong direction.

Current behavior is broken because lint-like diagnostics are treated as errors.

Proposed PR makes them warnings.

#!/usr/bin/env bash
#
# Runs clang-format on changed regions before commit.
#
# To install this, copy it to .git/hooks/pre-commit in your repo.
# Remaining installation checks/instructions will be printed when you commit.
#
read -d '' help <<- EOF
This repository requires you to install the git clang-format command.