https://github.com/azimutlabs/rollup
🍣 Rollup configurations for the best package bundling experience
https://github.com/azimutlabs/rollup
alabs azimutlabs rollup rollup-config rollup-configurations rollup-plugin
Last synced: 27 days ago
JSON representation
🍣 Rollup configurations for the best package bundling experience
- Host: GitHub
- URL: https://github.com/azimutlabs/rollup
- Owner: azimutlabs
- License: mit
- Created: 2021-01-24T07:45:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-03T10:02:22.000Z (about 4 years ago)
- Last Synced: 2024-11-07T04:43:28.434Z (7 months ago)
- Topics: alabs, azimutlabs, rollup, rollup-config, rollup-configurations, rollup-plugin
- Language: TypeScript
- Homepage: https://alabs.team/en
- Size: 71.1 MB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
🍣
![]()
/rollup
Rollup configurations for the best package bundling experience
## Overview
This repo provides everything you need to use [Rollup](https://github.com/rollup/rollup) as your
main **library** bundler: plugins, configurations, and utilities to work with them.Simply import and call:
```js
// rollup.config.js
import babel from '@azimutlabs/rollup-config-babel';export default babel();
```
...and output is a single `RollupOptions` objects:
```js
export default {
/* ...other RollupOptions */
input: '/root/project/src/index.js',
output: { format: 'es', dir: '/root/project/lib' },
plugins: [
// @azimutlabs/rollup-plugin-external
{ name: '@azimutlabs/rollup-plugin-external' },
// @rollup/plugin-node-resolve
{ name: 'node-resolve' },
// @rollup/plugin-alias
{ name: 'alias' },
// @rollup/plugin-babel
{ name: 'babel' },
],
}
```## Installation
All of our packages have `rollup` as a peer dependency, so you have to install it first:
```shell
$ yarn add -D rollup
```
...then add whatever package you want. The naming always starts with `@azimutlabs/rollup`.
For example, here is the installation script for the `babel` configuration pack.
```shell
$ yarn add -D @azimutlabs/rollup-{config,config-babel}
```## Packages
The list of our rollup packages.
Click the badges to see more information about the curtain package.| | |
| --- | --- |
| [![@azimutlabs/rollup][rollup]](packages/rollup) | Collect Rollup configurations into a singular array |
| [![@azimutlabs/rollup-config][rollup-config]](packages/rollup-config) | Compose, combine, merge and create Rollup configurations |
| | |[rollup]: https://img.shields.io/npm/v/@azimutlabs/rollup?color=cyan&label=rollup
[rollup-config]: https://img.shields.io/npm/v/@azimutlabs/rollup-config?color=cyan&label=rollup-config### Plugins `@azimutlabs/rollup-plugin-*`
| | |
| --- | --- |
| [![@azimutlabs/rollup-plugin-external][plugin-external]](packages/rollup-plugin-external) | Control [`external`](https://rollupjs.org/guide/en/#external) field of Rollup configuration depending on `package.json` |
| | |### Configurations `@azimutlabs/rollup-config-*`
| | |
| --- | --- |
| [![@azimutlabs/rollup-config-essentials][config-essentials]](packages/rollup-config-essentials) | Essential features to properly work on a js library package |
| [![@azimutlabs/rollup-config-babel][config-babel]](packages/rollup-config-babel) | Compile code using [Babel](https://github.com/babel/babel#readme) |
| [![@azimutlabs/rollup-config-typescript][config-typescript]](packages/rollup-config-typescript) | Compile code using [TypeScript](https://github.com/microsoft/TypeScript/#readme) |
| | |[plugin-external]: https://img.shields.io/npm/v/@azimutlabs/rollup-plugin-external?color=green&label=external
[config-essentials]: https://img.shields.io/npm/v/@azimutlabs/rollup-config-essentials?color=blue&label=essentials
[config-babel]: https://img.shields.io/npm/v/@azimutlabs/rollup-config-babel?color=blue&label=babel
[config-typescript]: https://img.shields.io/npm/v/@azimutlabs/rollup-config-typescript?color=blue&label=typescript## Examples
Check the [**examples**](examples) directory to see the demo packages created using
the configurations we provide.## Usage
**We highly suggest that you read specific readmes of packages that you want to use.**
Here we have some general usage descriptions.Consider that we are writing a **TypeScript** + **React** ui library. We want to have `commonjs` support
to work properly inside a `node` environment and `es6` import/export to support tree-shaking.
All those requirements are accomplished by this rollup config:
```js
// rollup.config.js
import { combine, compose, Envs } from '@azimutlabs/rollup-config';
import { babel } from '@azimutlabs/rollup-config-babel';
import { typescript } from '@azimutlabs/rollup-config-typescript';// Compose multiple configurations into a singular array of 'RollupOptions'.
export default compose(
// Change the default 'es' format to 'cjs'.
babel('es', /* { shimMissingExports: true } */),
// Will only be present in the final config
// when the 'NODE_ENV' var is set to either 'production' or 'test'.
[
combine(
// Array of configurations.
[babel, typescript],
// Internal module format.
'cjs',
{
// Rollup options that will be merged with options provided by configurations.
shimMissingExports: true,
// Additional options for internally used plugins.
pluginBuilders: {
typescript: {
// @rollup/plugin-typescript options.
tslib: require.resolve('tslib.custom'),
},
},
}
),
[Envs.Prod, Envs.Test]
],
);
```
Output will be:
```js
// NODE_ENV === 'production'
// lib/
// ...
// index.d.ts - output from typescript
// index.es.js - output from babel + typescript
// index.cjs.js - output from babel
export default [
{ /* babel commonjs config */ },
{ /* babel + typescript config */ }
]
```## Contributing
Any PR is welcomed by our **@js-opensource** team.
Check out our [contributing](CONTRIBUTING.md) guidelines for more info.## License
[](LICENSE)