How to use fork-ts-checker-webpack-plugin - 10 common examples

To help you get started, we’ve selected a few fork-ts-checker-webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnnyreilly / fork-ts-checker-notifier-webpack-plugin / index.ts View on Github external
apply(compiler: any) {
    if ('hooks' in compiler) {
      // webpack 4+
      try {
        forkTsCheckerWebpackPlugin
          .getCompilerHooks(compiler)
          .receive.tap('fork-ts-checker-notifier-webpack-plugin', this.compilationDone);
      } catch (error) {
        console.error(`
          Something went wrong in accessing the hooks.
          Most likely the order of plugins is wrong.\n
          Check the documentation for "fork-ts-checker-notifier-webpack-plugin"\n
        `);
        throw Error(`Error: ${error}`);
      }
    } else {
      // webpack 2 / 3
      compiler.plugin('fork-ts-checker-receive', this.compilationDone);
    }
  }
}
github lskjs / lskjs / packages / lsk-build / src / WebpackConfig.js View on Github external
getPlugins() {
    return [
      // Define free variables
      // https://webpack.github.io/docs/list-of-plugins.html#defineplugin
      new webpack.LoaderOptionsPlugin({
        // debug: this.isDebug(),
      }),
      new webpack.DefinePlugin(this.getGlobals()),
      new ExtractTextPlugin(this.isDebug() ? '[name].css?[chunkhash]' : '[name].[chunkhash].css'),
      ...!this.webpackStats ? [] : [new StatsPlugin(`webpack.${this.getTarget() === 'node' ? 'server' : 'client'}.stats.json`, this.webpackStats)],
      new webpack.ProvidePlugin({
        Promise: 'bluebird',
      }),
      ...((this.isTypescriptSupport() && this.name === 'client') ? [
        new ForkTsCheckerWebpackPlugin({
          async: false,
          ...(this.isDebug() ? {
            watch: this.resolvePath(srcDir),
            memoryLimit: 4096,
          } : {}),
          tsconfig: this.resolvePath('tsconfig.json'),
          tslint: this.resolvePath('tslint.json'),
        }),
      ] : [])
    ];
  }
github lskjs / lskjs / packages / build / src2 / WebpackConfig.js View on Github external
getPlugins() {
    return [
      // Define free variables
      // https://webpack.github.io/docs/list-of-plugins.html#defineplugin
      new webpack.LoaderOptionsPlugin({
        // debug: this.isDebug(),
      }),
      new webpack.DefinePlugin(this.getGlobals()),
      new ExtractTextPlugin(this.isDebug() ? '[name].css?[chunkhash]' : '[name].[chunkhash].css'),
      ...!this.webpackStats ? [] : [new StatsPlugin(`webpack.${this.getTarget() === 'node' ? 'server' : 'client'}.stats.json`, this.webpackStats)],
      new webpack.ProvidePlugin({
        Promise: 'bluebird',
      }),
      ...((this.isTypescriptSupport() && this.name === 'client') ? [
        new ForkTsCheckerWebpackPlugin({
          async: false,
          ...(this.isDebug() ? {
            watch: this.resolvePath('src'),
            memoryLimit: 4096,
          } : {}),
          tsconfig: this.resolvePath('tsconfig.json'),
          tslint: this.resolvePath('tslint.json'),
        }),
      ] : []),
    ];
  }
github lskjs / lskjs / packages / lsk-modules / packages / build / src / WebpackConfig.js View on Github external
getPlugins() {
    return [
      // Define free variables
      // https://webpack.github.io/docs/list-of-plugins.html#defineplugin
      new webpack.LoaderOptionsPlugin({
        // debug: this.isDebug(),
      }),
      new webpack.DefinePlugin(this.getGlobals()),
      new ExtractTextPlugin(this.isDebug() ? '[name].css?[chunkhash]' : '[name].[chunkhash].css'),
      ...!this.webpackStats ? [] : [new StatsPlugin(`webpack.${this.getTarget() === 'node' ? 'server' : 'client'}.stats.json`, this.webpackStats)],
      new webpack.ProvidePlugin({
        Promise: 'bluebird',
      }),
      ...((this.isTypescriptSupport() && this.name === 'client') ? [
        new ForkTsCheckerWebpackPlugin({
          async: false,
          ...(this.isDebug() ? {
            watch: this.resolvePath(srcDir),
            memoryLimit: 4096,
          } : {}),
          tsconfig: this.resolvePath('tsconfig.json'),
          tslint: this.resolvePath('tslint.json'),
        }),
      ] : [])
    ];
  }
