<commit_before># TypeScript loader for webpack

## Usage

A step by step tutorial is [available here](http://www.jbrantly.com/typescript-and-webpack/).

### Installation

```
npm install ts-loader
```

### Upgrading

Take advantage of the [Changelog](CHANGELOG.md) and [Upgrade Guide](UPGRADE.md).

### Running

Use webpack like normal, including `webpack --watch` and `webpack-dev-server`, or through another
build system using the [Node.js API](http://webpack.github.io/docs/node.js-api.html).

### Compatibility

The current version is compatible with TypeScript 1.5 and with the nightly build using [ntypescript](https://github.com/basarat/ntypescript) (use the `compiler` option, see below). You may experience issues using the nightly build due to its nature. Please feel free to report any such issues so that they can be fixed promptly.

### Configuration

1. Add `.ts` as a resolvable extension.
2. Configure all files with a `.ts` extension to be handled by `ts-loader`.

```
module.exports = {
    entry: './app.ts',
    output: {
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader' }
        ]
    }
}
```

#### Options

Most TypeScript-related options should be set using a 
[tsconfig.json](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json)
file. There are a few loader-specific options you can set although in general
you should not need to.

##### silent *(boolean) (default=false)*

If true, no console.log messages will be emitted. Note that most error
messages are emitted via webpack which is not affected by this flag.

##### compiler *(string) (default='typescript')*

Allows use of TypeScript compilers other than the official one. Should be
set to the NPM name of the compiler. Especially useful for the [nightly
build of TypeScript](https://github.com/basarat/ntypescript).

##### instance *(string)*

Advanced option to force files to go through different instances of the
TypeScript compiler. Can be used to force segregation between different parts
of your code.

##### configFileName *(string) (default='tsconfig.json')*

Allows you to specify a custom configuration file.

### Loading other resources and code splitting

Loading css and other resources is possible but you will need to make sure that
you have defined the `require` function in a declaration file.

```
declare var require: {
    <T>(path: string): T;
    (paths: string[], callback: (...modules: any[]) => void): void;
    ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void;
};
```

Then you can simply require assets or chunks per the [webpack documentation](http://webpack.github.io/docs).

```
require('!style!css!./style.css');
```

### React JSX

This loader supports using [jsx-typescript](https://github.com/fdecampredon/jsx-typescript).
Simply install jsx-typescript and use the `compiler=jsx-typescript` option. Note that you
will need to use ts-loader@0.3.x in order to use this as 0.4.x and above is not API-compatible. 

You may also be interested in using [ts-jsx-loader](https://github.com/jbrantly/ts-jsx-loader).

If you like living on the edge, the nightly version of TypeScript supports JSX natively. See
the [JSX test](test/jsx) for an example.

## Building from source

```
tsd reinstall
npm install
tsc index.ts --module commonjs
```

## License

The MIT License (MIT)

Copyright (c) 2015 <NAME><commit_msg>Update README with more details about code splitting and link to example. (#26)<commit_after># TypeScript loader for webpack

## Usage

A step by step tutorial is [available here](http://www.jbrantly.com/typescript-and-webpack/).

### Installation

```
npm install ts-loader
```

### Upgrading

Take advantage of the [Changelog](CHANGELOG.md) and [Upgrade Guide](UPGRADE.md).

### Running

Use webpack like normal, including `webpack --watch` and `webpack-dev-server`, or through another
build system using the [Node.js API](http://webpack.github.io/docs/node.js-api.html).

### Compatibility

The current version is compatible with TypeScript 1.5 and with the nightly build using [ntypescript](https://github.com/basarat/ntypescript) (use the `compiler` option, see below). You may experience issues using the nightly build due to its nature. Please feel free to report any such issues so that they can be fixed promptly.

### Configuration

1. Add `.ts` as a resolvable extension.
2. Configure all files with a `.ts` extension to be handled by `ts-loader`.

```
module.exports = {
    entry: './app.ts',
    output: {
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader' }
        ]
    }
}
```

#### Options

Most TypeScript-related options should be set using a 
[tsconfig.json](https://github.com/Microsoft/TypeScript/wiki/tsconfig.json)
file. There are a few loader-specific options you can set although in general
you should not need to.

##### silent *(boolean) (default=false)*

If true, no console.log messages will be emitted. Note that most error
messages are emitted via webpack which is not affected by this flag.

##### compiler *(string) (default='typescript')*

Allows use of TypeScript compilers other than the official one. Should be
set to the NPM name of the compiler. Especially useful for the [nightly
build of TypeScript](https://github.com/basarat/ntypescript).

##### instance *(string)*

Advanced option to force files to go through different instances of the
TypeScript compiler. Can be used to force segregation between different parts
of your code.

##### configFileName *(string) (default='tsconfig.json')*

Allows you to specify a custom configuration file.

### Loading other resources and code splitting

Loading css and other resources is possible but you will need to make sure that
you have defined the `require` function in a declaration file.

```
declare var require: {
    <T>(path: string): T;
    (paths: string[], callback: (...modules: any[]) => void): void;
    ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void;
};
```

Then you can simply require assets or chunks per the [webpack documentation](http://webpack.github.io/docs).

```
require('!style!css!./style.css');
```

The same basic process is required for code splitting. In this case, you `import` modules you need but you
don't directly use them. Instead you require them at [split points](http://webpack.github.io/docs/code-splitting.html#defining-a-split-point). 
See [this example](test/codeSplitting) for more details. 

### React JSX

This loader supports using [jsx-typescript](https://github.com/fdecampredon/jsx-typescript).
Simply install jsx-typescript and use the `compiler=jsx-typescript` option. Note that you
will need to use ts-loader@0.3.x in order to use this as 0.4.x and above is not API-compatible. 

You may also be interested in using [ts-jsx-loader](https://github.com/jbrantly/ts-jsx-loader).

If you like living on the edge, the nightly version of TypeScript supports JSX natively. See
the [JSX test](test/jsx) for an example.

## Building from source

```
tsd reinstall
npm install
tsc index.ts --module commonjs
```

## License

The MIT License (MIT)

Copyright (c) 2015 <NAME>
{'fraction_non_alphanumeric': 0.12284482758620689, 'fraction_numerical': 0.003502155172413793, 'mean_word_length': 3.9665551839464883, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2781293', 'n_tokens_mistral': 2211, 'n_tokens_neox': 2138, 'n_words': 869}