Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Commit

Permalink
docs(README): add README
Browse files Browse the repository at this point in the history
  • Loading branch information
s-panferov committed Feb 21, 2015
1 parent e56862c commit d92f52f
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 2 deletions.
23 changes: 23 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## License

The MIT License (MIT)

Copyright (c) 2015 Stanislav Panferov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
127 changes: 127 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# TypeScript Webpack Loader

TypeScript loader for Webpack. This project was started as a fork of https://github.com/andreypopp/typescript-loader.
Thanks @andreypopp for the great project.

## Installation

```
npm install awesome-typescript-loader
```

## Configuration

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

**webpack.config.js**

```javascript
module.exports = {

// Currently we need to add '.ts' to resolve.extensions array.
resolve: {
extensions: ['', '.ts', '.webpack.js', '.web.js', '.js']
},

// Source maps support (or 'inline-source-map' also works)
devtool: 'source-map',

// Add loader for .ts files.
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
}
]
}
};
```

After that, you would be able to build TypeScript files with webpack.

## Options

### target

Specify the TypeScript output target.

- ES3
- **ES5 (default)**
- ES6

### module

Specify the type of modules that TypeScript emits.

- **CommonJS (default)**
- AMD

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

Specify whether or not TypeScript emits source maps.

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

Specify whether or not TypeScript will allow inferring the `any` type.

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

Allows use of TypeScript compilers other than the official one. Should be
set to the NPM name of the compiler.

## Using with --watch or webpack-dev-server

This loader has support of both `--watch` and `webpack-dev-server` modes. It handles file dependencies
using internal webpack dependency markers. When you change a file, the loader recompiles all dependencies.

## Using with JSX-TypeScript compiler

You can use `typescript-loader` together with
[jsx-typscript](https://github.com/fdecampredon/jsx-typescript) compiler which
has support for JSX syntax (used in React.js).

For that you need to install `jsx-typescript`:

% npm install jsx-typescript

And specify `compiler` loader option:

```javascript
module.exports = {

module: {
loaders: [
{
test: /\.ts$/,
loader: 'typescript-loader?compiler=jsx-typescript'
}
]
}
};
```

## External Modules

The most natural way to structure your code with TypeScript and webpack is to use [external modules](https://github.com/Microsoft/TypeScript/wiki/Modules#going-external), and these work as you would expect.

```
npm install --save react
```

```typescript
import React = require('react');
```

## Internal Modules

This project doesn't aim to support internal modules, because it's hard to resolve dependencies for the watch
mode if you use such modules. Of course, you can still use external and internal .d.ts files.

## Declaration files

All declaration files should be resolvable from the entry file.
The easiest way to do this is to create a `references.d.ts` file which contains
references to all of your declaration files. Then reference
`references.d.ts` from your entry file.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function ensureInit(webpack: WebPack) {
var options = loaderUtils.parseQuery(webpack.query);
var tsImpl: typeof ts;

if (options.typescriptCompiler) {
tsImpl = require(options.typescriptCompiler);
if (options.compiler) {
tsImpl = require(options.compiler);
} else {
tsImpl = require('typescript');
}
Expand Down

0 comments on commit d92f52f

Please sign in to comment.