# Fastly WinterCG Runtime Key ## Proposal Specify a string as the [WinterCG runtime key](https://runtime-keys.proposal.wintercg.org/) for the Fastly JavaScript on Compute@Edge runtime. Current suggested proposals include: * `"js-compute"` * `"fastly-compute"` * `"fastly"` ## Background WinterCG has a runtime keys specification at https://runtime-keys.proposal.wintercg.org/. Existing runtimes supported include: * Alibaba Cloud (`"edge-routine"`) * Cloudflare (`"workerd"`) * Deno (`"deno"`) * Lagon Runtime (`"lagon"`) * React Native (`"react-native"`) * Netlify (`"netlify"`) * Node.js (`"node"`) * Bun (`"bun"`) * Vercel Edge Light (`"edge-light"`) Fastly's JS platform should support a key similarly to aid with workflows for compatibility and support. ## Usage - the Node.js `"exports"` and `"engines"` fields These keys allow applications and libraries to define platform-specific compatibility and behaviours. For example, consider an npm library that is able to provide an alternative implementation of itself when running on Fastly's Compute@Edge JavaScript platform. Once specified, we can support this via: package.json ```json= { "exports": { "js-compute": "./library-js-compute.js", "deno": "./library-deno.js", "workerd": "./library-cloudflare.js" }, "engines": { "node": ">=16", "deno": ">=1.10", "js-compute": ">2.0.0" } } ``` Where the library will then use the correct JavaScript file with platform-specific functionality for the correct platform. This would also be useful for adding compatibility fixes to existing JavaScript libraries to get them supported on JS Compute Runtime, as we can inform them how to write Fastly-specific code when necessary. The same approach can also apply to applications. The `"engines"` field then allows npm packages to formally define what platforms they support - when installing a package that doesn't support the current engine version a compatibility message is then provided to users by the npm package manager. ## Process 1. Determine agreement on the key name. 2. The PR will be proposed and landed with the WinterCG Runtime Keys specification. 3. Once landed, support for the key can be provided in the js-compute-runtime itself for resolving dependencies. In addition webpack and build configuration templates for the JS platform can in turn be updated to include this key configuration. 4. Documentation can be provided as suitable as a new compatibility option when running JavaScript on the Fastly platform.