Skip to content

Commit f337577

Browse files
committed
initial commit
1 parent ec70296 commit f337577

File tree

7 files changed

+214
-0
lines changed

7 files changed

+214
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
description: Use Bun instead of Node.js, npm, pnpm, or vite.
3+
globs: *.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json
4+
alwaysApply: false
5+
---
6+
7+
Default to using Bun instead of Node.js.
8+
9+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10+
- Use `bun test` instead of `jest` or `vitest`
11+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14+
- Bun automatically loads .env, so don't use dotenv.
15+
16+
## APIs
17+
18+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20+
- `Bun.redis` for Redis. Don't use `ioredis`.
21+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22+
- `WebSocket` is built-in. Don't use `ws`.
23+
- Bun.$`ls` instead of execa.
24+
25+
## Frontend
26+
27+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
28+
29+
Server:
30+
31+
```ts#index.ts
32+
import index from "./index.html"
33+
34+
Bun.serve({
35+
routes: {
36+
"/": index,
37+
"/api/users/:id": {
38+
GET: (req) => {
39+
return new Response(JSON.stringify({ id: req.params.id }));
40+
},
41+
},
42+
},
43+
// optional websocket support
44+
websocket: {
45+
open: (ws) => {
46+
ws.send("Hello, world!");
47+
},
48+
message: (ws, message) => {
49+
ws.send(message);
50+
},
51+
close: (ws) => {
52+
// handle close
53+
}
54+
},
55+
development: {
56+
hmr: true,
57+
console: true,
58+
}
59+
})
60+
```
61+
62+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
63+
64+
```html#index.html
65+
<html>
66+
<body>
67+
<h1>Hello, world!</h1>
68+
<script type="module" src="./frontend.tsx"></script>
69+
</body>
70+
</html>
71+
```
72+
73+
With the following `frontend.tsx`:
74+
75+
```tsx#frontend.tsx
76+
import React from "react";
77+
78+
// import .css files directly and it works
79+
import './index.css';
80+
81+
import { createRoot } from "react-dom/client";
82+
83+
const root = createRoot(document.body);
84+
85+
export default function Frontend() {
86+
return <h1>Hello, world!</h1>;
87+
}
88+
89+
root.render(<Frontend />);
90+
```
91+
92+
Then, run index.ts
93+
94+
```sh
95+
bun --hot ./index.ts
96+
```
97+
98+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# augment-action
2+
3+
To install dependencies:
4+
5+
```bash
6+
bun install
7+
```
8+
9+
To run:
10+
11+
```bash
12+
bun run index.ts
13+
```
14+
15+
This project was created using `bun init` in bun v1.2.15. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

bun.lock

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Hello via Bun!");

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "augment-action",
3+
"module": "index.ts",
4+
"type": "module",
5+
"private": true,
6+
"devDependencies": {
7+
"@types/bun": "latest"
8+
},
9+
"peerDependencies": {
10+
"typescript": "^5"
11+
}
12+
}

tsconfig.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
// Environment setup & latest features
4+
"lib": ["ESNext"],
5+
"target": "ESNext",
6+
"module": "Preserve",
7+
"moduleDetection": "force",
8+
"jsx": "react-jsx",
9+
"allowJs": true,
10+
11+
// Bundler mode
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"verbatimModuleSyntax": true,
15+
"noEmit": true,
16+
17+
// Best practices
18+
"strict": true,
19+
"skipLibCheck": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedIndexedAccess": true,
22+
"noImplicitOverride": true,
23+
24+
// Some stricter flags (disabled by default)
25+
"noUnusedLocals": false,
26+
"noUnusedParameters": false,
27+
"noPropertyAccessFromIndexSignature": false
28+
}
29+
}

0 commit comments

Comments
 (0)