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

klap

v7.0.11

Published

zero config, zero dependency bundler for tiny javascript packages.

Downloads

633

Readme

klap :clap:

a zero config, zero dependency bundler for tiny javascript packages.

Build Status David David npm NPM All Contributors

:sparkles: Features

  • :tada: zero config: bundle your library using only a package.json
  • :boom: zero config: typescript support (just rename *.js to *.ts)
  • :star2: zero config: code transforms using babel macros
  • :rainbow: zero config: code generation using babel plugin codegen
  • :rocket: zero dependency: uses gcc-style bundling.
  • :octopus: creates tiny bundles for multiple output formats cjs, esm and umd
  • :fire: Modern JS syntax with class properties, async/await, and generators
  • :zap: Built in Minification and Gzip Size Tracking
  • :cyclone: Built in development server for quick prototyping.
  • :confetti_ball: Supports react, styled-components and emotion out of the box.

:muscle: Powered By

  • rollup - Next-generation ES module bundler
  • babel - The compiler for next generation JavaScript
  • typescript - Typed JavaScript at Any Scale.

:plate_with_cutlery: Usage

First, initialize your project using klap init:

npx klap init

Prefer Typescript ? initialize using ts argument:

npx klap init ts

Want to use JSX with Typescript? init using tsx argument:

npx klap init tsx

The init command will create a minimal package.json with source, main, module and browser entries and the build, watch and start scripts.

{
  "name": "...",
  "version": "0.0.0",
  "files": [ "dist" ],
  "source": "src/sum.js",         # source file of your package
  "main": "dist/sum.cjs.js",      # commonjs bundle target
  "module": "dist/sum.esm.js",    # esm bundle target
  "browser": "dist/sum.js",       # umd bundle target
  "scripts": {
    "build": "klap build",        # bundle your package
    "watch": "klap watch",        # bundle your package and watch for changes
    "start": "klap start",        # start a development server
  },
  "devDependencies": {
    "klap": "3.2.0"               # klap as dev dependency
  }
}

Note: Dropping pkg.main will disable cjs output, also applies to esm and umd outputs.

Then use npm run or yarn to invoke npm scripts as you normally would.

See examples for common use cases using klap.

:anger: Granular Control

klap uses sensible defaults for most part. However, as needed, use below properties in package.json to fine tune klap. You can also use cli flags to control config options for klap.

| option | cli flag(s) | description | default | | ----------------- | ---------------------- | ---------------------------------------------- | ------------------------------------------------------------- | | source | -s --source | source file to compile and bundle | src/index.js | | cjs | -c --cjs | the output file for common js format | pkg.main | | esm | -e --esm | the output file for esm format | pkg.module | | umd | -u --umd | the output file for umd format | pkg.browser | | types | -t --types | the output file for type definitions | pkg.types | | browserslist | -b --browserslist | browserslist compatible compilation target | last 2 versions modern browsers if usage is greater than 1% | | klap.name | -n --name | package name for umd bundles | sanitized pkg.name | | klap.port | -p --port | port for development server | 1234 | | klap.example | --example | location of index js/ts file for start command | public/index.js or pkg.source | | klap.fallback | --fallback | location of index html file for start command | public/index.html | | klap.target | --target | target for development server (umd, es) | es | | klap.sourcemap | --no-sourcemap | sourcemaps for builds | true | | klap.minify | --no-minify | minification for builds | true | | klap.runtime | --runtime | the runtime for new JSX transform | react | | klap.pragma | --pragma | the JSX Pragma for classic runtime | react | | klap.pragmaFrag | --pragmaFrag | JSX Fragment pragma | react | | klap.usets | --usets | use typescript compiler for the project | false | | klap.globals | | global names for umd bundles | {} |

--usets allows the library code to use typescript features not supported by @babel/preset-typescript. See const-enums example to enable usage of const enums.

:clinking_glasses: License

klap is licensed under the MIT License.

Documentation is licensed under Creative Common License.

Created with ❤️ by @osdevisnot and all contributors.

:sparkles: Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

:gift_heart: Supporters