A server that can intelligently handle ESM specifiers.
# serve from fs
PORT=8080 esm-http-server
# serve as proxy
PORT=8081 HTTP_PROXY=http://localhost:8080/serve/ esm-http-server
All files will be served under the /serve/
prefix, so a index.html
file at the root of the location providing content would be available at /serve/index.html
.
By default specifiers follow the WHATWG module resolution algorithm.
PORT=8080 esm-http-server --loader loader.js
You can inspect the shape of the default loader to see what a custom one needs to provide. These loaders are designed to be composable and multiple --loader
flags are allowed and are constructed from left to right with the left as the final loader and the right as the first loader that intercepts requests.
Since the server only intercepts JS MIME types, if you serve non-module JS under a different MIME it will not be intercepted.