BundleBuilder

Builder for creating bundle files.

Builder for creating bundle files.

Allows you to add files, set options, and generate a complete bundle.

View source ↗

Constructor

new BundleBuilder(version?: "v1" | null);

Prop

Type

Properties

Prop

Type

Methods

Prop

Type

Examples

const builder = new BundleBuilder();

// Add files
builder.insertEntry('/index.html', Buffer.from('<html>...</html>'));
builder.insertEntry('/app.js', Buffer.from("console.log('hello');"));

// Build the bundle
const bundle = builder.build();

// Write to file
await writeBundle(bundle, 'app.wvb');

constructor

const builder = new BundleBuilder();

build

const bundle = builder.build();
await writeBundle(bundle, 'output.wvb');

containsEntry

if (builder.containsEntry('/index.html')) {
  console.log('index.html already added');
}

entryPaths

const paths = builder.entryPaths();
console.log(paths); // ["/index.html", "/app.js"]

insertEntry

// Auto-detect MIME type
builder.insertEntry('/index.html', Buffer.from('<html></html>'));

// Specify MIME type
builder.insertEntry('/data.bin', buffer, 'application/octet-stream');

// With custom headers
builder.insertEntry('/style.css', cssBuffer, 'text/css', {
  'Cache-Control': 'max-age=3600',
});

removeEntry

builder.removeEntry('/old-file.js');

On this page