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

typescript-cached-transpile

v0.0.6

Published

[![npm version](https://badge.fury.io/js/typescript-cached-transpile.svg)](https://badge.fury.io/js/typescript-cached-transpile)

Downloads

85,308

Readme

typescript-cached-transpile

npm version

Monkey-patches the TypeScript compiler to use a disk cache for transpileModule.

Intended for use solely with ts-node in transpileOnly mode. It'll make things faster.

TS_NODE_TRANSPILE_ONLY=true TS_NODE_COMPILER=typescript-cached-transpile ts-node ./src/index.ts

When required, it returns a monkey-patched version of the peer typescript module. The only change is the transpileModule function. It will cache results on disk, so subsequent invocations should be much faster.

Caching requires, and will only work, when the following requirements are met. If these requirements are not met, caching will be silently skipped. If you wonder why your builds aren't getting faster, you might be violating these requirements.

  • no transformers
  • no diagnostics returned by the compiler
  • compiler version is the same
  • filename is the same
  • source code is the same
  • sourcemaps are enabled
  • config object is the same, as determined by serializing to JSON and sha1 hashing
  • using transpileModule. Won't work if you're type-checking. (do that separately, e.g. tsc --noEmit)

If you need to programmatically customize the behavior, put your customizations in a JS file:

./my-cached-compiler.js
const {create} = require('typescript-cached-transpile');
module.exports = create({
    /* options here */
});

...and pass the absolute path to that file as ts-node's compiler option.

TS_NODE_TRANSPILE_ONLY=true TS_NODE_COMPILER=$PWD/my-cached-compiler.js ts-node ./src/index.ts

The cache directory can be set via environment variable TS_CACHED_TRANSPILE_CACHE. It should be an absolute path to avoid gotchas.

TS_NODE_TRANSPILE_ONLY=true TS_CACHED_TRANSPILE_CACHE=$PWD/.cache ts-node ./src/index.ts

Portable / pre-compiled cache

Filenames are included in the cache keys. Normally these are absolute. If you want to bundle a pre-generated cache with your code, the cache will need to use relative paths instead. Set env var TS_CACHED_TRANSPILE_PORTABLE to true to enable this behavior.