Self-Hosting
esm.sh provides a fast, global content delivery network publicly which powered by Cloudflare. You also can deploy your own esm.sh CDN.
To build and deploy your CDN, You will need Go 1.16+ to compile the server. The server runtime will install the nodejs (16 LTS) automatically.
Clone code
git clone https://github.com/ije/esm.sh
cd esm.sh
Run the sever locally
go run main.go --port=8080 --dev
Then you can import React
from http://localhost:8080/react
Deploy to remote host
Please ensure the supervisor has been installed on your host machine.
./scripts/deploy.sh
Server options:
port
- the port to listenhttpsPort
- the port to listen https (use autocert)etcDir
- the etc directory (default is/etc/esmd
)cache
- the cache config (default ismemory:main
)db
- the database config (default ispostdb:$etcDir/esm.db
)fs
- the fs (storage) config (default islocal:$etcDir/storage
)origin
- the origin of the CDN (this is useful when running the server behind a proxy/CDN)npmRegistry
- the npm registry (default is https://npmjs.org/registry)npmToken
- the private token for npm registry
Deploy with Docker
An example Dockerfile is found in the root of this project.