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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@owlpkg/typescript-loader

v1.0.5

Published

TypeScript loader for Webpack

Readme

Webpack TypeScript Loader

A TypeScript loader for Webpack:

Install

npm install --save-dev @owlpkg/typescript-loader

Install with TSLint Support

npm install --save-dev @owlpkg/typescript-loader tslint tslint-language-service

Usage (with tsconfig.json)

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.ts$/,
        include: path.resolve('src'),
        exclude: /node_modules/,
        use: [
          {
            loader: '@owlpkg/typescript-loader',
            options: {
              tsconfig: './tsconfig.json',
              cache: true
            }
          }
        ]
      }
    ]
  }
}

Usage (with jsconfig.json)

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve('src'),
        exclude: /node_modules/,
        use: [
          {
            loader: '@owlpkg/typescript-loader',
            options: {
              jsconfig: './jsconfig.json',
              cache: true
            }
          }
        ]
      }
    ]
  }
}

Usage (with HappyPack and TSLint)

module.exports = {
  module: {
    rules: [
      {
        test: /\.ts$/,
        include: path.resolve('src'),
        exclude: /node_modules/,
        use: [
          {
            loader: 'happypack/loader',
            options: {
              id: 'buildMyApp'
            }
          }
        ]
      }
    ]
  },
  plugins: [
    new HappyPack({
      id: 'buildMyApp',
      verbose: false,
      loaders: [
        {
          loader: '@owlpkg/typescript-loader',
          options: {
            tslint: './tslint.json',
            tsconfig: './tsconfig.json',
            cache: true,
          }
        }
      ]
    })
  ]
}

Loader Options

|Name |Type |Default |Description | |:--|:--:|:-----:|:----------| | tsconfig | {string} | './tsconfig.json' | Path to TSConfig File (It cannot be used together with jsconfig option) | jsconfig | {string} | undefined | Path to JSConfig File (It cannot be used together with tsconfig option) | tslint | {string} | undefined | Path to tslint.json file | tslintFormatter | {string} | undefined | Transform emitted result using a tslint formatted as specified in tslint/formatters | cache | {boolean|Object} | false | Cache the result and diagnostics of the loader to disk. If the cache is an object, it accepts the same properties as the cache-loader options do | getCustomTransformers | () => ({ before?: TransformerFactory[], after?: TransformerFactory[] }) | () => ({}) | Provides custom transformers. For instance, typescript-plugin-styled-components

Important!

Only the compilerOptions in your tsconfig or jsconfig file are taken into account for compilation. It's important to specify the exclude and (optionally) the include properties in the loader.

Contributing

This is a young project and a work in progress (but stable). So, it needs help. Please, feel free to contribute.

License

MIT License

Inspiration

(It's at the end of the README, so you don't have to read it if you don't want to)

I started to write this loader to improve build time and build time in incremental builds in my own projects. It was inspired in ts-loader, HappyPack and cache-loader mainly. In fact, the internal built-in cache shares (almost) the same code base as cache-loader.

The idea, VSCode is able to display diagnostic errors almost immediatly after you open the editor (even in big projects). I figured that if I build the loader as if it were a Code Editor such as VSCode, I should figure out a way to implement Type Checking only for the watched files. Here is a helpful link: Using the Compiler API

Technically, every file that is being transpiled is added to a list of watch-files. So, by watching files we are able to detect changes even before webpack calls the loader and transpile the source in the background and make the transpiled code and diagnostics available when the loader is called. This decreases build time in incremental builds or Webpack Watch Mode.

TSLint runs as a TypeScript Language Service Plugin, so there is no need for a separate loader or run a separate process for it. It works within the TS Compiler (to say in a way) and the errors and warnings are part of the TS diagnostic messages as well.

The cache (based on cache-loader), keeps the last result of a transpiled file and its diagnostics, so restarting Webpack loads the previously saved result from the cache. If no files were changed, then build time is really fast. However, if a file was changed, that file is transpiled but the unchanged files are served from cache.