github gocd / gocd / server / webapp / WEB-INF / rails / webpack / config / plugins.ts View on Github external
}) as webpack.Plugin,
    new SassLintPlugin() as webpack.Plugin,
    new StatsPlugin("manifest.json", {
      chunkModules: false,
      source: false,
      chunks: false,
      modules: false,
      assets: true
    }) as webpack.Plugin,
    new webpack.ProvidePlugin({
                                "$": "jquery",
                                "jQuery": "jquery",
                                "window.jQuery": "jquery"
                              }) as webpack.Plugin,
    new LicensePlugins(configOptions.licenseReportFile),
    new ForkTsCheckerWebpackPlugin({
                                     checkSyntacticErrors: true,
                                     useTypescriptIncrementalApi: true,
                                   })
  ];

  if (configOptions.production) {
    plugins.push(new MiniCssExtractPlugin({
                                            // Options similar to the same options in webpackOptions.output
                                            // both options are optional
                                            filename: "[name]-[hash].css",
                                            chunkFilename: "[id]-[hash].css",
                                          }));
    plugins.push(new OptimizeCssAssetsPlugin());
  } else {
    const jasmineFiles = jasmineCore.files;
github pixeloven / pixeloven / packages / pixeloven-storybook / config / src / webpack.config.ts View on Github external
{
                        loader: require.resolve("sass-loader"),
                        options: {
                            // Prefer `dart-sass`
                            implementation: require("sass"),
                        },
                    },
                ],
            },
        ],
    };
    config.module = config.module ? deepmerge(config.module, modules) : modules;

    // Plugins
    // @todo we should use the same setup as webpack and also this should have two modes
    const forkTsPlugin = new ForkTsCheckerWebpackPlugin({
        silent: true,
        tsconfig: resolveTsConfig(),
    });
    if (config.plugins) {
        config.plugins.push(forkTsPlugin);
    } else {
        config.plugins = [forkTsPlugin];
    }
    if (config.resolve) {
        // Aliases
        if (config.resolve.alias) {
            config.resolve.alias["@src"] = resolveSourceRoot();
        } else {
            config.resolve.alias = {
                "@src": resolveSourceRoot(),
            };
github xmazu / react-inline-suggest / scripts / webpack.dev.config.js View on Github external
devtool: 'source-map',

  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.scss', '.css'],
    modules: [absolute('src'), absolute('node_modules')],
  },
  plugins: [
    // Provide NODE_ENV variable
    new webpack.DefinePlugin({
      'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
    }),
    // Fork type-check to separate process
    new ForkTsCheckerPlugin({
      workers: ForkTsCheckerPlugin.TWO_CPUS_FREE,
      watch: ['src']
    }),
    new HtmlPlugin({
      template: 'example/index.html',
      hash: false,
      filename: 'index.html',
      inject: 'body',
    }),
    new webpack.NoEmitOnErrorsPlugin()
  ],

  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [
github stardog-union / stardog-language-servers / packages / sms-language-server / webpack.config.js View on Github external
}
    ],
  },
  resolve: {
    modules: [SRC_DIR, 'node_modules'],
    extensions: ['.ts', '.js'],
  },
  plugins: [
    new BannerPlugin({
      banner: '#!/usr/bin/env node',
    }),
    new ForkTsCheckerWebpackPlugin({
      tsconfig: path.resolve(__dirname, 'tsconfig.json'),
      watch: SRC_DIR,
      // CI memory limits make building with more than one CPU for type-checking too fragile, unfortunately
      workers: isCI ? ForkTsCheckerWebpackPlugin.ONE_CPU : ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
      memoryLimit: 4096,
    }),
  ],
  devtool: 'source-map',
  optimization: {
    minimizer: [
      new TerserPlugin({
        sourceMap: true,
        terserOptions: {
          // Chevrotain does not cooperate with webpack mangling (see here: https://sap.github.io/chevrotain/docs/FAQ.html#MINIFIED).
          mangle: {
            reserved,
          },
        },
      }),
    ],
github stardog-union / stardog-language-servers / packages / shacl-language-server / webpack.config.js View on Github external
},
  resolve: {
    modules: [SRC_DIR, 'node_modules'],
    extensions: ['.ts', '.js'],
  },
  plugins: [
    new BannerPlugin({
      banner: '#!/usr/bin/env node',
    }),
    new ForkTsCheckerWebpackPlugin({
      tsconfig: path.resolve(__dirname, 'tsconfig.json'),
      watch: SRC_DIR,
      // CI memory limits make building with more than one CPU for type-checking too fragile, unfortunately
      workers: isCI
        ? ForkTsCheckerWebpackPlugin.ONE_CPU
        : ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
      memoryLimit: 4096,
    }),
  ],
  devtool: 'source-map',
  optimization: {
    minimizer: [
      new TerserPlugin({
        sourceMap: true,
        terserOptions: {
          // Chevrotain does not cooperate with webpack mangling (see here: https://sap.github.io/chevrotain/docs/FAQ.html#MINIFIED).
          mangle: {
            reserved,
          },
        },
      }),
    ],
github stardog-union / stardog-language-servers / packages / stardog-language-utils / webpack.config.js View on Github external
exclude: [/node_modules/],
      },
    ],
  },
  resolve: {
    modules: [SRC_DIR, 'node_modules'],
    extensions: ['.ts', '.js'],
  },
  plugins: [
    new ForkTsCheckerWebpackPlugin({
      tsconfig: path.resolve(__dirname, 'tsconfig.json'),
      watch: SRC_DIR,
      // CI memory limits make building with more than one CPU for type-checking too fragile, unfortunately
      workers: isCI
        ? ForkTsCheckerWebpackPlugin.ONE_CPU
        : ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
      memoryLimit: 4096,
    }),
    new CopyWebpackPlugin([
      {
        from: `${SRC_DIR}/index.d.ts`,
        to: path.join(DIST_DIR, 'types', 'index.d.ts'),
      },
    ]),
  ],
  devtool: 'source-map',
};

const workerConfig = {
  mode: 'production',
  target: 'webworker',
  entry: path.join(SRC_DIR, 'worker.ts'),