# @onflow/fcl-bundle

> FCL Bundler Tool

Latest version **1.7.1** (published 2025-09-08) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @onflow/fcl-bundle
pnpm add @onflow/fcl-bundle
yarn add @onflow/fcl-bundle
bun add @onflow/fcl-bundle
```

Provides the command `fcl-bundle`.

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.7.1 |
| Published | 2025-09-08 |
| First published | 2022-07-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 30.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 333 |
| Author | Flow Foundation |
| Maintainers | han210, dapperj, dapper_labs, jeffreydoyle, harry.eth, turbolent_flow, chasefleming, gregsantos, gregorggg, jribbink, bthaile, nialexsan, sisyphussmiling, lmcmze |

## Links

- npm: https://www.npmjs.com/package/@onflow/fcl-bundle
- Repository: https://github.com/onflow/fcl-js
- Homepage: https://flow.com
- Issues: https://github.com/onflow/fcl-js/issues
- npm.io page: https://npm.io/package/@onflow/fcl-bundle

## Dependencies (15)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [rollup](https://npm.io/package/rollup.md) ^4.24.0
- [commander](https://npm.io/package/commander.md) ^12.1.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.25.8
- [@rollup/plugin-babel](https://npm.io/package/@rollup/plugin-babel.md) ^6.0.4
- [@rollup/plugin-image](https://npm.io/package/@rollup/plugin-image.md) ^3.0.3
- [@rollup/plugin-terser](https://npm.io/package/@rollup/plugin-terser.md) ^0.4.4
- [rollup-plugin-postcss](https://npm.io/package/rollup-plugin-postcss.md) ^4.0.2
- [@rollup/plugin-replace](https://npm.io/package/@rollup/plugin-replace.md) ^6.0.1
- [@rollup/plugin-commonjs](https://npm.io/package/@rollup/plugin-commonjs.md) ^28.0.1
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.25.7
- [rollup-plugin-typescript2](https://npm.io/package/rollup-plugin-typescript2.md) ^0.36.0
- [rollup-preserve-directives](https://npm.io/package/rollup-preserve-directives.md) ^1.1.3
- [@rollup/plugin-node-resolve](https://npm.io/package/@rollup/plugin-node-resolve.md) ^15.3.0
- [@babel/plugin-transform-runtime](https://npm.io/package/@babel/plugin-transform-runtime.md) ^7.25.7

## Recent versions

- 1.7.1 (latest) — 2025-09-08
- 1.7.0-kit.0 (kit) — 2025-04-23
- 1.7.0-cross-vm.0 (cross-vm) — 2025-02-21
- 1.6.0-alpha.1 (alpha) — 2024-11-21
- 1.4.2-event-streaming.1 (event-streaming) — 2023-11-29
- 1.4.0-typescript.0 (typescript) — 2023-11-01
- 1.7.0 — 2025-04-24
- 1.6.0 — 2024-11-27
- 1.5.1-alpha.0 — 2024-10-22
- 1.5.0 — 2024-06-12
- 1.4.2 — 2024-03-26
- 1.4.2-alpha.2 — 2024-02-26
- 1.4.2-alpha.1 — 2023-12-07
- 1.4.2-alpha.0 — 2023-12-04
- 1.4.2-event-streaming.0 — 2023-11-29
- … 13 more at https://npm.io/package/@onflow/fcl-bundle/versions

## README

# FCL-Bundle Overview
FCL-Bundle is a module bundler used internally by FCL which aims to be low configuration and consistent across the monorepo.  FCL-Bundle uses [rollup](https://rollupjs.org/) and generates cjs, esm, and umd formats of the bundled modules.

## CLI Usage

Usage: `fcl-bundle [options]` 

Options:  
  -V, --version  output the version number  
  -w, --watch    Run the build in watch mode  
  -h, --help     display help for command  

## Configuration
All of the configuration for FCL-Bundle currently takes place within the `package.json` of the modules which you wish to bundle.  The following configuration options are available:

| Key    | Required | Value Type | Description                                                                                                                                                                                                                                                                                                                                                                                 |
|----------|----------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source` | Yes      | string     | Specify a source file entry point or an dictionary of [Output Configuration](#output-configuration) objects keyed by respective source files (for multiple builds) - see [Source Configuration](#source-configuration) for more details |
| `main`   | No       | string     | Specify cjs bundle output path if not manually specified by [Output Configuration](#output-configuration) (as well as cjs entry point if not overridden by `package.exports`)                                                                                                                                     |
| `module` | No       | string     | Specify esm bundle output path if not manually specified by [Output Configuration](#output-configuration) (as well as esm entry point if not overriden by `package.exports`)                                                                                                                                      |
| `unpkg`  | No       | string     | Specify umd bundle output path if not manually specified by [Output Configuration](#output-configuration) (as well as umd entry point if not overriden by `package.exports`)                                                                                                                                      |

> **Note:** If output paths end in ".min.js", the resulting bundle will be minified


### Output Configuration

An Output Configuration object exists with the following properties:
| Key    | Required | Value Type | Description                                                                                                                |
|----------|----------|------------|----------------------------------------------------------------------------------------------------------------------------|
| `cjs`    | No       | string     | Path of the cjs output bundle                                                                                              |
| `esm`    | No       | string     | Path of the esm output bundle                                                                                              |
| `umd`    | No       | string     | Path of the umd output bundle                                                                                              |
| `banner` | No       | string     | Either a string representing a banner to be prepended to all output bundles for this build or a [Banner Configuration](#banner-configuration) object |

An empty Output Configuration will fallback to the [default outputs](#default-outputs) if none are provided.  However, if at least one output format is provided, the missing outputs will be excluded from the final build.

In practice, these Output Configuration objects will be consumed as shown in the [Source Configuration](#source-configuration) below.

> **Note:** If output paths end in ".min.js", the resulting bundle will be minified

### Source Configuration

A source configuration can be provided in one of three ways:
1. A `string` identifying the path to the entry source file.  Build outputs will be inferred from either the root level `main`, `module`, and `unpkg` fields or from the [default outputs](#default-outputs) if none are provided.
    ```json
    {
      ...
      "source": "./src/index.js",
    }
    ```
2. An array of entry source files.  Build outputs will be inferred from the [default outputs](#default-outputs).
    ```json
    {
      ...
      "source": [
        "./src/indexA.js",
        "./src/indexB.js"
      ]
    }
    ```

3. A dictionary of [Output Configuration](#output-configuration) objects keyed by respective source files.
    ```json
    {
      ...
      "source": {
        "./src/indexA.js": {
          "cjs": "./dist/indexA.js"
        },
        "./src/indexB.js": {
          "cjs": "./dist/indexB.js",
          "esm": "./dist/indexB.module.js"
        },
        "./src/indexC.js": {
          "cjs": "./dist/indexC.js",
          "esm": "./dist/indexC.module.js",
          "umd": "./dist/indexC.umd.js"
        }
      }
    }
    ```
    
### Default Outputs
***Note:*** if no output bundles (cjs,esm,umd) are specifified in either the root of package.json (`main`, `module`, `unpkg`) or an Output Configuration object, the bundler will produce the following defaults:
 - `cjs` -> `dist/${basename(entry)}.js`
 - `esm` -> `dist/${basename(entry)}.module.js`
 - `umd` -> `dist/${basename(entry)}.umd.js`

### Banner Configuration

| Key    | Required | Value Type | Description                                                                                                    |
|----------|----------|------------|----------------------------------------------------------------------------------------------------------------|
| `banner` | Yes      | string     | Text to be displayed in banner                                                                                 |
| `raw`    | No       | boolean    | If false, wraps the banner in JS comment, if true no extra formatting is applied to banner **(default false)** |

## Features
 - Replace `PACKAGE_CURRENT_VERSION` in bundled code with the current `version` of the package being bundled from `package.json`
 - Bundles dependencies with UMD builds for use in browser
 - Transpiles output bundles using `@babel/preset-env` and [babel rollup plugin](https://www.npmjs.com/package/@rollup/plugin-babel)
 - PostCSS support for CSS bundling, must include a `postcss.config.js` in the root of the package
 - Images are bundled with the `@rollup/plugin-image` plugin as base64 strings
 - Minification of bundles with `terser` if output paths end in ".min.js"
 - TypeScript support if entry point is a `.ts` file

---
_Source: https://npm.io/package/@onflow/fcl-bundle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
