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 production source for UNPKG. There are 5 packages:
unpkg-wwwis the main UNPKG website and package file CDN workerunpkg-appis the package browser app workerunpkg-esmis theesm.unpkg.compackage import worker for browser-ready ESM, CSS modules, import maps, and inline TS/TSX transformsunpkg-filesis the Bun file server backend that fetches npm tarballs, extracts files, and builds ESM artifacts for the workersunpkg-workeris the shared TypeScript library used by the workers and the files backend
We use pnpm for workspace tooling and Bun for the runtime and tests. Install these first.
Next, install all dependencies and run the tests:
pnpm install
pnpm testThen start the file server and each worker, plus the asset servers for the two HTML apps:
pnpm --filter unpkg-files dev
pnpm --filter unpkg-www dev
pnpm --filter unpkg-www dev:assets
pnpm --filter unpkg-app dev
pnpm --filter unpkg-app dev:assets
pnpm --filter unpkg-esm devThe local services listen on these ports:
unpkg-www:http://localhost:3000unpkg-app:http://localhost:3001unpkg-esm:http://localhost:3002unpkg-files:http://localhost:4000
The unpkg-files backend is deployed on Fly.io. You'll need an account.
Next, adjust the Fly config in packages/unpkg-files/fly.json (you'll need your own app name) and deploy:
pnpm --filter unpkg-files run deployTo deploy the workers, you'll need a Cloudflare account. You will also need to (1) edit the wrangler.json file in each worker and update its routes to your own domain(s) and (2) adjust each worker's environment vars (in wrangler.json) so they can find one another in production.
For API token authentication, create a local .env.local file from .env.example and set CLOUDFLARE_API_TOKEN. The worker deploy scripts load .env.local automatically before invoking Wrangler. Use a token with the Cloudflare permissions needed for the operation you are running, such as worker deploy permissions for deploys and cache purge permissions when purging CDN entries.
Once you've done that, you can deploy all workers with:
pnpm run deploy:workersOr deploy each worker individually with:
pnpm --filter unpkg-www run deploy
pnpm --filter unpkg-app run deploy
pnpm --filter unpkg-esm run deployPlease see LICENSE for more information.