Skip to content

Commit

Permalink
Merge pull request #643 from johnnyreilly/master
Browse files Browse the repository at this point in the history
v3.0 changes
  • Loading branch information
johnnyreilly authored Oct 16, 2017
2 parents a89212d + 50aa9a5 commit b0fb7ba
Show file tree
Hide file tree
Showing 245 changed files with 31,665 additions and 37,624 deletions.
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ node_js:
- "8"
sudo: false
install:
- npm install npm -g
- npm install
- npm run build
- npm install $TYPESCRIPT
- yarn install
- yarn build
- yarn add $TYPESCRIPT
env:
- [email protected]
- TYPESCRIPT=typescript@next
Expand All @@ -20,5 +19,3 @@ env:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## v3.0.0

All changes were made with this [PR](https://github.com/TypeStrong/ts-loader/pull/643) - thanks @johnnyreilly

- drop support for typescript < 2.0 (no-one seems to be using it and we can simplify the code) **BREAKING CHANGE**
- remove `entryFileIsJs` option; it can be inferred from whether the `allowJs` TypeScript compiler option has been set.
- move to webpack 3.0 for test harness
- drop `configFileName` support [(replaced by `configFile`)](https://github.com/TypeStrong/ts-loader/pull/607) **BREAKING CHANGE**
- add support for a custom formatter for output - drop visual studio format (this can be added back if there's clamour for it and people can supply their own formatters in the interim) **BREAKING CHANGE**
- make loglevel warn by default (stop outputting typescript version number by default). Fixes #488
- fix [tsc has "module" default to "es2015"when targetting es2015+, but ts-loader does not](https://github.com/TypeStrong/ts-loader/issues/570)
- [switch to yarn](https://github.com/TypeStrong/ts-loader/issues/369) because of [this](https://stackoverflow.com/questions/45022048/why-does-npm-install-rewrite-package-lock-json/45566871#45566871)
- allow controlling whether the output can contain colours

## v2.3.7

- [Start validating the options supplied to the loader](https://github.com/TypeStrong/ts-loader/pull/630) (#629) - thanks @johnnyreilly!
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ action to take before coding begins.
## Building

```shell
npm install
npm run build
yarn install
yarn build
```

## Changing
Expand All @@ -25,10 +25,10 @@ In short: fork, make your changes, and submit a pull request.

This project makes use of 2 integration test packs to make sure we don't break anything. That's right, count them, 2! There is a comparison test pack which compares compilation outputs and is long established. There is also an execution test pack which executes the compiled JavaScript. This test pack is young and contains fewer tests; but it shows promise.

You can run all the tests (in both test packs) with `npm test`.
You can run all the tests (in both test packs) with `yarn test`.

To run comparison tests alone use `npm run comparison-tests`.
To run execution tests alone use `npm run execution-tests`.
To run comparison tests alone use `yarn run comparison-tests`.
To run execution tests alone use `yarn run execution-tests`.

Not all bugs/features necessarily fit into either framework and that's OK. However, most do and therefore you should make every effort to create at least one test which demonstrates the issue or exercises the feature. Use your judgement to decide whether you think a comparison test or an execution test is most appropriate.

Expand All @@ -48,15 +48,15 @@ Before you can actually publish make sure the following statements are true:
OK - you're actually ready. We're going to publish. Here we need to tread carefully. Follow these steps:

- clone ts-loader from the main repo with this command: `git clone https://github.com/TypeStrong/ts-loader.git`
- [Login to npm](https://docs.npmjs.com/cli/adduser) if you need to: `npm login`
- install ts-loaders packages with `npm install`
- build ts-loader with `npm run build`
- run the tests to ensure all is still good: `npm test`
- [Login to npm](https://docs.npmjs.com/cli/adduser) if you need to: `yarn login`
- install ts-loaders packages with `yarn install`
- build ts-loader with `yarn build`
- run the tests to ensure all is still good: `yarn test`

If all the tests passed then we're going to ship:
- tag the release in git. You can see existing tags with the command `git tag`. If the version in your `package.json` is `"1.0.1"` then you would tag the release like so: `git tag v1.0.1`. For more on type of tags we're using read [here](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Lightweight-Tags).
- Push the tag so the new version will show up in the [releases](https://github.com/TypeStrong/ts-loader/releases): `git push origin --tags`
- On the releases page, click the "Draft a new release button" and, on the presented page, select the version you've just released, name it and copy in the new markdown that you added to the [changelog](CHANGELOG.md).
- Now the big moment: `npm publish`
- Now the big moment: `yarn publish`

You've released! Pat yourself on the back.
97 changes: 64 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,24 @@ To read more on this look at this [webpack Medium post](https://medium.com/webpa

### Installation

```
yarn add ts-loader
```

or

```
npm install ts-loader
```

You will also need to install TypeScript if you have not already.

```
yarn add typescript
```

or

```
npm install typescript
```
Expand Down Expand Up @@ -148,7 +160,7 @@ For more background have a read of [this issue](https://github.com/TypeStrong/ts

### Options

There are two types of options: TypeScript options (aka "compiler options") and loader options. TypeScript options should be set using a tsconfig.json file. Loader options can be set either using a query when specifying the loader or through the `options` property in the webpack configuration:
There are two types of options: TypeScript options (aka "compiler options") and loader options. TypeScript options should be set using a tsconfig.json file. Loader options can be specified through the `options` property in the webpack configuration:

```javascript
module.exports = {
Expand All @@ -157,36 +169,20 @@ module.exports = {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
transpileOnly: true
}
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
]
}
]
}
}
```

Alternatively this can be configured using a query:

```javascript
module.exports = {
...
module: {
loaders: [
// specify option using query
{
test: /\.tsx?$/,
loader: 'ts-loader?' + JSON.stringify({
transpileOnly: true
}) }
]
}
}
```

For a full breakdown of the power of query syntax have a read of [this](https://github.com/webpack/loader-utils#getoptions).

### Loader Options

#### transpileOnly *(boolean) (default=false)*
Expand Down Expand Up @@ -238,10 +234,6 @@ codes to ignore.
Allows use of TypeScript compilers other than the official one. Should be
set to the NPM name of the compiler, eg [`ntypescript`](https://github.com/basarat/ntypescript).
#### configFileName *(string) (default='tsconfig.json')*
This option has been deprecated in favor of [`configFile`](#user-content-configfile-string-defaulttsconfigjson).
#### configFile *(string) (default='tsconfig.json')*
Allows you to specify where to find the TypeScript configuration file.
Expand All @@ -252,9 +244,48 @@ You may provide
* a relative path to the configuration file. It will be resolved relative to the respective `.ts` entry file.
* an absolute path to the configuration file.

#### visualStudioErrorFormat *(boolean) (default=false)*
#### colors *(boolean) (default=true)*

If `false`, disables built-in colors in logger messages.

#### errorFormatter *((message: ErrorInfo, colors: boolean) => string) (default=undefined)*

By default ts-loader formats TypeScript compiler output for an error or a warning in the style:

```
[tsl] ERROR in myFile.ts(3,14)
TS4711: you did something very wrong
```

If that format is not to your taste you can supply your own formatter using the `errorFormatter` option. Below is a template for a custom error formatter. Please note that the `colors` parameter is an instance of [`chalk`](https://github.com/chalk/chalk) which you can use to color your output. (This instance will respect the `colors` option.)

```js
function customErrorFormatter(error, colors) {
const messageColor = error.severity === 'warning' ? colors.bold.yellow : colors.bold.red;
return 'Does not compute.... ' + messageColor(Object.keys(error).map(key => `${key}: ${error[key]}`));
}
```

If the above formatter received an error like this:

```
{
"code":2307,
"severity": "error",
"content": "Cannot find module 'components/myComponent2'.",
"file":"/.test/errorFormatter/app.ts",
"line":2,
"character":31
}
```

It would produce an error message that said:

```
Does not compute.... code: 2307,severity: error,content: Cannot find module 'components/myComponent2'.,file: /.test/errorFormatter/app.ts,line: 2,character: 31
```

If `true`, the TypeScript compiler output for an error or a warning, e.g. `(3,14): error TS4711: you did something very wrong`, in file `myFile` will instead be `myFile(3,14): error TS4711: you did something very wrong` (notice the file name at the beginning). This way Visual Studio will interpret this line and show any errors or warnings in the *error list*. This enables navigation to the file/line/column through double click.
And the bit after "Does not compute.... " would be red.

#### compilerOptions *(object) (default={})*

Expand All @@ -267,9 +298,9 @@ 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.

#### entryFileIsJs *(boolean) (default=false)*
#### entryFileCannotBeJs *(boolean) (default=false)*

To be used in concert with the `allowJs` compiler option. If your entry file is JS then you'll need to set this option to true. Please note that this is rather unusual and will generally not be necessary when using `allowJs`.
If the `allowJs` compiler option is `true` then it's possible for your entry files to be JS. Since people have reported occasional problems with this the `entryFileCannotBeJs` setting exists to disable this functionality (if set then your entry file cannot be JS). Please note that this is rather unusual and will generally not be necessary when using `allowJs`. This option may be removed in a future version of ts-loader if it appears to be unused (likely).
#### appendTsSuffixTo *(RegExp[]) (default=[])*
#### appendTsxSuffixTo *(RegExp[]) (default=[])*
Expand Down
12 changes: 5 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ environment:
- TYPESCRIPT: [email protected]
- TYPESCRIPT: [email protected]
- TYPESCRIPT: [email protected]
- TYPESCRIPT: [email protected]
- TYPESCRIPT: [email protected]
install:
- ps: Install-Product node $env:nodejs_version
- npm install
- npm run build
- npm install %TYPESCRIPT%
- yarn install
- yarn build
- yarn add %TYPESCRIPT%
test_script:
- node --version
- npm --version
- npm test
- yarn --version
- yarn test
build: off
6 changes: 3 additions & 3 deletions examples/react-babel-karma-gulp-fork-ts-checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
You'll need [node / npm](https://nodejs.org/) installed. To get up and running just enter:

```
npm install
npm run serve
yarn install
yarn serve
```

This will:

1. Download the npm packages you need (including the type definitions from DefinitelyTyped)
2. Compile the code and serve it up at [http://localhost:8080](http://localhost:8080)

When you're building for production then `npm run build`
When you're building for production then `yarn build`
Loading

0 comments on commit b0fb7ba

Please sign in to comment.