Skip to content

Commit

Permalink
Merge branch 'bun-experiment'
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston committed Feb 26, 2024
2 parents 6f8d9a1 + ee49926 commit f0ec054
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 19,272 deletions.
17 changes: 5 additions & 12 deletions .github/actions/install-workspace/action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# .github/actions/setup-node/action.yml
name: 'install workspace'
description: 'Set up Node.js environment and check out code'
inputs:
node-version-file:
description: 'Path to Node version file'
default: '.nvmrc'
description: 'Set up Bun and install packages'
runs:
using: 'composite'
steps:
- name: setup node
uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v1
with:
node-version-file: ${{ inputs.node-version-file }}
cache: 'npm'
cache-dependency-path: 'package-lock.json'
bun-version: latest

- name: npm ci
run: npm ci --audit=false --fund=false
- name: bun install
run: bun install --silent
shell: bash
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: install workspace
uses: ./.github/actions/install-workspace

- name: npm run build
run: npm run build
- name: bun run build
run: bun run build

test:
runs-on: ubuntu-latest
Expand All @@ -28,8 +28,8 @@ jobs:
- name: install workspace
uses: ./.github/actions/install-workspace

- name: npm test
run: npm test
- name: bun run test
run: bun run test

lint:
runs-on: ubuntu-latest
Expand All @@ -40,8 +40,8 @@ jobs:
- name: install workspace
uses: ./.github/actions/install-workspace

- name: npm run lint:check
run: npm run lint:check
- name: bun run lint:check
run: bun run lint:check

dockerize:
name: dockerize
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
FROM node:21-alpine
FROM oven/bun:1

WORKDIR /usr/src/app

COPY . ./

RUN npm ci

RUN npx nx run-many -t build -p koa-server react-app
RUN bun install --silent
RUN bunx nx run-many -t build -p koa-server react-app

ENV PORT=8080
EXPOSE 8080
CMD ["node", "./apps/koa-server/dist/server.js"]
CMD ["bun", "./apps/koa-server/dist/server.js"]
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ It is what @bhouston considers best practice in January 2024.

## Features

- Bun runtime for maximum speed.
- Mono-repository using NPM workspaces
- TypeScript for type safety
- ES Modules for fast builds
Expand All @@ -31,25 +32,25 @@ It is what @bhouston considers best practice in January 2024.
## Getting Started

1. Clone this repository
2. Run `npm install`
2. Run `bun install`

### Tests

1. Run `npm run test` to run all jest tests
1. Run `bun run test` to run all jest tests

### Continuous Dev Build

1. Run `npm run watch` to start the hot reload development server & build watchers
1. Run `bun run watch` to start the hot reload development server & build watchers

### Optimized Production Build

1. Run `npm run build` to build the source
1. Run `bun run build` to build the source

### Run the webserver (no reload)

1. Run `npx koa-server` to start the webserver
2. Open the link that appears in the console in your browser
1. Run `bunx koa-server` to start the webserver
2. Open `http://localhost:8000` in your browser

### Command Line

1. Run `npx cmdline-app` to run the CLI example
1. Run `bunx cmdline-app` to run the CLI example
2 changes: 1 addition & 1 deletion apps/koa-server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"targets": {
"watch": {
"options": {
"commands": ["tsc --watch", "nodemon dist/server.js"]
"commands": ["bun run --watch dist/server.js"]
}
},
"build": {},
Expand Down
4 changes: 2 additions & 2 deletions apps/react-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"targets": {
"watch": {
"options": {
"commands": ["vite"]
"commands": ["bunx --bun vite"]
}
},
"build": {
"options": {
"commands": ["tsc", "vite build"]
"commands": ["bunx --bun tsc", "bunx --bun vite build"]
}
},
"lint:check": {},
Expand Down
2 changes: 1 addition & 1 deletion apps/react-app/stats.html

Large diffs are not rendered by default.

Binary file added bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"outputs": ["{projectRoot}/dist"],
"options": {
"cwd": "{projectRoot}",
"commands": ["tsc --watch"],
"commands": ["bunx --bun tsc --watch"],
"parallel": true
}
},
Expand All @@ -34,7 +34,7 @@
"outputs": ["{projectRoot}/dist"],
"options": {
"cwd": "{projectRoot}",
"commands": ["tsc"]
"commands": ["bunx --bun tsc"]
},
"cache": true
},
Expand All @@ -59,7 +59,7 @@
"inputs": ["default"],
"options": {
"cwd": "{projectRoot}",
"command": "prettier \"src/**/*.{js,jsx,css,md,html,ts,tsx,json,yaml}\" --check"
"command": "bunx prettier \"src/**/*.{js,jsx,css,md,html,ts,tsx,json,yaml}\" --check"
},
"cache": true
},
Expand All @@ -70,7 +70,7 @@
"outputs": [],
"options": {
"cwd": "{projectRoot}",
"command": "node --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js"
"command": "bun --experimental-vm-modules --no-warnings ../../node_modules/jest/bin/jest.js"
},
"cache": true
}
Expand Down
Loading

0 comments on commit f0ec054

Please sign in to comment.