# broccoli-typescript-compiler

> A Broccoli plugin which compiles TypeScript files.

Latest version **8.0.0** (published 2022-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install broccoli-typescript-compiler
pnpm add broccoli-typescript-compiler
yarn add broccoli-typescript-compiler
bun add broccoli-typescript-compiler
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2022-02-02 |
| First published | 2015-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 307.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Kris Selden |
| Maintainers | wycats, wagenet, krisselden, ef4, rwjblue, tomdale, stefanpenner, chancancode |
| Keywords | TypeScript, broccoli-plugin, compiler, javascript, js |

## Links

- npm: https://www.npmjs.com/package/broccoli-typescript-compiler
- Repository: https://github.com/tildeio/broccoli-typescript-compiler
- Issues: https://github.com/tildeio/broccoli-typescript-compiler/issues
- npm.io page: https://npm.io/package/broccoli-typescript-compiler

## Dependencies (7)

- [md5-hex](https://npm.io/package/md5-hex.md) ^3.0.1
- [walk-sync](https://npm.io/package/walk-sync.md) ^2.1.0
- [heimdalljs](https://npm.io/package/heimdalljs.md) 0.3.3
- [fs-tree-diff](https://npm.io/package/fs-tree-diff.md) ^2.0.1
- [broccoli-funnel](https://npm.io/package/broccoli-funnel.md) ^3.0.3
- [broccoli-plugin](https://npm.io/package/broccoli-plugin.md) ^4.0.1
- [broccoli-merge-trees](https://npm.io/package/broccoli-merge-trees.md) ^4.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 8.0.0 (latest) — 2022-02-02
- 2.0.0-beta.2 (beta) — 2017-07-20
- 7.0.0 — 2020-09-28
- 6.0.1 — 2020-09-03
- 6.0.0 — 2020-05-20
- 5.0.0 — 2020-02-20
- 4.2.0 — 2019-10-17
- 4.1.0 — 2018-11-30
- 4.0.1 — 2018-08-06
- 3.0.1 — 2018-06-04
- 2.3.0 — 2018-05-15
- 2.2.0 — 2018-02-13
- 2.1.1 — 2017-12-08
- 2.1.0 — 2017-09-03
- 2.0.1 — 2017-08-18
- … 22 more at https://npm.io/package/broccoli-typescript-compiler/versions

## README

# broccoli-typescript-compiler

![Build Status](https://github.com/tildeio/broccoli-typescript-compiler/workflows/CI/badge.svg)

A [Broccoli](https://github.com/broccolijs/broccoli) plugin which
compiles [TypeScript](http://www.typescriptlang.org) files.

## How to install?

```sh
$ npm install broccoli-typescript-compiler --save-dev
```

## How to use?

```js
var typescript = require("broccoli-typescript-compiler").default;
var cjsTree = typescript(inputTree, {
  tsconfig: {
    compilerOptions: {
      module: "commonjs",
      target: "es5",
      moduleResolution: "node",
      newLine: "LF",
      rootDir: "src",
      outDir: "dist",
      sourceMap: true,
      declaration: true,
    },
    files: ["src/index.ts", "src/tests/**"],
  },
  throwOnError: false,
  annotation: "compile program",
});
```

### Config Options:

`tsconfig:`

- default (when ommited): will find the nearest `tsconfig` relative to where the BroccoliTypeScriptCompiler is invoked.
- as string: a absolute path to a config tsconfig file
- as config object: See: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

`annotation:`

An optional string, which when provide should be a descriptive annotation. Useful for debugging, to tell multiple instances of the same plugin apart.

`throwOnError`

An optional boolean, defaulting to `false`. If set to `true`, will cause the build to break on errors.

_note: if `process.env.NODE_ENV === 'production'` is true, `throwOnError` will default to `true`._

### Ways to use:

## via the broccoli plugin subclass

This outputs only the emitted files from the compiled program.

```js
const { TypescriptCompiler } = require("broccoli-typescript-compiler");
let compiled = new TypescriptCompiler(input, options);
```

## via function

This outputs only the emitted files from the compiled program.

```js
const { default: typescript } = require("broccoli-typescript-compiler");

let compiled = typescript(src, options);
```

## filter function (passthrough non .ts files)

This selects only ts files from the input to compile and merges emitted files with the non ts files in the input.

```js
const { filterTypescript } = require("broccoli-typescript-compiler");
let output = filterTypescript(input, options);
```

## Development

### How to upgrade `typescript`

1. Initialize git submodules. `git submodule update --init`
2. Update `typescript` in `package.json`
3. Run `yarn run generate-tsconfig-interface`
4. Update `vendor/typescript`. `cd vendor/typescript && git fetch --tags && git checkout v[new-version-of-typescript]`
5. Commit all of the above changes
6. Run `yarn test`. There may be some changes needed to the tests to accomidate changes in TypeScript.

---
_Source: https://npm.io/package/broccoli-typescript-compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
