Skip to content

Didericis/bare-bundle-transform

Repository files navigation

bare-bundle-transform

NPM Version Tests

Provides a simple CLI that takes a bare-bundle generated by bare-pack and transforms each file in the bundle. You can use this to alter code that's incompatible with bare while bundling, like regex patterns using the /u flag.

Installation

npm i [-g] bare-bundle-transform

Usage

Plugins must export a single default function with the following signature (for a specific example, see the local babel plugin used in the tests):

/**
 * @param {Bundle} bare - bare bundle being transformed
 * @param {Object} file - file being transformed
 * @param {string} file.name - file path
 * @param {Buffer} file.data - file contents
 * @param {number} file.mode - unix file mode (octal)
 */
function plugin(bundle, { name, data, mode }) {
  // see https://github.com/holepunchto/bare-bundle/ for bundle API
}

module.exports = plugin

A local plugin like ./babel.js can then be applied to a bundle generated by bare-pack like so:

bare-pack ./app.js | bare-bundle-transform --plugin ./babel.js -o ./app.bundle

You can also turn plugins into node modules (EX: bare-bundle-transform-plugin-babel) and then run them like so:

bare-pack ./app.js | bare-bundle-transform --plugin bare-bundle-transform-plugin-babel -o ./app.bundle

CLI

bare-bundle-transform [flags] [bundle]

Transform the bundle located at [bundle]. If no bundle is supplied, will read whatever is passed into stdin. If --out is provided, the transformed bundle will be written to the specified file. Otherwise, the bundle will be written to stdout.

Flags include:

--version|-v
--out|-o <path>
--plugin <path>

About

File transformations for bare-bundle

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •