7.0.11 • Published 2 years ago

klap v7.0.11

Weekly downloads
204
License
MIT
Repository
github
Last release
2 years ago

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.

optioncli flag(s)descriptiondefault
source-s --sourcesource file to compile and bundlesrc/index.js
cjs-c --cjsthe output file for common js formatpkg.main
esm-e --esmthe output file for esm formatpkg.module
umd-u --umdthe output file for umd formatpkg.browser
types-t --typesthe output file for type definitionspkg.types
browserslist-b --browserslistbrowserslist compatible compilation targetlast 2 versions modern browsers if usage is greater than 1%
klap.name-n --namepackage name for umd bundlessanitized pkg.name
klap.port-p --portport for development server1234
klap.example--examplelocation of index js/ts file for start commandpublic/index.js or pkg.source
klap.fallback--fallbacklocation of index html file for start commandpublic/index.html
klap.target--targettarget for development server (umd, es)es
klap.sourcemap--no-sourcemapsourcemaps for buildstrue
klap.minify--no-minifyminification for buildstrue
klap.runtime--runtimethe runtime for new JSX transformreact
klap.pragma--pragmathe JSX Pragma for classic runtimereact
klap.pragmaFrag--pragmaFragJSX Fragment pragmareact
klap.usets--usetsuse typescript compiler for the projectfalse
klap.globalsglobal 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

7.0.11

2 years ago

7.0.8

2 years ago

7.0.9

2 years ago

7.0.10

2 years ago

7.0.7

3 years ago

7.0.6

3 years ago

7.0.4

3 years ago

7.0.3

3 years ago

7.0.2

3 years ago

7.0.1

3 years ago

7.0.0

3 years ago

6.1.6

3 years ago

6.1.5

3 years ago

6.1.4

3 years ago

6.1.2

3 years ago

6.1.3

3 years ago

6.1.0

3 years ago

6.1.1

3 years ago

6.0.10

3 years ago

6.0.9

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.2.8

3 years ago

5.2.7

3 years ago

5.2.6

3 years ago

5.2.5

3 years ago

5.2.4

3 years ago

5.2.3

3 years ago

5.2.2

3 years ago

5.2.1

3 years ago

5.1.1

4 years ago

5.2.0

4 years ago

5.1.0

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.10.7

4 years ago

4.10.6

4 years ago

4.10.5

4 years ago

4.10.4

4 years ago

4.10.3

4 years ago

4.10.2

4 years ago

4.10.1

4 years ago

4.10.0

4 years ago

4.9.2

4 years ago

4.9.0

4 years ago

4.9.1

4 years ago

4.8.1

4 years ago

4.8.0

4 years ago

4.7.3

4 years ago

4.7.2

4 years ago

4.7.1

4 years ago

4.7.0

4 years ago

4.6.1

4 years ago

4.6.0

4 years ago

4.5.1

4 years ago

4.5.0

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.0

4 years ago

4.2.3

4 years ago

4.2.2

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.8

4 years ago

4.0.7

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

3.6.2

4 years ago

3.6.1

4 years ago

3.6.0

4 years ago

3.5.4

4 years ago

3.5.3

4 years ago

3.5.2

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

1.0.0

5 years ago