Skip to content

Commit

Permalink
feat(bun): use bun instead of nodejs (#626)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Coombs <[email protected]>
  • Loading branch information
0xfourzerofour and dancoombs committed Feb 27, 2024
1 parent 80e6e3a commit 37e1673
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 919 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
uses: actions/checkout@v3
- name: Install protobuf
run: sudo apt-get -y install protobuf-compiler
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
- name: Install protobuf
run: sudo apt-get install -y protobuf-compiler

- uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
Expand Down
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
FROM --platform=$TARGETPLATFORM rust:1.75.0 AS chef-builder

# Install system dependencies
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config protobuf-compiler nodejs yarn rsync

RUN apt-get update && apt-get -y upgrade && apt-get install -y libclang-dev pkg-config protobuf-compiler rsync unzip
RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr bash
SHELL ["/bin/bash", "-c"]
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="/root/.foundry/bin:${PATH}"
Expand Down
8 changes: 5 additions & 3 deletions crates/sim/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ fn main() -> Result<(), Box<dyn error::Error>> {
}

fn compile_tracer() -> Result<(), Box<dyn error::Error>> {
let install_url = "https://classic.yarnpkg.com/en/docs/install";
let install_url = "https://bun.sh/docs/installation";
let action = "compile tracer";
run_command(
Command::new("yarn").current_dir("tracer"),
Command::new("bun").arg("install").current_dir("tracer"),
install_url,
action,
)?;
run_command(
Command::new("yarn").arg("build").current_dir("tracer"),
Command::new("bun")
.args(["run", "bundle"])
.current_dir("tracer"),
install_url,
action,
)
Expand Down
12 changes: 0 additions & 12 deletions crates/sim/tracer/.swcrc

This file was deleted.

Binary file added crates/sim/tracer/bun.lockb
Binary file not shown.
9 changes: 3 additions & 6 deletions crates/sim/tracer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
"license": "UNLICENSED",
"scripts": {
"clean": "rm -rf dist/*",
"build": "swc src/validationTracer.ts -d dist",
"typecheck": "tsc --noEmit",
"watch": "yarn build --watch"
"bundle": "bun build src/validationTracer.ts --outdir ./dist",
"watch": "bun run bundle --watch"
},
"devDependencies": {
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.53",
"@types/node": "^18.14.0",
"@types/bun": "^1.0.7",
"prettier": "^2.8.4",
"typescript": "^4.9.5"
}
Expand Down
27 changes: 20 additions & 7 deletions crates/sim/tracer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{
"compilerOptions": {
"target": "ES6",
"lib": ["ES5"],
"module": "esnext",
"moduleResolution": "node",
// Enable latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"alwaysStrict": false
"noFallthroughCasesInSwitch": true,

// Some stricter flags
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true
},
"include": ["./src/**/*"]
}
Loading

0 comments on commit 37e1673

Please sign in to comment.