Coder Social home page Coder Social logo

klandergren / rules_ts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aspect-build/rules_ts

0.0 0.0 0.0 1.17 MB

Bazel rules for the `tsc` compiler from http://typescriptlang.org

Home Page: https://docs.aspect.build/rules/aspect_rules_ts

License: Apache License 2.0

Shell 10.57% JavaScript 25.26% TypeScript 0.58% Starlark 63.58%

rules_ts's Introduction

Bazel rules for TypeScript

This is the canonical ruleset for using Bazel with TypeScript, based on https://github.com/aspect-build/rules_js.

Many companies are successfully building with rules_ts. If you're getting value from the project, please let us know! Just comment on our Adoption Discussion.

This is a high-performance alternative to the @bazel/typescript npm package from rules_nodejs. The ts_project rule here is identical to the one in rules_nodejs, making it easy to migrate. Since rules_js always runs tools from the bazel-out tree, rules_ts naturally fixes most usability bugs with rules_nodejs:

  • Freely mix generated *.ts and tsconfig.json files in the bazel-out tree with source files
  • Fixes the need for any rootDirs settings in tsconfig.json as reported in microsoft/TypeScript#37378
  • "worker mode" for ts_project now shares workers across all targets, rather than requiring one worker pool per target

rules_ts is just a part of what Aspect provides:

Known issues:

Installation

Follow instructions from the release you wish to use: https://github.com/aspect-build/rules_ts/releases

Examples

There are a number of examples in the examples/ folder and larger examples in the bazel-examples repository using rules_ts such as jest, react, angular.

If you'd like an example added, you can fund a Feature Request.

Usage

See the API documentation in the docs/ folder.

From a BUILD file

The most common use is with the ts_project macro which invokes a transpiler you configure to transform source files like .ts files into outputs such as .js and .js.map, and the tsc CLI to type-check the program and produce .d.ts files.

In a macro

Many organizations set default values, so it's common to write a macro to wrap ts_project, then ensure that your developers load your macro rather than loading from @aspect_rules_ts directly.

BUILD file generation

Aspect provides a TypeScript BUILD file generator as part of the Aspect CLI. Run aspect configure to create or update BUILD.bazel files as you edit TypeScript sources. See https://docs.aspect.build/cli/commands/aspect_configure.

Advanced: custom rules

If you know how to write Bazel rules, you might find that ts_project doesn't do what you want.

One way to customize it is to peel off one layer of indirection, by calling the ts_project_rule directly. This bypasses our default setting logic, and also the validation program which checks that ts_project attributes are well-formed.

You can also write a custom rule from scratch. We expose helper functions from /ts/private in this repo. Be aware that these are not a public API, so you may have to account for breaking changes which aren't subject to our usual semver policy.

rules_ts's People

Contributors

gregmagolan avatar alexeagle avatar thesayyn avatar jbedard avatar renovate[bot] avatar kormide avatar github-actions[bot] avatar jfirebaugh avatar renovate-bot avatar gzm0 avatar mattem avatar sallustfire avatar vpanta avatar jstuder-gh avatar dzbarsky avatar dgp1130 avatar mgred avatar nbeloglazov avatar oleg-codaio avatar tsawada avatar uebelandre avatar yvanguidoin avatar ericrafalovsky avatar mrmeku avatar realtimetodie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.