osdevisnot/klap


zero config, zero dependency bundler for tiny javascript packages

https://npm.im/klap

License: MIT

Language: JavaScript

Keywords: babel, build, bundle, bundling, esm, esmodules, microlib, module-bundler, npm, packaging, react, rollup, tiny-javascript-packages, tiny-modules, typescript, umd, watch, yarn


klap 👏

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

Build Status David David npm NPM

klap init output klap build output

✨ Features

  • 🎉 zero config: bundle your library using only a package.json
  • 💥 zero config: typescript support (just rename *.js to *.ts)
  • 🌟 zero config: code transforms using babel macros
  • 🚀 zero dependency: uses gcc-style bundling.
  • 💇 tiny bundles for all inputs
  • 🔥 Modern JS syntax with class properties, async/await, and generators
  • 🎊 Supports react and styled-components out of the box.
  • 🐙 creates multiple output formats cjs, esm and umd
  • ⚡️ Built in Minification and Gzip Size Tracking
  • 🌀 Built in development server for quick prototyping.

💪 Powered By

  • rollup - Next-generation ES module bundler
  • babel - The compiler for next generation JavaScript

🍽 Usage

First, setup your project using klap init:

npx klap init

This 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 to compile and bundle
  "main": "dist/sum.cjs.js",      # commonjs target
  "module": "dist/sum.esm.js",    # esm target
  "browser": "dist/sum.js",       # umd target
  "scripts": {
    "build": "klap build",        # build your project
    "watch": "klap watch",        # build and watch for changes
    "start": "klap start",        # watch and start dev server
  },
  "devDependencies": {
    "klap": "3.2.0"               # klap as dev dependency
  }
}

Note: Dropping pkg.main will disable cjs output. This also applies to esm and umd as well.

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

💢 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
klap.name -n --name package name for umd bundles sanitized pkg.name
klap.port -p --port port for development server 1234
klap.target -t --target target for development server (`umd es`)
browserslist -b --browserlist browserlist compatible compilation target >1%, not ie 11, not op_mini all
klap.example -e --example location of index js/ts file for example public/index.js
klap.fallback -f --fallback location of index html file for example public/index.html
klap.sourcemap --no-sourcemap sourcemaps for builds true
klap.minify --no-minify minification for builds true
klap.pragma --pragma pragma for jsx and tsx compilation React.createElement
klap.frag --frag pragma for jsx and tsx fragments React.Fragment
klap.globals global names for umd bundles {}
klap.namedExports named exports for commonjs modules {}

Note: See default browserlist coverage

🥂 License

klap is licensed under the MIT License.

Documentation is licensed under Creative Common License.

Created with ♥ by @osdevisnot and all contributors.

Project Statistics

Sourcerank 6
Repository Size 1.64 MB
Stars 11
Forks 0
Watchers 1
Open issues 1
Dependencies 998
Contributors 1
Tags 24
Created
Last updated
Last pushed

Top Contributors See all

Abhishek Shende

Packages Referencing this Repo

klap
zero config, zero dependency bundler for tiny javascript packages.
Latest release 3.5.0 - Updated - 11 stars

Recent Tags See all

v3.5.0 December 09, 2019
v3.4.0 December 09, 2019
v3.3.0 December 07, 2019
v3.2.3 December 04, 2019
v3.2.2 November 26, 2019
v3.2.1 November 22, 2019
v3.2.0 November 20, 2019
v3.1.1 November 19, 2019
v3.1.0 November 15, 2019
v3.0.1 November 14, 2019
v3.0.0 November 12, 2019
v2.2.0 November 08, 2019
v2.1.0 November 07, 2019
v2.0.0 November 06, 2019
v1.0.3 November 01, 2019

Something wrong with this page? Make a suggestion

Last synced: 2019-12-09 07:42:42 UTC