Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The JS Compute Runtime for Fastly's [Compute@Edge platform](https://www.fastly.c

Note that this repository uses Git submodules, so you will need to run

```
```sh
git submodule update --recursive --init
```

Expand All @@ -21,13 +21,63 @@ To build from source, you need to ensure that the headers and object files for t
(cd c-dependencies/spidermonkey && sh download-engine.sh)
```


Alternatively, the engine can also be built from source using `c-dependencies/spidermonkey/build-engine.sh`. That should only be required if you want to modify the engine itself, however.

In additon you need to have the following tools installed to successfully build, and build from a linux based system.

- Rust
```
curl -so rust.sh https://sh.rustup.rs && sh rust.sh -y
restart shell or run source $HOME/.cargo/env
```
- Build tools
```sh
sudo apt install build-essential
```
- binaryen
```sh
sudo apt install binaryen
```
- rust target wasm32-wasi
```sh
rustup target add wasm32-wasi
```
- cbindgen
```sh
cargo install cbindgen
```
- wasi-sdk
```sh
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
tar xf wasi-sdk-12.0-linux.tar.gz
sudo mkdir -p /opt/wasi-sdk
sudo mv wasi-sdk-12.0/* /opt/wasi-sdk/
Comment on lines +52 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth pointing out that there's a .deb available for ubuntu/debian users?

```
- rust version - the rust version may need to be pinned due to the WASI spidermonkey version, the current version can be found at [main.yml](.github/workflows/main.yml) under "Install pinned Rust version and wasm32-wasi target"
```
rustup update 1.57.0 --no-self-update
rustup default 1.57.0
```

Once that is done, the runtime and the CLI tool for applying it to JS source code can be built using cargo:
```sh
cargo build --release
```

#### Build a windows executable
To build for windows on a linux system you need to install the following modules:

```
sudo apt-get install gcc-mingw-w64
rustup target add x86_64-pc-windows-gnu
```

then you can run the following
```sh
cargo build --target x86_64-pc-windows-gnu --release
```

## Testing

The JS Compute Runtime doesn't currently contain automated tests itself. Instead, Fastly runs an automated test suite for an internal repository for the JavaScript SDK using the runtime.
Expand All @@ -43,6 +93,20 @@ addEventListener('fetch', e => {
console.log("Hello World!");
});
```
Create a fastly.toml file which is required for the application to run:
```toml
# This file describes a Fastly Compute@Edge package. To learn more visit:
# https://developer.fastly.com/reference/fastly-toml/

authors = ["[email protected]"]
description = "test service"
language = "javascript"
manifest_version = 2
name = "test"
service_id = ""

```

into a C@E service with your build of the CLI tool, run the following command:
```sh
cargo run --release -- test.js test.wasm
Expand All @@ -52,3 +116,10 @@ Then test your service in Viceroy:
```sh
viceroy test.wasm
```

## Testing a Dev Release
:warning: **You should not use this for production workloads!!!!!!!!**

Dev builds are released before production releases to allow for further testing. These are not released upstream to NPM, however you can acquire them from the [Releases](https://github.com/fastly/js-compute-runtime/releases/) section. Download the runtime for your platform, extract the executable and place it in the /node_modules/@fastly/js-compute/bin/PLATFORM folder of your Compute@Edge project. Then you can use the normal [Fastly CLI](https://github.com/fastly/cli) to build your service.

Please submit an [issue](https://github.com/fastly/js-compute-runtime/issues) if you find any problems during testing.