From 083297733db30c90a5fd0210271137b34ce7b443 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Fri, 22 May 2020 12:29:59 -0400 Subject: [PATCH] Readme Tweaks (#628) --- README.md | 84 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 1070b9c0..53bf90bd 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,18 @@ --- -## ✨ Features: +

+ Guide → + Setup ✯ + Formats ✯ + Modern Mode ✯ + Usage & Configuration ✯ + All Options +

+ +--- + +## ✨ Features - **One dependency** to bundle your library using only a `package.json` - Support for ESnext & async/await _(via [Babel] & [async-to-promises])_ @@ -19,37 +30,40 @@ - 0 configuration TypeScript support - Built-in Terser compression & gzipped bundle size tracking -## 🔧 Installation +## 🔧 Installation & Setup -### Download +1️⃣ **Install** by running: `npm i -D microbundle` -`npm i -D microbundle` - -### Set up your `package.json` +2️⃣ **Set up** your `package.json`: ```js { - "source": "src/foo.js", // Your source file (same as 1st arg to microbundle) - "main": "dist/foo.js", // output path for CommonJS/Node - "module": "dist/foo.module.js", // output path for JS Modules - "unpkg": "dist/foo.umd.js", // optional, for unpkg.com + "name": "foo", // your package name + "source": "src/foo.js", // your source code + "main": "dist/foo.js", // where to generate the CommonJS/Node bundle + "module": "dist/foo.module.js", // where to generate the ESM bundle + "unpkg": "dist/foo.umd.js", // where to generate the UMD bundle (also aliased as "umd:main") "scripts": { - "build": "microbundle", // uses "source" and "main" as input and output paths by default - "dev": "microbundle watch" + "build": "microbundle", // compiles "source" to "main"/"module"/"unpkg" + "dev": "microbundle watch" // re-build when source files change } } ``` -## 🤖 Modern Output +3️⃣ **Try it out** by running `npm run build`. + +## 💽 Output Formats + +Microbundle produces esm, cjs, umd bundles with your code compiled to syntax that works pretty much everywhere. While it's possible to customize the browser or Node versions you wish to support using a [browserslist configuration](https://github.com/browserslist/browserslist#browserslist-), the default setting is optimal and strongly recommended. -Microbundle's `esm`, `cjs`, `umd` and `iife` output formats all compile your code to syntax that works pretty much everywhere. You can customize which browser or Node versions you wish to support by [adding a browserslist configuration](https://github.com/browserslist/browserslist#browserslist-), however the default setting is recommended for most cases since it supports as many browsers as possible. +## 🤖 Modern Mode In addition to the above formats, Microbundle also outputs a `modern` bundle specially designed to work in _all modern browsers_. This bundle preserves most modern JS features when compiling your code, but ensures the result runs in 90% of web browsers without needing to be transpiled. Specifically, it uses [preset-modules](https://github.com/babel/preset-modules) to target the set of browsers that support `