This is a Node.js module for serializing and parsing the
format defined in the Web
Currently this library doesn't support origin-signed bundles, but bundles generated by this library can be signed with the
sign-bundle Go tool.
npm install wbn
Please be aware that the API is not yet stable and is subject to change any time.
Creating a Bundle:
const wbn = ;const fs = ;const primaryURL = '';const builder = primaryURL; // response body (string or Uint8Array)// Have as many builder.addExchange() for resource URLs as needed for the package.fs;
Reading a Bundle:
const wbn = ;const fs = ;const buf = fs;const bundle = buf;const exchanges = ;for const url of bundleurlsconst resp = bundle;exchanges;console;
This package also includes
wbn command which lets you build a web bundle from a local directory. For example, if you have all the necessary files for
static/ directory, run the following command:
$ wbn --dir static \--baseURL https://example.com/ \--output out.wbn
wbn --help for full options.
Note: currently this CLI only covers a subset of the functionality offered by
gen-bundle Go tool.
Generated bundles can be opened with web browsers supporting web bundles.
Chrome (79+) experimentally supports Web Bundles with some limitations. See this document for more details.