UNPKG

2.31 kBMarkdownView Raw
1# karma-typescript-preprocessor
2
3> Preprocessor to compile TypeScript on the fly.
4
5[![Build Status](https://travis-ci.org/sergeyt/karma-typescript-preprocessor.svg?branch=master)](https://travis-ci.org/sergeyt/karma-typescript-preprocessor)
6[![Deps Status](https://david-dm.org/sergeyt/karma-typescript-preprocessor.png)](https://david-dm.org/sergeyt/karma-typescript-preprocessor)
7[![devDependency Status](https://david-dm.org/sergeyt/karma-typescript-preprocessor/dev-status.svg)](https://david-dm.org/sergeyt/karma-typescript-preprocessor#info=devDependencies)
8[![npm](https://img.shields.io/npm/dt/karma-typescript-preprocessor.svg?maxAge=2592000)](https://www.npmjs.com/package/karma-typescript-preprocessor)
9
10## Installation
11
12```bash
13npm install karma-typescript-preprocessor --save-dev
14```
15
16## Configuration
17
18The code below shows the sample configuration of the preprocessor.
19```js
20// karma.conf.js
21module.exports = function(config) {
22 config.set({
23 preprocessors: {
24 '**/*.ts': ['typescript']
25 },
26
27 typescriptPreprocessor: {
28 // options passed to the typescript compiler
29 options: {
30 sourceMap: false, // (optional) Generates corresponding .map file.
31 target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5'
32 module: 'amd', // (optional) Specify module code generation: 'commonjs' or 'amd'
33 noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type.
34 noResolve: true, // (optional) Skip resolution and preprocessing.
35 removeComments: true, // (optional) Do not emit comments to output.
36 concatenateOutput: false // (optional) Concatenate and emit output to single file. By default true if module option is omited, otherwise false.
37 },
38 // transforming the filenames
39 transformPath: function(path) {
40 return path.replace(/\.ts$/, '.js');
41 }
42 }
43 });
44};
45```
46
47If you set the `sourceMap` option to `true` then the generated source map will be inlined as a data-uri.
48
49All TypeScript compiler options are defined [here](https://github.com/Microsoft/TypeScript/blob/0f67f4b6f1589756906782f1ac02e6931e1cff13/lib/typescript.d.ts#L1445-L1500).
50
51----
52
53For more information on Karma see the [homepage](http://karma-runner.github.com).
54