Welcome to UNPKG!
UNPKG is a fast, global content delivery network for everything on npm. Use it to quickly and easily load any file from npm using a URL like:
https://unpkg.com/:package@:version/:file
Where :package
is the package name, :version
is the version range, and :file
is the path to the file in the package.
You can learn more about UNPKG on the website.
This repository contains the source for the unpkg.com production server. The source is divided into two Cloudflare Workers:
unpkg-www-worker
serves all files on npm and the main homepageunpkg-app-worker
serves the package detail pages
To run everything locally, you'll first need to do an install:
pnpm install
Then start each worker along with its assets server (you'll need 4 terminal tabs):
cd workers/www && pnpm dev
cd workers/www && pnpm dev:assets
cd workers/app && pnpm dev
cd workers/app && pnpm dev:assets
The dev server will be listening on http://localhost:3000
. Wrangler allows the workers to find and communicate with each other in dev.
To deploy the workers, you'll need to have a Cloudflare account. You will also need to edit the wrangler.json
file in each worker and update its routes
to your own domain(s). You'll also need to adjust each worker's environment vars
(in wrangler.json
) so they can find one another in production.
Once you've done that, you can deploy each worker with:
cd workers/www && pnpm run deploy
cd workers/app && pnpm run deploy
Please see LICENSE for more information.