Closed7
bun + cloudflare workers, deploy 手順
概要
bun 1.0で、cloudflare workersデプロイの内容です
- bun install 省略します
環境
- bun 1.0
- cloudflare workers
参考
mkdir projectName
cd projectName
bun init
bun --help
npm add
bun add -d @cloudflare/workers-types wrangler
bun 起動、ためし
bun run index.ts
index.ts 修正
- 今回は、フレームワークつかいません
index.ts
export interface Env {
}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
return new Response('Hello World-222!');
},
};
- package.json, 下記追加
"scripts": {
"start": "wrangler dev index.ts",
"deploy": "wrangler deploy --minify index.ts"
},
wrangler.toml 参考
name = "bun_2test"
compatibility_date = "2023-09-01"
[vars]
#MY_VARIABLE = "production_value"
bun run start
dev-server , start
deploy
bunx wrangler login
bun run deploy
- package.json
{
"name": "bun_2test",
"module": "index.ts",
"type": "module",
"scripts": {
"start": "wrangler dev index.ts",
"deploy": "wrangler deploy --minify index.ts"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20230914.0",
"bun-types": "latest",
"wrangler": "^3.8.0"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
このスクラップは2023/09/19にクローズされました