介绍
Bun 是一个运行时,即运行代码的一个基础层。
build
bun支持将代码build成单文件,方便部署。
# build for windows x64
bun build --compile --target=bun-windows-x64 ./path/to/my/app.ts --outfile myapp.exe
# Note: the default architecture is x64 if no architecture is specified.
bun build --compile --target=bun-linux-arm64 ./index.ts --outfile myapp
bun build --compile --target=bun-linux-x64 ./index.ts --outfile myapp
很多时候跨平台build会出问题,比如在windows上build linux的单文件,很可能因为网络或者其他原因出现问题,所以一般把代码复制过去,然后bun install ,然后再 bun build,这个时候,不需要target参数,则直接就能编译了。
bun build --compile ./index.ts --outfile myapp