Create a code bundle
Refer to these guidelines to create an 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.
The EdgeWorkers code bundle cannot contain any executable files.
Name | Type | Required | Description |
---|---|---|---|
edgeworker-version | String | ✓ | Unique identifier for the version |
bundle-version | Integer | ✗ | Bundle format version |
api-version | String | ✗ | Version of JavaScript API that the functions are coded against |
description | String | ✗ | Descriptive phrase for the code function |
misc | Object | ✗ | Miscellaneous data you can include in the manifest to identify the function |
Follow these steps to create the bundle.
You can also use the code bundle editor to create an EdgeWorker version.
-
Create the JavaScript source in a file called
main.js
. -
Each time you create a new version of the code bundle you need to increment the
edgeworker-version
in thebundle.json
file.
{
"edgeworker-version": "1.2",
"description" : "Perform redirect"
}
- 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 to create an EdgeWorker version.
Updated about 1 year ago