Skip to content

zuzusik/karma-typescript-preprocessor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

karma-typescript-preprocessor

Preprocessor to compile TypeScript on the fly.

Build Status Deps Status devDependency Status

NPM

Installation

Just write karma-typescript-preprocessor as a devDependency in your package.json.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-typescript-preprocessor": "~0.1"
  }
}

Or just issue the following command:

npm install karma-typescript-preprocessor --save-dev

Configuration

The code below shows the sample configuration of the preprocessor.

// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      '**/*.ts': ['typescript']
    },

    typescriptPreprocessor: {
      // options passed to the typescript compiler
      options: {
        sourceMap: false, // (optional) Generates corresponding .map file.
        target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5'
        module: 'amd', // (optional) Specify module code generation: 'commonjs' or 'amd'
        noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type.
        noResolve: true, // (optional) Skip resolution and preprocessing.
        removeComments: true // (optional) Do not emit comments to output.
      },
      // transforming the filenames
      transformPath: function(path) {
        return path.replace(/\.ts$/, '.js');
      }
    }
  });
};

If you set the sourceMap option to true then the generated source map will be inlined as a data-uri.


For more information on Karma see the homepage.

About

TypeScript preprocessor for karma-runner

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 46.3%
  • TypeScript 41.2%
  • CoffeeScript 12.5%