GithubHelp home page GithubHelp logo

isabella232 / js-compute-runtime Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fastly/js-compute-runtime

0.0 0.0 0.0 19.15 MB

JavaScript runtime for Fastly Compute@Edge

License: Apache License 2.0

Dockerfile 0.03% JavaScript 1.30% Rust 5.09% Makefile 0.60% C++ 87.57% C 5.07% Shell 0.33%

js-compute-runtime's Introduction

Fastly Compute@Edge JS Runtime

The JS Compute Runtime for Fastly's Compute@Edge platform provides the environment JavaScript is executed in when using the Compute@Edge JavaScript SDK.

Note: If you just want to use JavaScript on the Compute@Edge Platform, we recommend using the JavaScript Starter Kits provided by the Fastly CLI tool. For more information please see the JavaScript documentation on the Fastly Developer Hub.

Working with the JS Compute Runtime source

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

git submodule update --recursive --init

to pull down or update submodules.

Building the JS Compute Runtime

To build from source, you need to ensure that the headers and object files for the SpiderMonkey JavaScript engine are available. It's recommended to download pre-built object files:

(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.

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

cargo build --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.

Manual testing is well supported, however. To test your changes, you can follow these steps:

  1. Build the runtime's CLI tool, see above
  2. Create a C@E service from a JS source file by running the CLI tool
  3. Test the service using Fastly's local testing server

As an example, to turn a file test.js with this source code:

addEventListener('fetch', e => {
  console.log("Hello World!");
});

into a C@E service with your build of the CLI tool, run the following command:

cargo run --release -- test.js test.wasm

Then test your service in Viceroy:

viceroy test.wasm

js-compute-runtime's People

Contributors

black2d avatar jakechampion avatar tschneidereit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.