Create a code bundle

Refer to these guidelines for developing your EdgeWorkers code bundle.

EdgeWorkers functions are defined in a file entitled main.js. You also need to create a manifest file called bundle.json. These are packaged together, along with any other dependencies as a compressed .tgz file.
For example, a package called mybundle.tgz includes two files:
  • main.js. The JavaScript source that contains event handler functions.
  • bundle.json. The manifest file that includes necessary meta information.
Table 1. Manifest file specificationsJSON file format
Name Type Description Required
edgeworker-version String Unique identifier for the version yes
bundle-version Integer Bundle format version no
api-version String Version of JavaScript API that the functions are coded against no
description String Descriptive phrase for the code function no
misc Object Miscellaneous data you can include in the manifest to identify the function no
Follow these steps to create the bundle:
  1. Create the JavaScript source in a file called main.js.
  2. Increment the edgeworker-version in the bundle.json file.
        "edgeworker-version": "1.2",
        "description" : "Perform redirect"
  3. Compress the files into a code bundle.
    tar -czvf filename.tgz main.js bundle.json
Once you have created the code bundle, you can use the EdgeWorkers Management application or the EdgeWorker API to create an EdgeWorker version.