MCPcopy
hub / github.com/unpkg/unpkg

github.com/unpkg/unpkg @main sqlite

repository ↗ · DeepWiki ↗
399 symbols 874 edges 91 files 0 documented · 0%
README

UNPKG

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.

Development

This repository contains the production source for UNPKG. There are 5 packages:

  • unpkg-www is the main UNPKG website and package file CDN worker
  • unpkg-app is the package browser app worker
  • unpkg-esm is the esm.unpkg.com package import worker for browser-ready ESM, CSS modules, import maps, and inline TS/TSX transforms
  • unpkg-files is the Bun file server backend that fetches npm tarballs, extracts files, and builds ESM artifacts for the workers
  • unpkg-worker is 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 test

Then 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 dev

The local services listen on these ports:

  • unpkg-www: http://localhost:3000
  • unpkg-app: http://localhost:3001
  • unpkg-esm: http://localhost:3002
  • unpkg-files: http://localhost:4000

Deploying

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 deploy

To 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:workers

Or deploy each worker individually with:

pnpm --filter unpkg-www run deploy
pnpm --filter unpkg-app run deploy
pnpm --filter unpkg-esm run deploy

License

Please see LICENSE for more information.

Extension points exported contracts — how you extend this code

PackageInfo (Interface)
(no doc)
packages/unpkg-worker/src/lib/npm-info.ts
Window (Interface)
(no doc)
packages/unpkg-app/assets/scripts.ts
Metadata (Interface)
(no doc)
packages/unpkg-esm/src/request-handler.ts
Env (Interface)
(no doc)
packages/unpkg-files/src/lib/env.ts
Window (Interface)
(no doc)
packages/unpkg-www/assets/scripts.ts
CompatCase (Interface)
(no doc)
scripts/esm-compat-suite.ts
CompatCase (Interface)
(no doc)
scripts/esm-browser-smoke.ts
CompatReport (Interface)
(no doc)
scripts/esm-beta-readiness.ts

Core symbols most depended-on inside this repo

resolvePackageExport
called by 44
packages/unpkg-worker/src/lib/pkg-exports.ts
rewriteImports
called by 19
packages/unpkg-worker/src/lib/pkg-imports.ts
moduleCase
called by 16
scripts/generate-esm-compat-corpus.ts
notFound
called by 15
packages/unpkg-files/src/lib/request-handler.ts
rewriteEsmImports
called by 15
packages/unpkg-files/src/lib/esm-build-service.ts
normalizeEsmRequestUrl
called by 11
packages/unpkg-worker/src/lib/esm-url.ts
resolveBuildFilename
called by 11
packages/unpkg-files/src/lib/esm-build-service.ts
corsHeaders
called by 10
packages/unpkg-esm/src/request-handler.ts

Shape

Function 304
Interface 63
Method 18
Class 14

Languages

TypeScript100%

Modules by API surface

scripts/esm-compat-suite.ts70 symbols
packages/unpkg-files/src/lib/esm-build-service.ts58 symbols
packages/unpkg-esm/src/request-handler.ts25 symbols
scripts/esm-browser-smoke.ts16 symbols
packages/unpkg-files/src/lib/npm-files.ts16 symbols
packages/unpkg-app/src/components/icons.tsx11 symbols
scripts/generate-esm-compat-corpus.ts10 symbols
scripts/esm-beta-readiness.ts10 symbols
packages/unpkg-worker/src/lib/esm-url.ts10 symbols
packages/unpkg-worker/src/lib/pkg-exports.ts7 symbols
packages/unpkg-app/src/components/code-viewer.tsx7 symbols
packages/unpkg-www/src/request-handler.test.ts6 symbols

Dependencies from manifests, versioned

@cloudflare/workers-types4.20250320.0 · 1×
@ryanto/esbuild-plugin-tailwind0.0.1 · 1×
@types/bun1.2.8 · 1×
@types/gunzip-maybe1.4.2 · 1×
@types/node22.10.2 · 1×
@types/semver7.5.8 · 1×
@types/tar-stream3.1.3 · 1×
chalk5.4.1 · 1×
es-module-lexer1.6.0 · 1×
esbuild0.24.2 · 1×
gunzip-maybe1.4.2 · 1×
highlight.js11.11.1 · 1×

For agents

$ claude mcp add unpkg \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact