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

@menglinmaker/npm-library-boilerplate

v0.0.0

Published

Boilerplate for creating NPM library with CJS, ESM and DTS output

Downloads

2

Readme

Create your library

Boilerplate for creating NPM library, config free.

Note: This template is targeted at libraries that run on browsers due to compatability considerations. It should run just fine on Node.js

 

 

Setup and usage

Setup

  1. Simply use this template.

  2. Clone your template locally.

  3. Install node dependencies using pnpm:

pnpm i
  1. Provide NPM_TOKEN repository secret to GitHub Setting for deployment.

Publish npm library

  1. Create new changeset and follow prompts:
pnpm changeset
  1. Add pull request to main branch.

  2. After accepting pull request to main, a new pull request should be generated via CD.yml.

  3. The maintainer needs to accept the new pull request so the package is published.

 

 

Features

Enforce pnpm for consistency

To achieve consistency for devs, use of pnpm is enforced with a package.json script:

"preinstall": "npx only-allow pnpm"

Git hook with formatting and linting

simple-git-hooks is automatically setup on install via a package.json script:

"postinstall": "simple-git-hooks"

This repo uses:

  • prettier for formatting.
  • eslint for linting.
    • @eslint/js plugin for JavaScript rules.
    • typescript-eslint for TypeScript rules.
    • eslint-plugin-compat for detecting browser compatability issues.

Note: .npmrc config node-linker=hoisted is necessary to overcome early postinstall bug

Continuous integration and delivery

CI should work without configuration as long as linting, testing and building are successful.

CD is currectly setup for public release and only publishes on main branch after CI workflow succeeds - refer to .changeset/config.json and .github/workflows/CI.yml.

Modern testing library

vitest is designed to be compatable with ECMAScript Modules (ESM), which works directly in browsers. For new libraries this is the recommended method of exporting JavaScript modules.

Does this really matter? - probably not. You can also use jest.

Note: Compatability between browsers and JavaScript runtimes is generally difficult anyways.

Readable builds

There are two main build goals:

  1. Support CommonJs and ESM bundles with TypeScript if necessary.
  2. Make dubugging simple.

Thus no minification and bundling is used to maintain as much similarity between build package and source code.

Also, I don't wish to force TypeScript on the consumer. But I will force TypeScript library authors - there's no reason to make consuming difficult.

Bundling is achieved with rollup:

  • rollup-plugin-esbuild plugin for CommonJs and ESM build.
  • rollup-plugin-dts plugin for TypeScript d.ts build.

 

 

Todo:

  • Lint for different JavaScript runtimes: