MCPcopy
hub / github.com/TypeStrong/fork-ts-checker-webpack-plugin

github.com/TypeStrong/fork-ts-checker-webpack-plugin @v9.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v9.1.0 ↗
314 symbols 837 edges 143 files 2 documented · 1%
README

SWUbanner

Fork TS Checker Webpack Plugin

Webpack plugin that runs TypeScript type checker on a separate process.

npm version build status downloads commitizen friendly code style: prettier semantic-release

Features

Installation

This plugin requires Node.js >=14.0.0+, Webpack ^5.11.0, TypeScript ^3.6.0

  • If you depend on TypeScript 2.1 - 2.6.2, please use version 4 of the plugin.
  • If you depend on Webpack 4, TypeScript 2.7 - 3.5.3 or ESLint feature, please use version 6 of the plugin.
  • If you depend on Node.js 12, please use version 8 of the plugin.
  • If you need Vue.js support, please use version 6 of ths plugin
# with npm
npm install --save-dev fork-ts-checker-webpack-plugin

# with yarn
yarn add --dev fork-ts-checker-webpack-plugin

# with pnpm
pnpm add -D fork-ts-checker-webpack-plugin

The minimal webpack config (with ts-loader)

// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
  context: __dirname, // to automatically find tsconfig.json
  entry: './src/index.ts',
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        // add transpileOnly option if you use ts-loader < 9.3.0 
        // options: {
        //   transpileOnly: true
        // }
      }
    ]
  },
  plugins: [new ForkTsCheckerWebpackPlugin()],
  watchOptions: {
    // for some systems, watching many files can result in a lot of CPU or memory usage
    // https://webpack.js.org/configuration/watch/#watchoptionsignored
    // don't use this pattern, if you have a monorepo with linked packages
    ignored: /node_modules/,
  },
};

Examples how to configure it with babel-loader, ts-loader and Visual Studio Code are in the examples directory.

Modules resolution

It's very important to be aware that this plugin uses TypeScript's, not webpack's modules resolution. It means that you have to setup tsconfig.json correctly.

It's because of the performance - with TypeScript's module resolution we don't have to wait for webpack to compile files.

To debug TypeScript's modules resolution, you can use tsc --traceResolution command.

Options

This plugin uses cosmiconfig. This means that besides the plugin constructor, you can place your configuration in the: * "fork-ts-checker" field in the package.json * .fork-ts-checkerrc file in JSON or YAML format * fork-ts-checker.config.js file exporting a JS object

Options passed to the plugin constructor will overwrite options from the cosmiconfig (using deepmerge).

Name Type Default value Description
async boolean compiler.options.mode === 'development' If true, reports issues after webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the watch mode.
typescript object {} See TypeScript options.
issue object {} See Issues options.
formatter string or object or function codeframe Available formatters are basic, codeframe and a custom function. To configure codeframe formatter, pass: { type: 'codeframe', options: { <coderame options> } }. To use absolute file path, pass: { type: 'codeframe', pathType: 'absolute' }.
logger { log: function, error: function } or webpack-infrastructure console Console-like object to print issues in async mode.
devServer boolean true If set to false, errors will not be reported to Webpack Dev Server.

TypeScript options

Options for the TypeScript checker (typescript option object).

Name Type Default value Description
memoryLimit number 2048 Memory limit for the checker process in MB. If the process exits with the allocation failed error, try to increase this number.
configFile string 'tsconfig.json' Path to the tsconfig.json file (path relative to the compiler.options.context or absolute path)
configOverwrite object { compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } } This configuration will overwrite configuration from the tsconfig.json file. Supported fields are: extends, compilerOptions, include, exclude, files, and references.
context string dirname(configuration.configFile) The base path for finding files specified in the tsconfig.json. Same as the context option from the ts-loader. Useful if you want to keep your tsconfig.json in an external package. Keep in mind that not having a tsconfig.json in your project root can cause different behaviour between fork-ts-checker-webpack-plugin and tsc. When using editors like VS Code it is advised to add a tsconfig.json file to the root of the project and extend the config file referenced in option configFile.
build boolean false The equivalent of the --build flag for the tsc command.
mode 'readonly' or 'write-dts' or 'write-tsbuildinfo' or 'write-references' `build === true ? 'write-tsbuildin

Extension points exported contracts — how you extend this code

QueuedListener (Interface)
(no doc) [1 implementers]
test/e2e/driver/listener.ts
WatchFileSystem (Interface)
(no doc) [1 implementers]
src/watch/watch-file-system.ts
FilesMatch (Interface)
(no doc)
src/files-match.ts
InfrastructureLogger (Interface)
(no doc)
src/infrastructure-logger.ts
FilesChange (Interface)
(no doc)
src/files-change.ts
ForkTsCheckerWebpackPluginState (Interface)
(no doc)
src/plugin-state.ts
ForkTsCheckerWebpackPluginOptions (Interface)
(no doc)
src/plugin-options.ts
Logger (Interface)
(no doc)
src/logger.ts

Core symbols most depended-on inside this repo

exists
called by 54
src/typescript/worker/lib/file-system/file-system.ts
resolve
called by 31
test/e2e/driver/listener.ts
log
called by 16
src/infrastructure-logger.ts
realPath
called by 15
src/typescript/worker/lib/file-system/file-system.ts
createWebpackDevServerDriver
called by 13
test/e2e/driver/webpack-dev-server-driver.ts
submit
called by 13
src/utils/async/pool.ts
updateFilesChange
called by 11
src/files-change.ts
forwardSlash
called by 11
src/utils/path/forward-slash.ts

Shape

Function 216
Method 53
Interface 33
Class 12

Languages

TypeScript100%

Modules by API surface

src/typescript/worker/lib/system.ts41 symbols
src/typescript/worker/lib/config.ts14 symbols
src/typescript/worker/lib/file-system/real-file-system.ts12 symbols
src/typescript/worker/lib/file-system/file-system.ts12 symbols
src/typescript/worker/lib/host/watch-solution-builder-host.ts10 symbols
test/e2e/driver/webpack-dev-server-driver.ts9 symbols
test/e2e/driver/listener.ts9 symbols
src/typescript/worker/lib/file-system/mem-file-system.ts9 symbols
src/rpc/rpc-worker.ts9 symbols
src/typescript/worker/lib/performance.ts7 symbols
src/infrastructure-logger.ts7 symbols
src/files-change.ts7 symbols

Dependencies from manifests, versioned

@babel/code-frame7.16.7 · 1×
@babel/core7.10.0 · 1×
@babel/preset-env7.10.0 · 1×
@babel/preset-typescript7.9.0 · 1×
@commitlint/config-conventional16.0.0 · 1×
@project-references-fixture/shared1.0.0 · 1×
@semantic-release/commit-analyzer8.0.1 · 1×
@semantic-release/exec5.0.0 · 1×
@semantic-release/npm7.1.3 · 1×
@semantic-release/release-notes-generator9.0.3 · 1×
@types/babel__code-frame7.0.3 · 1×

For agents

$ claude mcp add fork-ts-checker-webpack-plugin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact