You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to speed up compilation significantly you can set this flag.
289
292
However, many of the benefits you get from static type checking between
@@ -311,7 +314,10 @@ module.exports = {
311
314
}
312
315
```
313
316
314
-
#### happyPackMode _(boolean) (default=false)_
317
+
#### happyPackMode
318
+
| Type | Default Value |
319
+
|------|--------------|
320
+
|`boolean`|`false`|
315
321
316
322
If you're using [HappyPack](https://github.com/amireh/happypack) or [thread-loader](https://github.com/webpack-contrib/thread-loader) to parallise your builds then you'll need to set this to `true`. This implicitly sets `*transpileOnly*` to `true` and **WARNING!** stops registering **_all_** errors to webpack.
317
323
@@ -325,37 +331,55 @@ This will ensure that the plugin checks for both syntactic errors (eg `const arr
325
331
326
332
Also, if you are using `thread-loader` in watch mode, remember to set `poolTimeout: Infinity` so workers don't die.
327
333
328
-
#### resolveModuleName and resolveTypeReferenceDirective:
334
+
#### resolveModuleName and resolveTypeReferenceDirective
329
335
330
336
These options should be functions which will be used to resolve the import statements and the `<reference types="...">` directives instead of the default TypeScript implementation. It's not intended that these will typically be used by a user of `ts-loader` - they exist to facilitate functionality such as [Yarn Plug’n’Play](https://yarnpkg.com/en/docs/pnp).
Provide custom transformers - only compatible with TypeScript 2.3+ (and 2.4 if using `transpileOnly` mode). For example usage take a look at [typescript-plugin-styled-components](https://github.com/Igorbek/typescript-plugin-styled-components) or our [test](test/comparison-tests/customTransformer).
335
344
336
345
You can also pass a path string to locate a js module file which exports the function described above, this useful especially in `happyPackMode`. (Because forked processes cannot serialize functions see more at [related issue](https://github.com/Igorbek/typescript-plugin-styled-components/issues/6#issue-303387183))
337
346
338
-
#### logInfoToStdOut _(boolean) (default=false)_
347
+
#### logInfoToStdOut
348
+
| Type | Default Value |
349
+
|------|--------------|
350
+
|`boolean`|`false`|
339
351
340
352
This is important if you read from stdout or stderr and for proper error handling.
341
353
The default value ensures that you can read from stdout e.g. via pipes or you use webpack -j to generate json output.
342
354
343
-
#### logLevel _(string) (default=warn)_
355
+
#### logLevel
356
+
| Type | Default Value |
357
+
|------|--------------|
358
+
|`string`|`warn`|
344
359
345
360
Can be `info`, `warn` or `error` which limits the log output to the specified log level.
346
361
Beware of the fact that errors are written to stderr and everything else is written to stderr (or stdout if logInfoToStdOut is true).
347
362
348
-
#### silent _(boolean) (default=false)_
363
+
#### silent
364
+
| Type | Default Value |
365
+
|------|--------------|
366
+
|`boolean`|`false`|
349
367
350
368
If `true`, no console.log messages will be emitted. Note that most error
351
369
messages are emitted via webpack which is not affected by this flag.
352
370
353
-
#### ignoreDiagnostics _(number[]) (default=[])_
371
+
#### ignoreDiagnostics
372
+
| Type | Default Value |
373
+
|------|--------------|
374
+
|`number[]`|`[]`|
354
375
355
376
You can squelch certain TypeScript errors by specifying an array of diagnostic
356
377
codes to ignore.
357
378
358
-
#### reportFiles _(string[]) (default=[])_
379
+
#### reportFiles
380
+
| Type | Default Value |
381
+
|------|--------------|
382
+
|`string[]`|`[]`|
359
383
360
384
Only report errors on files matching these glob patterns.
361
385
@@ -370,12 +394,18 @@ Only report errors on files matching these glob patterns.
370
394
371
395
This can be useful when certain types definitions have errors that are not fatal to your application.
372
396
373
-
#### compiler _(string) (default='typescript')_
397
+
#### compiler
398
+
| Type | Default Value |
399
+
|------|--------------|
400
+
|`string`|`'typescript'`|
374
401
375
402
Allows use of TypeScript compilers other than the official one. Should be
376
403
set to the NPM name of the compiler, eg [`ntypescript`](https://github.com/basarat/ntypescript).
Allows you to specify where to find the TypeScript configuration file.
381
411
@@ -388,11 +418,17 @@ You may provide
388
418
Please note, that if the configuration file is outside of your project directory, you might need to set the `context` option to avoid TypeScript issues (like TS18003).
389
419
In this case the `configFile` should point to the `tsconfig.json` and `context` to the project root.
390
420
391
-
#### colors _(boolean) (default=true)_
421
+
#### colors
422
+
| Type | Default Value |
423
+
|------|--------------|
424
+
|`boolean`|`true`|
392
425
393
426
If `false`, disables built-in colors in logger messages.
By default `ts-loader` formats TypeScript compiler output for an error or a warning in the style:
398
434
@@ -435,20 +471,32 @@ Does not compute.... code: 2307,severity: error,content: Cannot find module 'com
435
471
436
472
And the bit after "Does not compute.... " would be red.
437
473
438
-
#### compilerOptions _(object) (default={})_
474
+
#### compilerOptions
475
+
| Type | Default Value |
476
+
|------|--------------|
477
+
|`object`|`{}`|
439
478
440
479
Allows overriding TypeScript options. Should be specified in the same format
441
480
as you would do for the `compilerOptions` property in tsconfig.json.
442
481
443
-
#### instance _(string)_
482
+
#### instance
483
+
| Type | Default Value |
484
+
|------|--------------|
485
+
|`string`|`TODO`|
444
486
445
487
Advanced option to force files to go through different instances of the
446
488
TypeScript compiler. Can be used to force segregation between different parts
447
489
of your code.
448
490
449
-
#### appendTsSuffixTo _(RegExp[]) (default=[])_
491
+
#### appendTsSuffixTo
492
+
| Type | Default Value |
493
+
|------|--------------|
494
+
|`RegExp[]`|`[]`|
450
495
451
-
#### appendTsxSuffixTo _(RegExp[]) (default=[])_
496
+
#### appendTsxSuffixTo
497
+
| Type | Default Value |
498
+
|------|--------------|
499
+
|`RegExp[]`|`[]`|
452
500
453
501
A list of regular expressions to be matched against filename. If filename matches one of the regular expressions, a `.ts` or `.tsx` suffix will be appended to that filename.
454
502
@@ -551,7 +599,10 @@ Or if you want to use only tsx, just use the `appendTsxSuffixTo` option only:
By default whenever the TypeScript compiler needs to check that a file/directory exists or resolve symlinks it makes syscalls. It does not cache the result of these operations and this may result in many syscalls with the same arguments ([see comment](https://github.com/TypeStrong/ts-loader/issues/825#issue-354725524) with example).
630
690
In some cases it may produce performance degradation.
631
691
632
692
This flag enables caching for some FS-functions like `fileExists`, `realpath` and `directoryExists` for TypeScript compiler. Note that caches are cleared between compilations.
ts-loader has opt-in support for [project references](https://www.typescriptlang.org/docs/handbook/project-references.html). With this configuration option enabled, `ts-loader` will incrementally rebuild upstream projects the same way `tsc --build` does. Otherwise, source files in referenced projects will be treated as if they’re part of the root project.
637
700
@@ -656,7 +719,7 @@ We do not support HMR as we did not yet work out a reliable way how to set it up
656
719
657
720
If you want to give `webpack-dev-server` HMR a try, follow the official [webpack HMR guide](https://webpack.js.org/guides/hot-module-replacement/), then tweak a few config options for `ts-loader`:
658
721
659
-
1. Set `transpileOnly` to `true` (see [transpileOnly](#transpileonly-boolean-defaultfalse) for config details and recommendations above).
722
+
1. Set `transpileOnly` to `true` (see [transpileOnly](#transpileonly) for config details and recommendations above).
660
723
2. Inside your HMR acceptance callback function, maybe re-require the module that was replaced.
0 commit comments