Skip to content

πŸ₯πŸ‹πŸπŸ“πŸŠπŸ Automatically generate your rollup.js boilerplate πŸ’πŸˆπŸ‡πŸ‰πŸπŸŽ

License

Notifications You must be signed in to change notification settings

jaebradley/fruit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

94 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

fruit

Build your rollup.js boilerplate in seconds.1

build-status npm-version npm-total-downloads

πŸ₯ πŸ‹ 🍐 πŸ“ 🍊 🍍 🍰 πŸ’ 🍈 πŸ‡ πŸ‰ 🍏 🍎 🍌

Introduction

Two of the most-popular libraries used to bundle JavaScript are rollup and webpack.

The general consensus is that rollup should be used for building libraries and webpack should be used for building applications.

This is because webpack comes with features like hot module reloading (which has obvious benefits for applications) while rollup "scope hoists", which guarantees smaller bundles than webpack.

However, there is a decent amount of boilerplate associated with configuring a baseline rollup library (.eslintrc, travis.yml, .babelrc, jest, etc.).

fruit aims to generate rollup library boilerplate (using some preferred configuration options) so that you can start building your library right away.

Installation

npm install @jaebradley/fruit --global

Usage

Execute fruit via the command line and then follow the configuration options

configuration-options

which will install dependencies and generate a basic bundle, with "logic" for placeholder library exports.

bundle-generation

Configuration Options

Right now, there are two different types of libraries you can generate boilerplate for - Node and React.

Both come with

Node

Node Library Directory Structure (with commitlinting)

/some/project/path
β”œβ”€β”€ .babelrc
β”œβ”€β”€ .eslintignore
β”œβ”€β”€ .eslintrc
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .npmignore
β”œβ”€β”€ .travis.yml
β”œβ”€β”€ build
|  β”œβ”€β”€ index.cjs.js
|  β”œβ”€β”€ index.esm.js
|  └── index.js
β”œβ”€β”€ commitlint.config.js
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ rollup.config.js
└── src
   β”œβ”€β”€ index.js
   └── index.test.js

React

This option also comes with the following additional dependencies

Production Dependencies

  • react
  • react-dom
  • prop-types

Development Dependencies

It also comes with Storybook which makes it easy to display different component use-cases.

You can run Storybook locally, on port 6006 by executing the storybook npm script (npm run storybook).

React Library Directory Structure (with commitlinting)

/some/project/path
β”œβ”€β”€ .babelrc
β”œβ”€β”€ .eslintignore
β”œβ”€β”€ .eslintrc
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .npmignore
β”œβ”€β”€ .storybook
|  β”œβ”€β”€ addons.js
|  β”œβ”€β”€ config.js
|  └── webpack.config.js
β”œβ”€β”€ .travis.yml
β”œβ”€β”€ build
|  β”œβ”€β”€ index.cjs.css
|  β”œβ”€β”€ index.cjs.js
|  β”œβ”€β”€ index.css
|  β”œβ”€β”€ index.esm.css
|  β”œβ”€β”€ index.esm.js
|  └── index.js
β”œβ”€β”€ commitlint.config.js
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ rollup.config.js
└── src
   β”œβ”€β”€ AnExample
   |  β”œβ”€β”€ AnExample.scss
   |  β”œβ”€β”€ AnExample.stories.jsx
   |  β”œβ”€β”€ AnExample.test.jsx
   |  └── index.jsx
   β”œβ”€β”€ AnotherExample
   |  β”œβ”€β”€ AnotherExample.scss
   |  β”œβ”€β”€ AnotherExample.stories.jsx
   |  β”œβ”€β”€ AnotherExample.test.jsx
   |  └── index.jsx
   β”œβ”€β”€ index.js
   └── setupTest.js

commitlint

I like commitlinting.

If you select the commitlint feature, it'll add the following development dependencies

and the following npm scripts

  • commitmsg
    • A commit message .git hook that will trigger commitlint
  • gc

semantic-release

I like to automate package deployment using semantic-release.

If you select the semantic-release feature, the following dependencies will be added

along with the following npm scripts

  • deploy
    • which will trigger the semantic-release deploy process
  • semantic-release (for use in npm run deploy)
  • travis-deploy-once (for use in npm run deploy)

Footnotes

1 Ok, maybe more like "many seconds" (β˜• time?)