The demo uses the local rescript-x package from the repo root, so install both layers:
bun install
cd demo
bun installThe demo postinstall script creates demo/node_modules/rescript-x as a symlink back to the repo root. That keeps the demo reproducible without recursively copying the whole repository into node_modules.
cd demo
bun run devOpen the Vite URL that it prints, typically http://localhost:9000. In dev, the browser should use the Vite server origin rather than the raw Bun app port.
For a production-style local run:
cd demo
bun run build
NODE_ENV=production bun run src/Demo.jsThe app listens on PORT when it is set, and falls back to 4444.
Build from the repo root so the Docker build can include the parent rescript-x package:
docker build -f demo/Dockerfile -t resx-demo .Run the image:
docker run --rm -p 4444:4444 -e PORT=4444 resx-demoWhat the image contains:
- A Bun single-file executable at
/app/demo-app - The Vite output in
/app/dist - No Bun toolchain or source tree in the runtime image
The container has already been verified to serve both /start and hashed asset routes from /assets/....
Build the executable locally:
cd demo
bun run build:sfeThat produces:
build/demo-appdist/
Deploy both of those together. This demo currently uses the default staticAssetRoutes.mode: "filesystem", so the executable is not fully self-contained and still serves generated assets from ./dist.
Run it like this:
cd demo
PORT=4444 NODE_ENV=production ./build/demo-appImportant runtime notes:
- Keep
dist/in the current working directory when you start the executable, or set your serviceWorkingDirectoryto the directory that containsdist/. - Files from
demo/assets/are fingerprinted intodist/assets/. - Files from
demo/public/are also emitted intodist/, so you do not need to deploypublic/separately. - If you want to offload assets to a CDN or another static host, you need to change the generated asset URLs and static route strategy. The current setup expects the app process to serve
dist/itself.
If you want a truly standalone executable instead, switch the demo Vite config to staticAssetRoutes: { mode: "embedded" } before building. That makes ResX generate embedded-file-backed static routes for bun build --compile, so the resulting executable can serve its generated assets without a sidecar dist/ tree.
Platform note:
- Bun single-file executables are target-platform specific. If you want to deploy the SFE directly to Linux, build it on Linux for the correct architecture. The Docker image is the safest path because it already builds the Linux executable in-container.