npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

forktschecker-hook-loader

v1.0.2

Published

No emit assets if tsForkChecker has errors

Downloads

4

Readme

Fork TS Checker Hook Loader

What it does?

Allows Webpack to handle errors from ForkTsChecker and HappyPack while these run in a separate process.

Description

Works together with Fork Ts Checker Webpack Plugin, HappyPack, and ts-loader. While ForkTSChecker works in a separate process, the loader listens for the hook fork-ts-checker-receive and fork-ts-checker-done right before the files are emitted, so it's possible to pass control to Webpack to handle errors and warnings.

Installation

Install the following packages:

npm install --save-dev forktschecker-hook-loader
npm install --save-dev fork-ts-checker-webpack-plugin happypack cache-loader

Examples

You can check an example in the example folder

Alternatively, you can:

  1. Clone the repository
  2. Run npm install
  3. Run npm run webpack:example to run webpack in --watch mode
  4. The output can be seen in the /example/dist folder

Configuration

  1. Create a Webpack Configuration file (webpack.config.js):
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const HappyPack = require('happypack')
const webpack = require('webpack')

module.exports = {
  stats,
  entry: './entry.tsx',
  output: {
    filename: 'entry.bundle.js',
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: [
          { loader: 'cache-loader' },
          { loader: 'happypack/loader?id=ts' },
          { loader: 'forktschecker-hook-loader' },
        ],
      },
    ],
  },
  plugins: [
    new webpack.NoEmitOnErrorsPlugin(), // < !Doesn't emit on errors
    new HappyPack({
      id: 'ts',
      loaders: [
        {
          loader: 'ts-loader',
          options: {
            configFile: './tsconfig.json',
            happyPackMode: true,
          },
        },
      ],
    }),
    new ForkTsCheckerWebpackPlugin({
      checkSyntacticErrors: true,
      tsconfig: './tsconfig.json',
      tslint: './tslint.json',
    }),
    new webpack.WatchIgnorePlugin([
      /\.d\.ts$/,
      /.js$/,
    ]),
  ],
}
  1. Add a tsconfig.json file. For example:
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es6"],
    "moduleResolution": "node",
  },
  "exclude": [
    "node_modules"
  ]
}
  1. Run Webpack:
webpack --config webpack.config.js

or in watch mode:

webpack --config webpack.config.js --watch

Loader Options

emitInWatchMode (boolean) (default = false)

Outputs warnings and errors when Webpack is run with --watch flag. It's useful when ForkTsCheckerWebpackPlugin option silent is set to true.

Example:

{
  loader: 'forktschecker-hook-loader',
  options: {
    emitInWatchMode: true,
  },
}

useEmitFormatter (boolean|string) (default = false)

If set to true, uses the formatter specified in ForkTsCheckerWebpackPlugin option formatter (which by default is formatter: "default").

This loader provides an additional formatter when useEmitFormatter is a string and the value is default.

When this option is set to true or "default", it will format the emitted errors and warnings. This is different from logging which doesn't report errors or warnings to Webpack.

Example:

{
  loader: 'forktschecker-hook-loader',
  options: {
    useEmitFormatter: true,
  },
},

Another example:

{
  loader: 'forktschecker-hook-loader',
  options: {
    useEmitFormatter: 'default',
  },
},

License

MIT License