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

@checkdigit/typescript-config

v9.0.0

Published

Check Digit standard Typescript configuration

Downloads

6,885

Readme

checkdigit/typescript-config

MIT License

Copyright (c) 2022–2024 Check Digit, LLC

Introduction

This module contains the standard Check Digit Typescript configuration, along with our standard build tool builder.

Typescript Configuration

  • currently requires Node 22.11 or above.
  • emits esnext, with the default libraries, to avoid down-leveling. It is intended that application spec tests pick up any issues with using newer features unavailable in a particular environment. Browsers and Node.js are fast-moving targets, and can add language features at any time.
  • uses the module type of esnext.
  • all compiler options set for maximum strictness.

Builder

builder is a command line tool that generates ESM modules from the Typescript source. It is intended to be used when publishing a package to NPM, or to bundle a package for deployment. It uses tsc for generating types, and esbuild for generating code.

Note: the require function will be defined as a global variable, to allow dynamic requires by CommonJS submodules. This is not a problem for Node.js, but will cause issues in a browser environment.

Options

  • --type the type of output to generate. Defaults to module (ESM). Valid values are module or types.
  • --entryPoint the entry point for the bundle, relative to the inDir. if not provided, the files in the inDir will be processed as individual unbundled files.
  • --inDir the input source code directory.
  • --outDir the output directory.
  • --outFile the output file, relative to --outDir. This is provided for single-file bundles, along with --entryPoint.
  • --external external modules to exclude from the bundle. Built-in node modules are automatically excluded. A wildcard * can be used to exclude multiple external modules.
  • --minify whether to minify the output.
  • --sourceMap whether to include inline sourcemap.

Examples

# build ESM .mjs files from Typescript source
npx builder --type=module --outDir=build-esm

# build single-file ESM .mjs bundle from Typescript source
npx builder --type=module --outDir=build-esm-bundle --entryPoint=index.ts --outFile=index.mjs

Tests

This module includes a number of integration-style tests, to ensure that a specific version of Typescript will interoperate with builder, in addition to libraries and frameworks used by Check Digit:

  • Jest and ts-jest
  • ESLint and @typescript-eslint/eslint-plugin
  • Built-in node:test runner
  • prettier
  • tsc
  • esbuild
  • Wallaby.js (supports node:test by including @swc-node/register as a peer dependency)

We do this to ensure that Typescript upgrades do not break these dependencies. New major versions of Typescript are not immediately supported by projects such as ts-jest, eslint, prettier, etc. Our policy is to wait until these projects fully support the new version of Typescript, and/or without emitting warnings during these tests, before publishing.

A note about versioning

Strict semver is a little complicated, as Typescript itself does not adhere to semver. So our "best effort" policy is:

  • Each update to the minimum Node target (e.g., Node 18 to Node 20), or a change to a major compiler output option (e.g. module, target or moduleResolution) will result in a new major version of this module. We coordinate this with whatever the latest LTS version of Node is currently supported by Amazon Lambda, Google Cloud Functions, and Azure Functions.
  • Each new "major" version of Typescript (e.g. 4.2.x to 4.3.x) will result in a new minor version of this module.
  • A new minor update of Typescript (e.g. 4.3.1 to 4.3.2) may result in a patch, in a situation where a specific need or issue requires setting a new minimum version of Typescript.

Bear in mind, any update of Typescript can potentially break your build. But hopefully in a way that's useful.

Installation

npm add -D @checkdigit/typescript-config

Note: you do not need to explicitly install Typescript itself, as the most recent supported version comes in as a peer dependency of @checkdigit/typescript-config.

Make sure your project's tsconfig.json extends @checkdigit/typescript-config.

Example tsconfig.json

{
  "extends": "@checkdigit/typescript-config"
}

Note this configuration has moduleResolution set to bundler. This requires that you use the builder command to produce working code for deployment. However, for simply running Jest tests, this is not necessary if used in conjunction with @checkdigit/jest-config.

License

MIT