This repository powers UNPKG, a CDN and web app for serving npm package files directly from package tarballs. It includes Cloudflare Workers for public request handling, a Bun origin service for package file access and transformations, and shared tooling for compatibility and release work.
- This is a pnpm workspace. Root scripts fan out to the packages under
packages/*. packages/unpkg-wwwis the mainunpkg.comCloudflare Worker.packages/unpkg-appis the app/browse Cloudflare Worker.packages/unpkg-esmis theesm.unpkg.comCloudflare Worker. It owns ESM-specific routing, metadata, raw/build proxying, inline transforms, and esm.sh-compatible request behavior.packages/unpkg-filesis the Bun-based origin file server. Package file reads, tarball handling, and ESM build/transform work live here.packages/unpkg-workercontains shared Cloudflare Worker utilities used by the worker packages.scriptscontains repo-level maintenance and compatibility runners, including the ESM compatibility, browser smoke, readiness, and corpus generation tools.docscontains product and implementation specs for larger efforts.pnpm vendor:esm-shstarts a pinned upstream esm.sh Docker image for local baseline corpus testing.
- Node.js is used for tooling. The repo requires Node
>=23. - Bun is used for runtime and tests. The
unpkg-filesserver runs on Bun, and package tests usebun test. - Docker is used to run the pinned local esm.sh baseline for compatibility tests.
- Use pnpm for workspace commands and dependency management.
- Do not assume Node and Bun are interchangeable here: prefer the command already declared in
package.jsonscripts. - Local Cloudflare API tokens belong in
.env.local, which is gitignored. Wrangler deploy scripts load it throughscripts/with-local-env.sh; do not commit machine-specific token paths or secret values.
- Install dependencies with
pnpm install. - Build everything with
pnpm run build. - Run the full repo test suite with
pnpm test. This runs a build first viapretest. - Run package-specific commands with
pnpm --filter <package> <script>, for examplepnpm --filter unpkg-files test. - Start local development servers with the package
devscripts:pnpm --filter unpkg-www devfor the main Worker on port 3000.pnpm --filter unpkg-app devfor the app Worker on port 3001.pnpm --filter unpkg-esm devfor the ESM Worker on port 3002.pnpm --filter unpkg-files devfor the Bun file server on port 4000.
- Deploy workers with their package scripts, for example
pnpm --filter unpkg-www deployorpnpm --filter unpkg-esm deploy. - Deploy staging workers with
pnpm --filter <package> deploy:staging. unpkg-wwwandunpkg-apphave asset build steps wired into their package scripts and Wrangler configs; use those scripts so HTML/CSS/JS asset changes are built before deployment.unpkg-esmserver-renders its beta HTML page with Preact components in the Worker and does not have a separate static asset build.- Worker deploy scripts load local secrets through
scripts/with-local-env.sh; keep Cloudflare tokens in.env.local.
- Run the seed compatibility suite with
pnpm test:esm-compat. - Run a corpus with
pnpm test:esm-compat -- --corpus scripts/esm-compat-corpus.ecosystem.json. - Start the local esm.sh baseline with
pnpm vendor:esm-sh, then compare against it withpnpm test:esm-compat:local-baseline -- --corpus scripts/esm-compat-corpus.ecosystem.json. - Use
--dry-runto validate and print corpus cases without network requests. - Use
--ndjsonfor long corpus runs so progress and per-case failures stream as newline-delimited JSON. - Store local compatibility reports in
.reports/. This directory is gitignored; runpnpm clean:reportsbefore new report-producing runs when old output could be confused with fresh results. - For live runs, set
ESM_UNPKG_ORIGINto the local, staging, or beta origin you intend to test. The default ishttps://esm.unpkg.com. - The compatibility runner limits live checks with
--concurrencyand--timeout-ms, and can restart localhostesm.sh,unpkg-esm, orunpkg-filesservices when a local service becomes unreachable.