JSPM

  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q68107F
  • License MIT

A lightweight, extensive and configurable npm package for building all your ES6 source codes in one parse using rollup

Package Exports

  • @teclone/rollup-all
  • @teclone/rollup-all/build/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@teclone/rollup-all) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@teclone/rollup-all

Build Status Coverage Status semantic-release npm version npm

Overview

@teclone/rollup-all is a drop in solution of for building all your shiny Javascript/Typescript library/application source codes using rollup. It is very configurable and allows you to generate commonjs, es module, and browser builds at once.

It allows you to configure the build process, letting you define what should be included and excluded in the build, if sourcemap should be generated, if minified versions of the build should be generated, if asset and type definition files should be copied over, and lots more...

It comes with all needed configurations already done for you, including support for typescript and react projects. It uses Rollup's JavaScript API to automate the build process.

Getting Started

npm install --save-dev @teclone/rollup-all

Next, add the build script to your package.json file

{
  "scripts": {
    "build": "rollup-all"
  }
}

Advanced Configuration

In case you need to do some other configurations, such as passing extra babel presets, babel plugins, rollup plugins, and build config, then you can create a rollup.config.js file at the root of your project. Like shown below:

const { config } = require('@teclone/rollup-all');
module.exports = config(opts);

The above code is the way to configure the build process. The good thing is that it is self documented, because it is a typescript project.

By using your code editor auto completion tools, you can see the structure of the opts object.

Below is a brief documentation of the opts object.

The configuration object

The options object takes two objects, config and babelConfig.

  1. Babel Config

The babelConfig object is where you add extra configurations for babel such as presets and plugins. Any extra configurations defined will be added on top of the default configurations in the project.

babelConfig accepts two properties: presets, and plugins. both are of type array, and follows babel conventions for defining presets and plugins.

By default, The following presets are added automatically:

  1. @babel/preset-env
  2. @babel/preset-typescript
  3. @babel/preset-react

The following babel plugins are added automatically:

  1. @babel/plugin-proposal-class-properties

  2. @babel/plugin-proposal-nullish-coalescing-operator

  3. @babel/plugin-proposal-object-rest-spread

  4. @babel/plugin-transform-runtime

  5. @babel/runtime

  6. Config

The config object is where you configure build specific options, and also where you extend the rollup plugins. it accepts a plugins array, that are added to the already used plugins. Below is a list of already added plugins

  1. rollup-plugin-babel
  2. @rollup/plugin-commonjs
  3. @rollup/plugin-node-resolve
  4. rollup-plugin-terser
  5. @rollup/plugin-json

The config option takes other configuration options, such as sourcemap option, interop, uglify, assets array, distConfig options (where you can configure options specifically for browser builds, such as externals). etc. Note that distConfig.enabled options is set to false by default.

Contributing

We welcome your own contributions, ranging from code refactoring, documentation improvements, new feature implementations, bugs/issues reporting, etc. Thanks in advance!!!