/qwikly

Example project and workspace to run Qwik City on Fastly's Compute@Edge

Active PRs & Discussion

Setup

Link the two submodules

# Build the qwik monorepo submodule and link it globally for use in our projects
cd ./qwik
pnpm install && pnpm api.update && pnpm build && pnpm link.dist

cd ../qwik-city-e2e
pnpm install && pnpm link --global @builder.io/qwik @builder.io/qwik-city

# Builds qwik project and generates wasm with js-compute and inlined static assets
pnpm build.fastly

# Runs built artifacts locally
pnpm serve.fastly

# Creates or deploys the project to fastly
pnpm deploy.fastly

Qwik City Fastly Adapter

The architecture follows this guide and consists of three components:

  1. The Vite config. Responsible for generating a server entrypoint for the Fastly platform.
  2. The platform middleware. Responsible for handling the Fastly platform FetchEvent on each request and mapping qwik-city features to the platform. This includes:
  3. The starter template. Responsible for merging template files and settings with an existing qwik-city project.
    • This template includes the @fastly/compute-js-static-publish along with a default static-publish.rc.js config. This is responsible for building mappings of static assets and including them inline to the WASM binary or uploading them to the KV Store. A statics.js gets generated during this process, which yields a getServer() factory for creating a PublisherServer that gets passed into the middleware at runtime.
    • This template also includes the @fastly/js-compute library which contains the js-compute-runtime command. This command is responsible for building the bin/main.wasm executable and packing this up into a Fastly deployable pkg/[fastly service name].tar.gz tarball.