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

@dappykit/my-library

v1.1.0

Published

Library for Node.js and the browser using Typescript template

Downloads

6

Readme

MyLibrary: A TypeScript + Jest + Webpack Template for Node.js and Browser Libraries

Welcome to MyLibrary, a ready-to-use TypeScript template for building libraries that can run in both Node.js and the browser. This project is bundled with Jest for testing and Webpack for building your library.

Table of Contents

Getting Started

To get started, clone this repository to your local machine and run npm ci.

npx @dappykit/my-library my-new-lib

Project Structure

Here's a brief overview of the key files and directories in this template:

  • src/: The source code of your library. The entry point of the library is src/index.ts.
  • test/: Contains the tests for your library.
  • .github/workflows/: Contains configuration for GitHub Actions workflows.
  • .babelrc.js: Configures Babel, a JavaScript compiler.
  • .eslintrc.json: Configures ESLint, a tool for identifying and reporting on patterns in JavaScript.
  • jest.config.js: Configures Jest, a JavaScript testing framework.
  • tsconfig.json: Configures TypeScript for the project.
  • webpack.config.ts: Configures Webpack for bundling the library.

Available Scripts

This template includes the following scripts:

  • npm run prepublishOnly: Cleans the dist directory and compiles TypeScript files to JavaScript. It also prepares the library for both Node.js and browser environments.
  • npm run test: Runs the Jest test suite.
  • npm run lint:check: Lints the codebase using ESLint and checks for formatting issues with Prettier.
  • npm run check:types: Checks for TypeScript type errors.
  • npm run compile:node: Compiles the code for Node.js using Webpack.
  • npm run compile:types: Compiles the TypeScript declarations.
  • npm run compile:browser: Compiles the code for the browser using Webpack.

GitHub Actions

This template includes three GitHub Actions workflows:

  • tests.yaml: Runs tests, checks for type errors, and lints the code whenever changes are pushed or a pull request is created.
  • publish_npmjs.yaml: Publishes the package to npm when a new release is created on GitHub. You'll need to add your npm token to your repository's secrets under the name NPM_TOKEN.
  • release_github.yaml: Creates a new release on GitHub whenever changes are pushed to the master branch. For this to work, you'll need to add a personal access token to your repository's secrets under the name REPO_GHA_PAT.

Customizing the Library

To make this library your own, you'll need to change the following:

  • Update name, version, description, and author in package.json.
  • If you want your library to be available under a different name in the window object when used in a browser, update the library key in the output object in webpack.config.ts. For example, if you want your library to be available as MyNewLib, you would set library: 'MyNewLib'.
  • Write your library's code in the src/ directory. You can organize your code in this directory any way you want. Don't forget to update src/index.ts if you add or remove files.
  • Write tests for your library's code in the test/ directory. Jest is configured to read all files in this directory that match the pattern *.test.ts.

This template should give you a strong starting point for building a library that can run in both Node.js and the browser. Happy coding!