ts-loader
Advanced tools
Comparing version 9.2.9 to 9.3.0
# Changelog | ||
## v9.3.0 | ||
* [simplify configuration for fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/ts-loader/pull/1451) - thanks @piotr-oles | ||
## v9.2.9 | ||
@@ -4,0 +8,0 @@ |
@@ -103,3 +103,3 @@ "use strict"; | ||
validateLoaderOptions(loaderOptions); | ||
const options = makeLoaderOptions(instanceName, loaderOptions); | ||
const options = makeLoaderOptions(instanceName, loaderOptions, loaderContext); | ||
cache.set(loaderOptions, options); | ||
@@ -158,3 +158,9 @@ return options; | ||
} | ||
function makeLoaderOptions(instanceName, loaderOptions) { | ||
function makeLoaderOptions(instanceName, loaderOptions, loaderContext) { | ||
var _a; | ||
const hasForkTsCheckerWebpackPlugin = (_a = loaderContext._compiler) === null || _a === void 0 ? void 0 : _a.options.plugins.some(plugin => { | ||
var _a; | ||
return typeof plugin === 'object' && | ||
((_a = plugin.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'ForkTsCheckerWebpackPlugin'; | ||
}); | ||
const options = Object.assign({}, { | ||
@@ -166,3 +172,4 @@ silent: false, | ||
context: undefined, | ||
transpileOnly: false, | ||
// Set default transpileOnly to true if there is an instance of ForkTsCheckerWebpackPlugin | ||
transpileOnly: hasForkTsCheckerWebpackPlugin, | ||
compilerOptions: {}, | ||
@@ -169,0 +176,0 @@ appendTsSuffixTo: [], |
{ | ||
"name": "ts-loader", | ||
"version": "9.2.9", | ||
"version": "9.3.0", | ||
"description": "TypeScript loader for webpack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -114,11 +114,13 @@ # TypeScript loader for webpack | ||
- 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. | ||
- I want the fastest compilation that's available. Use [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin). It performs type checking in a separate process with `ts-loader` just handling transpilation. | ||
### Faster Builds | ||
As your project becomes bigger, compilation time increases linearly. It's because typescript's semantic checker has to inspect all files on every rebuild. The simple solution is to disable it by using the `transpileOnly: true` option, but doing so leaves you without type checking and *will not output declaration files*. | ||
As your project becomes bigger, compilation time increases linearly. It's because typescript's semantic checker has to inspect all files on every rebuild. | ||
The simple solution is to disable it by using the `transpileOnly: true` option, but doing so leaves you without type checking and *will not output declaration files*. | ||
You probably don't want to give up type checking; that's rather the point of TypeScript. So what you can do is use the [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin). It runs the type checker on a separate process, so your build remains fast thanks to `transpileOnly: true` but you still have the type checking. Also, the plugin has several optimizations to make incremental type checking faster (AST cache, multiple workers). | ||
You probably don't want to give up type checking; that's rather the point of TypeScript. So what you can do is use the [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin). | ||
It runs the type checker on a separate process, so your build remains fast thanks to `transpileOnly: true` but you still have the type checking. | ||
If you'd like to see a simple setup take a look at [our simple example](examples/fork-ts-checker-webpack-plugin/). For a more complex setup take a look at our [more involved example](examples/react-babel-karma-gulp). | ||
If you'd like to see a simple setup take a look at [our example](examples/fork-ts-checker-webpack-plugin/). | ||
@@ -284,4 +286,6 @@ ### Yarn Plug’n’Play | ||
It's advisable to use `transpileOnly` alongside 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 example](examples/fork-ts-checker-webpack-plugin). For a more complex setup take a look at our [more involved example](examples/react-babel-karma-gulp). | ||
It's advisable to use `transpileOnly` alongside the [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/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 example](examples/fork-ts-checker-webpack-plugin). | ||
> Tip: When you add the [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin) to your webpack config, the `transpileOnly` will default to `true`, so you can skip that option. | ||
If you enable this option, webpack 4 will give you "export not found" warnings any time you re-export a type: | ||
@@ -314,3 +318,3 @@ | ||
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. **_IMPORTANT_**: If you are using fork-ts-checker-webpack-plugin alongside HappyPack or thread-loader then ensure you set the `syntactic` diagnostic option like so: | ||
It's advisable to use this with the [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin) to get full type checking again. **_IMPORTANT_**: If you are using fork-ts-checker-webpack-plugin alongside HappyPack or thread-loader then ensure you set the `syntactic` diagnostic option like so: | ||
@@ -317,0 +321,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
250560
3059
765