Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-loader

Package Overview
Dependencies
Maintainers
3
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-loader - npm Package Compare versions

Comparing version 6.2.1 to 6.2.2

3

CHANGELOG.md
# Changelog
## v6.2.2
* [Enable typescript 3.8.3 support when using `webpack.config.ts` files](https://github.com/TypeStrong/ts-loader/issues/1072) - thanks @vladimiry!
## v6.2.1

@@ -4,0 +7,0 @@ * [Output types alongside JS files, enable declaration maps](https://github.com/TypeStrong/ts-loader/pull/1026) - thanks @meyer!

4

dist/interfaces.d.ts

@@ -48,5 +48,5 @@ export { ModuleResolutionHost, FormatDiagnosticsHost } from 'typescript';

/** Used to watch changes in source files, missing files needed to update the program or config file */
watchFile(path: string, callback: typescript.FileWatcherCallback, pollingInterval?: number): typescript.FileWatcher;
watchFile(path: string, callback: typescript.FileWatcherCallback, pollingInterval?: number, options?: typescript.CompilerOptions): typescript.FileWatcher;
/** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */
watchDirectory(path: string, callback: typescript.DirectoryWatcherCallback, recursive?: boolean): typescript.FileWatcher;
watchDirectory(path: string, callback: typescript.DirectoryWatcherCallback, recursive?: boolean, options?: typescript.CompilerOptions): typescript.FileWatcher;
}

@@ -53,0 +53,0 @@ export interface SolutionDiagnostics {

{
"name": "ts-loader",
"version": "6.2.1",
"version": "6.2.2",
"description": "TypeScript loader for webpack",

@@ -16,3 +16,4 @@ "main": "index.js",

"docker:build": "docker build -t ts-loader .",
"postdocker:build": "docker run -it ts-loader yarn test"
"postdocker:build": "docker run -it ts-loader yarn test",
"generate-toc": "markdown-toc -i ./README.md && git add README.md && git commit -m \"chore: update docs\""
},

@@ -87,2 +88,3 @@ "husky": {

"lint-staged": "^8.0.0",
"markdown-toc": "^1.2.0",
"mkdirp": "^0.5.1",

@@ -89,0 +91,0 @@ "mocha": "^6.0.0",

@@ -11,6 +11,99 @@ # TypeScript loader for webpack

This is the TypeScript loader for webpack.
<br />
<p align="center">
<h3 align="center">ts-loader</h3>
<p align="center">
This is the TypeScript loader for webpack.
<br />
<br />
<a href="https://github.com/TypeStrong/ts-loader/issues">Installation</a>
·
<a href="https://github.com/TypeStrong/ts-loader/issues">Report Bug</a>
·
<a href="https://github.com/TypeStrong/ts-loader/issues">Request Feature</a>
</p>
</p>
## Table of Contents
<!-- toc -->
- [Getting Started](#getting-started)
* [Installation](#installation)
* [Running](#running)
* [Examples](#examples)
* [Faster Builds](#faster-builds)
* [Yarn Plug’n’Play](#yarn-plugnplay)
* [Babel](#babel)
* [Parallelising Builds](#parallelising-builds)
* [Compatibility](#compatibility)
* [Configuration](#configuration)
+ [`devtool` / sourcemaps](#devtool--sourcemaps)
* [Code Splitting and Loading Other Resources](#code-splitting-and-loading-other-resources)
* [Declarations (.d.ts)](#declarations-dts)
* [Failing the build on TypeScript compilation error](#failing-the-build-on-typescript-compilation-error)
* [`baseUrl` / `paths` module resolution](#baseurl--paths-module-resolution)
* [Options](#options)
* [Loader Options](#loader-options)
+ [transpileOnly](#transpileonly)
+ [happyPackMode](#happypackmode)
+ [resolveModuleName and resolveTypeReferenceDirective](#resolvemodulename-and-resolvetypereferencedirective)
+ [getCustomTransformers](#getcustomtransformers)
+ [logInfoToStdOut](#loginfotostdout)
+ [logLevel](#loglevel)
+ [silent](#silent)
+ [ignoreDiagnostics](#ignorediagnostics)
+ [reportFiles](#reportfiles)
+ [compiler](#compiler)
+ [configFile](#configfile)
+ [colors](#colors)
+ [errorFormatter](#errorformatter)
+ [compilerOptions](#compileroptions)
+ [instance](#instance)
+ [appendTsSuffixTo](#appendtssuffixto)
+ [appendTsxSuffixTo](#appendtsxsuffixto)
+ [onlyCompileBundledFiles](#onlycompilebundledfiles)
+ [allowTsInNodeModules](#allowtsinnodemodules)
+ [context](#context)
+ [experimentalFileCaching](#experimentalfilecaching)
+ [projectReferences](#projectreferences)
* [Usage with webpack watch](#usage-with-webpack-watch)
* [Hot Module replacement](#hot-module-replacement)
- [Contributing](#contributing)
- [License](#license)
<!-- tocstop -->
## Getting Started
### Installation
```
yarn add ts-loader --dev
```
or
```
npm install ts-loader --save-dev
```
You will also need to install TypeScript if you have not already.
```
yarn add typescript --dev
```
or
```
npm install typescript --save-dev
```
### 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).
### Examples

@@ -22,3 +115,3 @@

- I want the simplest setup going. Use "[vanilla](examples/vanilla)" ts-loader
- I want the simplest setup going. Use "[vanilla](examples/vanilla)" `ts-loader`
- 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.

@@ -40,3 +133,3 @@

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).
`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).

@@ -53,38 +146,9 @@ ### Parallelising Builds

### Installation
```
yarn add ts-loader --dev
```
or
```
npm install ts-loader --save-dev
```
You will also need to install TypeScript if you have not already.
```
yarn add typescript --dev
```
or
```
npm install typescript --save-dev
```
### 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
* TypeScript: 2.4.1+
* webpack: 4.x+ (please use ts-loader 3.x if you need webpack 2 or 3 support)
* webpack: 4.x+ (please use `ts-loader` 3.x if you need webpack 2 or 3 support)
* node: 6.11.5 minimum (aligned with webpack 4)
A full test suite runs each night (and on each pull request). It runs both on [Linux](https://travis-ci.org/TypeStrong/ts-loader) and [Windows](https://ci.appveyor.com/project/JohnReilly/ts-loader), testing ts-loader against major releases of TypeScript. The test suite also runs against TypeScript@next (because we want to use it as much as you do).
A full test suite runs each night (and on each pull request). It runs both on [Linux](https://travis-ci.org/TypeStrong/ts-loader) and [Windows](https://ci.appveyor.com/project/JohnReilly/ts-loader), testing `ts-loader` against major releases of TypeScript. The test suite also runs against TypeScript@next (because we want to use it as much as you do).

@@ -134,5 +198,5 @@ If you become aware of issues not caught by the test suite then please let us know. Better yet, write a test and submit it in a PR!

If you want to be able to debug your original source then you can thanks to the magic of sourcemaps. There are 2 steps to getting this set up with ts-loader and webpack.
If you want to be able to debug your original source then you can thanks to the magic of sourcemaps. There are 2 steps to getting this set up with `ts-loader` and webpack.
First, for ts-loader to produce **sourcemaps**, you will need to set the [tsconfig.json](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) option as `"sourceMap": true`.
First, for `ts-loader` to produce **sourcemaps**, you will need to set the [tsconfig.json](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) option as `"sourceMap": true`.

@@ -227,3 +291,6 @@ Second, you need to set the `devtool` option in your `webpack.config.js` to support the type of sourcemaps you want. To make your choice have a read of the [`devtool` webpack docs](https://webpack.js.org/configuration/devtool/). You may be somewhat daunted by the choice available. You may also want to vary the sourcemap strategy depending on your build environment. Here are some example strategies for different environments:

#### transpileOnly _(boolean) (default=false)_
#### transpileOnly
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|

@@ -256,3 +323,6 @@ If you want to speed up compilation significantly you can set this flag.

#### happyPackMode _(boolean) (default=false)_
#### happyPackMode
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|

@@ -267,11 +337,14 @@ 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.

This will ensure that the plugin checks for both syntactic errors (eg `const array = [{} {}];`) and semantic errors (eg `const x: number = '1';`). By default the plugin only checks for semantic errors (as when used with ts-loader in `transpileOnly` mode, ts-loader will still report syntactic errors).
This will ensure that the plugin checks for both syntactic errors (eg `const array = [{} {}];`) and semantic errors (eg `const x: number = '1';`). By default the plugin only checks for semantic errors (as when used with `ts-loader` in `transpileOnly` mode, `ts-loader` will still report syntactic errors).
Also, if you are using `thread-loader` in watch mode, remember to set `poolTimeout: Infinity` so workers don't die.
#### resolveModuleName and resolveTypeReferenceDirective:
#### resolveModuleName and resolveTypeReferenceDirective
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).
#### getCustomTransformers _( (program: Program) => { before?: TransformerFactory<SourceFile>[]; after?: TransformerFactory<SourceFile>[]; } )_
#### getCustomTransformers
| Type |
|------|
| ` (program: Program) => { before?: TransformerFactory<SourceFile>[]; after?: TransformerFactory<SourceFile>[]; } ` |

@@ -282,3 +355,6 @@ 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).

#### logInfoToStdOut _(boolean) (default=false)_
#### logInfoToStdOut
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|

@@ -288,3 +364,6 @@ This is important if you read from stdout or stderr and for proper error handling.

#### logLevel _(string) (default=warn)_
#### logLevel
| Type | Default Value |
|------|--------------|
| `string` | `warn` |

@@ -294,3 +373,6 @@ Can be `info`, `warn` or `error` which limits the log output to the specified log level.

#### silent _(boolean) (default=false)_
#### silent
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|

@@ -300,3 +382,6 @@ If `true`, no console.log messages will be emitted. Note that most error

#### ignoreDiagnostics _(number[]) (default=[])_
#### ignoreDiagnostics
| Type | Default Value |
|------|--------------|
| `number[]` | `[]`|

@@ -306,3 +391,6 @@ You can squelch certain TypeScript errors by specifying an array of diagnostic

#### reportFiles _(string[]) (default=[])_
#### reportFiles
| Type | Default Value |
|------|--------------|
| `string[]` | `[]`|

@@ -322,3 +410,6 @@ Only report errors on files matching these glob patterns.

#### compiler _(string) (default='typescript')_
#### compiler
| Type | Default Value |
|------|--------------|
| `string` | `'typescript'`|

@@ -328,3 +419,6 @@ Allows use of TypeScript compilers other than the official one. Should be

#### configFile _(string) (default='tsconfig.json')_
#### configFile
| Type | Default Value |
|------|--------------|
| `string` | `'tsconfig.json'`|

@@ -342,9 +436,15 @@ Allows you to specify where to find the TypeScript configuration file.

#### colors _(boolean) (default=true)_
#### colors
| Type | Default Value |
|------|--------------|
| `boolean` | `true`|
If `false`, disables built-in colors in logger messages.
#### errorFormatter _((message: ErrorInfo, colors: boolean) => string) (default=undefined)_
#### errorFormatter
| Type | Default Value |
|------|--------------|
| `(message: ErrorInfo, colors: boolean) => string` | `undefined`|
By default ts-loader formats TypeScript compiler output for an error or a warning in the style:
By default `ts-loader` formats TypeScript compiler output for an error or a warning in the style:

@@ -390,3 +490,6 @@ ```

#### compilerOptions _(object) (default={})_
#### compilerOptions
| Type | Default Value |
|------|--------------|
| `object` | `{}`|

@@ -396,3 +499,6 @@ Allows overriding TypeScript options. Should be specified in the same format

#### instance _(string)_
#### instance
| Type | Default Value |
|------|--------------|
| `string` | `TODO`|

@@ -403,5 +509,11 @@ Advanced option to force files to go through different instances of the

#### appendTsSuffixTo _(RegExp[]) (default=[])_
#### appendTsSuffixTo
| Type | Default Value |
|------|--------------|
| `RegExp[]` | `[]`|
#### appendTsxSuffixTo _(RegExp[]) (default=[])_
#### appendTsxSuffixTo
| Type | Default Value |
|------|--------------|
| `RegExp[]` | `[]`|

@@ -509,5 +621,8 @@ 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.

#### onlyCompileBundledFiles _(boolean) (default=false)_
#### onlyCompileBundledFiles
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|
The default behavior of ts-loader is to act as a drop-in replacement for the `tsc` command,
The default behavior of `ts-loader` is to act as a drop-in replacement for the `tsc` command,
so it respects the `include`, `files`, and `exclude` options in your `tsconfig.json`, loading

@@ -519,5 +634,8 @@ any files specified by those options. The `onlyCompileBundledFiles` option modifies this behavior,

#### allowTsInNodeModules _(boolean) (default=false)_
#### allowTsInNodeModules
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|
By default, ts-loader will not compile `.ts` files in `node_modules`.
By default, `ts-loader` will not compile `.ts` files in `node_modules`.
You should not need to recompile `.ts` files there, but if you really want to, use this option.

@@ -551,3 +669,6 @@ Note that this option acts as a *whitelist* - any modules you desire to import must be included in

#### context _(string) (default=undefined)_
#### context
| Type | Default Value |
|------|--------------|
| `string` | `undefined`|

@@ -585,3 +706,6 @@ If set, will parse the TypeScript configuration file with given **absolute path** as base path.

#### experimentalFileCaching _(boolean) (default=true)_
#### experimentalFileCaching
| Type | Default Value |
|------|--------------|
| `boolean` | `true`|

@@ -593,5 +717,8 @@ 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).

#### projectReferences _(boolean) (default=false)_
#### projectReferences
| Type | Default Value |
|------|--------------|
| `boolean` | `false`|
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.
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.

@@ -619,3 +746,3 @@ ### Usage with webpack watch

1. Set `transpileOnly` to `true` (see [transpileOnly](#transpileonly-boolean-defaultfalse) for config details and recommendations above).
1. Set `transpileOnly` to `true` (see [transpileOnly](#transpileonly) for config details and recommendations above).
2. Inside your HMR acceptance callback function, maybe re-require the module that was replaced.

@@ -622,0 +749,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc