Skip to content

Commit 4551893

Browse files
authored
there's way too many examples (#899)
* single fork-ts-checker-webpack-plugin example * useTypeScriptIncrementalApi * delete most examples * update readme * add a close comment
1 parent c9b1f31 commit 4551893

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5440
-40149
lines changed

.github/stale.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ markComment: >
1414
recent activity. It will be closed if no further activity occurs. Thank you
1515
for your contributions.
1616
# Comment to post when closing a stale issue. Set to `false` to disable
17-
closeComment: false
17+
closeComment: >
18+
Closing as stale. Please reopen if you'd like to work on this further.

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ This is the typescript loader for webpack.
1414

1515
### Examples
1616

17-
We have a number of example setups to accomodate different workflows. From "[vanilla](examples/vanilla)" ts-loader, to using ts-loader in combination with [babel](https://babeljs.io/) for transpilation, [happypack](https://github.com/amireh/happypack) or [thread-loader](https://github.com/webpack-contrib/thread-loader) for faster builds and [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin) for performing type checking in a separate process. Not forgetting [Hot Module Replacement](https://webpack.js.org/api/hot-module-replacement/). Our examples can be found [here](examples/).
17+
We have a number of example setups to accomodate different workflows. Our examples can be found [here](examples/).
1818

19-
### Babel
19+
We probably have more examples than we need. That said, here's a good way to get started:
2020

21-
ts-loader works very well in combination with [babel](https://babeljs.io/) and [babel-loader](https://github.com/babel/babel-loader). There is an [example](https://github.com/Microsoft/TypeScriptSamples/tree/master/react-flux-babel-karma) of this in the official [TypeScript Samples](https://github.com/Microsoft/TypeScriptSamples). Alternatively take a look at our own [example](examples/react-babel-karma-gulp).
21+
- I want the simplest setup going. Use "[vanilla](examples/vanilla)" ts-loader
22+
- I want the fastest compilation that's available. Use [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin). It performs type checking in a separate process with `ts-loader` just handling transpilation.
2223

2324
### Faster Builds
2425

@@ -28,6 +29,10 @@ You probably don't want to give up type checking; that's rather the point of Typ
2829

2930
If you'd like to see a simple setup take a look at [our simple example](examples/fork-ts-checker/). For a more complex setup take a look at our [more involved example](examples/react-babel-karma-gulp).
3031

32+
### Babel
33+
34+
ts-loader works very well in combination with [babel](https://babeljs.io/) and [babel-loader](https://github.com/babel/babel-loader). There is an [example](https://github.com/Microsoft/TypeScriptSamples/tree/master/react-flux-babel-karma) of this in the official [TypeScript Samples](https://github.com/Microsoft/TypeScriptSamples). Alternatively take a look at our own [example](examples/react-babel-karma-gulp).
35+
3136
### Parallelising Builds
3237

3338
It's possible to parallelise your builds. Historically this was useful from a performance perspective with webpack 2 / 3. [With webpack 4+ there appears to be significantly less benefit and perhaps even cost.](https://blog.johnnyreilly.com/2018/12/you-might-not-need-thread-loader.html)
@@ -146,7 +151,7 @@ declare var require: {
146151

147152
Then you can simply require assets or chunks per the [webpack documentation](https://webpack.js.org/guides/code-splitting/).
148153

149-
```js
154+
```javascript
150155
require("!style!css!./style.css");
151156
```
152157

@@ -171,7 +176,7 @@ If you want to resolve modules according to `baseUrl` and `paths` in your `tscon
171176

172177
This feature requires webpack 2.1+ and TypeScript 2.0+. Use the config below or check the [package](https://github.com/dividab/tsconfig-paths-webpack-plugin/blob/master/README.md) for more information on usage.
173178

174-
```js
179+
```javascript
175180
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
176181

177182
module.exports = {
@@ -244,7 +249,7 @@ If you're using [HappyPack](https://github.com/amireh/happypack) or [thread-load
244249

245250
It's advisable to use this with the [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin) to get full type checking again. To see what this looks like in practice then either take a look at [our simple HappyPack example](examples/happypack) / [our simple thread-loader example](examples/thread-loader). For a more complex setup take a look at our [more involved HappyPack example](examples/react-babel-karma-gulp-happypack) / [more involved thread-loader example](examples/react-babel-karma-gulp-thread-loader). **_IMPORTANT_**: If you are using fork-ts-checker-webpack-plugin alongside HappyPack or thread-loader then ensure you set the `checkSyntacticErrors` option like so:
246251

247-
```
252+
```javascript
248253
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true })
249254
```
250255

@@ -326,7 +331,7 @@ By default ts-loader formats TypeScript compiler output for an error or a warnin
326331

327332
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.)
328333

329-
```js
334+
```javascript
330335
function customErrorFormatter(error, colors) {
331336
const messageColor =
332337
error.severity === "warning" ? colors.bold.yellow : colors.bold.red;
@@ -339,7 +344,7 @@ function customErrorFormatter(error, colors) {
339344

340345
If the above formatter received an error like this:
341346

342-
```
347+
```json
343348
{
344349
"code":2307,
345350
"severity": "error",
@@ -588,7 +593,7 @@ Ok, so how is that relevant to ts-loader? Because the best way to think about wh
588593

589594
Because TS will generate .js and .d.ts files, you should ignore these files, otherwise watchers may go into an infinite watch loop. For example, when using webpack, you may wish to add this to your webpack.conf.js file:
590595

591-
```js
596+
```javascript
592597
plugins: [
593598
new webpack.WatchIgnorePlugin([
594599
/\.js$/,

examples/core-js/internal/tests/browserMocks.js

-25
This file was deleted.

examples/core-js/internal/tests/fileMock.js

-1
This file was deleted.

examples/core-js/internal/tests/styleMock.js

-3
This file was deleted.

examples/core-js/package.json

-72
This file was deleted.

examples/core-js/src/components/__tests__/__snapshots__/layout.tests.tsx.snap

-7
This file was deleted.

examples/core-js/src/components/__tests__/layout.tests.tsx

-13
This file was deleted.

0 commit comments

Comments
 (0)