Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
49 changes: 49 additions & 0 deletions .github/workflows/release-2x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Release workflow for the 2.x branch (2.x versions)
# This workflow handles releases for the 2.x version line of rescript-bun.
# It only triggers on pushes to the 2.x branch to ensure 2.x releases are properly managed.
name: Release (2.x)

permissions:
contents: write
pull-requests: write

on:
push:
branches:
- 2.x

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

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

- name: Install dependencies
run: npm ci

- name: Build project
run: bun run build

# This workflow is specifically for 2.x releases on the 2.x branch
# The changeset action will handle version bumps according to changeset config
- name: Create Release Pull Request or Publish to npm (2.x releases)
uses: changesets/action@v1
with:
publish: bun run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/release-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Release workflow for the main branch (1.x versions)
# This workflow handles releases for the 1.x version line of rescript-bun.
# It only triggers on pushes to the main branch to ensure 1.x releases are properly managed.
name: Release (1.x)

permissions:
contents: write
pull-requests: write

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

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

- name: Install dependencies
run: npm ci

- name: Build project
run: bun run build

# This workflow is specifically for 1.x releases on the main branch
# The changeset action will handle version bumps according to changeset config
- name: Create Release Pull Request or Publish to npm (1.x releases)
uses: changesets/action@v1
with:
publish: bun run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Test workflow for both main (1.x) and 2.x branches
# This workflow runs tests on both the main branch (1.x development)
# and the 2.x branch (2.x development) to ensure code quality across both version lines.
name: Test

on:
push:
branches: [main]
branches: [main, 2.x]
pull_request:
branches: [main]
branches: [main, 2.x]

jobs:
build:
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# main

## 2.0.2

### Patch Changes

- c7312ed: Improve Sqlite bindings

## 2.0.1

### Patch Changes

- b5304a1: Fix deprecations from latest ReScript v12 beta

## 2.0.0

### Patch Changes

- 1088e3f: Merge latest work from 1.x.

A note about versions:

- `2.x.x` is for ReScript v12 and above.
- `0.x.x` is for ReScript v11 and below.

# 2.0.0-alpha.2

`rescript-bun` is now compatible with ReScript v12 beta 3.

- Include changes of 0.6

# 2.0.0-alpha.1

`rescript-bun` is now compatible with ReScript v12.

- Remove `@rescript/core` since it now ships with the compiler.
- Remove `BigInt` since it now ships with the compiler.

## 0.6.0

### Minor Changes

- c6b9a03: Add bindings to `routes` in `Bun.serve`.
- c6b9a03: Add basic SQLite bindings in `BunSqlite`.

_Check out the `2.x` branch for ReScript v12 support._

- Add bindings to `routes` in `Bun.serve`. https://github.com/zth/rescript-bun/pull/11
- Add basic SQLite bindings in `BunSqlite`. https://github.com/zth/rescript-bun/pull/12

# 0.5.0

- Add bindings for `Response.json()`. https://github.com/zth/rescript-bun/pull/5
Expand Down
50 changes: 50 additions & 0 deletions DUAL_BRANCH_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dual-Branch Release Setup

This repository uses a dual-branch approach for managing releases:

## Branch Structure

- **`main` branch**: Handles 1.x version releases
- **`2.x` branch**: Handles 2.x version releases

## Workflow Files

### Release Workflows

- **`release-main.yml`**: Triggers on pushes to `main` branch, handles 1.x releases
- **`release-2x.yml`**: Triggers on pushes to `2.x` branch, handles 2.x releases

Both workflow files exist on both branches, but each only triggers on its respective branch to prevent interference.

### Test Workflow

- **`test.yml`**: Runs on both `main` and `2.x` branches to ensure code quality across both version lines

## Changeset Configuration

Each branch has its own changeset configuration:

- **`main` branch**: `baseBranch: "main"` in `.changeset/config.json`
- **`2.x` branch**: `baseBranch: "2.x"` in `.changeset/config.json`

This ensures that changesets work correctly on each branch by comparing against the appropriate base.

## Release Process

### For 1.x releases (main branch):
1. Create changeset: `npm run changeset`
2. Commit and push to main branch
3. The `release-main.yml` workflow will create a release PR or publish

### For 2.x releases (2.x branch):
1. Switch to 2.x branch: `git checkout 2.x`
2. Create changeset: `npm run changeset`
3. Commit and push to 2.x branch
4. The `release-2x.yml` workflow will create a release PR or publish

## Important Notes

- Both branches maintain independent changeset histories
- Workflows do not interfere with each other due to branch-specific triggers
- Each branch can have different dependencies and configurations as needed
- The version numbers are managed separately per branch (1.x vs 2.x)
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# rescript-bun

_Check out the `2.x` branch for ReScript v12 support._

## Release Branches

This repository maintains two active release branches:
- **`main` branch**: For 1.x releases (ReScript v11+ support)
- **`2.x` branch**: For 2.x releases (ReScript v12+ support)

Each branch has independent release cycles managed by changesets. See [DUAL_BRANCH_SETUP.md](DUAL_BRANCH_SETUP.md) for detailed information about the dual-branch setup.

Use [Bun](https://bun.sh) with ReScript.

> **Currently alpha state software**. You're encouraged to start using it, but please report all issues. There will be both bindings missing and some bindings will probably be wrong/suboptimal. We're going to work through the API surface as we go. Report all issues you find!
Expand All @@ -8,19 +18,19 @@ Use [Bun](https://bun.sh) with ReScript.

**Template repo to get up and running quickly: https://github.com/zth/rescript-bun-starter**

You need to be on ReScript v11 `>=11.1.0` and Core `>=1.3.0`. This is designed for uncurried mode so you should use that as well (`"uncurried": true` in your bsconfig/`rescript.json`).
You need to be on ReScript v12 `>=12.0.0-alpha.4`.

Install `rescript-bun` and `@rescript/core`:
Install `rescript-bun`:

```bash
npm i rescript-bun @rescript/core
npm i rescript-bun@next
```

Include them in your `rescript.json`:

```json
{
"bs-dependencies": ["@rescript/core", "rescript-bun"]
"bs-dependencies": ["rescript-bun"]
}
```

Expand All @@ -30,11 +40,7 @@ Include them in your `rescript.json`:

```json
{
"bsc-flags": [
"-open RescriptCore",
"-open RescriptBun",
"-open RescriptBun.Globals"
]
"bsc-flags": ["-open RescriptBun", "-open RescriptBun.Globals"]
}
```

Expand Down Expand Up @@ -77,7 +83,7 @@ let server = Bun.serve({
request
->Request.headers
->Headers.get("x-user-name")
->Option.getWithDefault("Unknown user")
->Option.getOr("Unknown user")

Response.make(`Hello ${userName}!`, ~options={status: 200})
},
Expand Down Expand Up @@ -208,14 +214,19 @@ Currently, bindings exist for the most common things. There's still a good amoun

## Other things to figure out

- How to reuse/contribute to [`rescript-webapi`](https://github.com/TheSpyder/rescript-webapi) instead of rolling our own bindings. I've intentionally not reused any other existing library because I wanted to start from scratch and follow ReScript v11 idioms as much as possible. But once all of this settles, we need to figure out and share the common denominator with `rescript-webapi` and other similar projects to this.
- How to reuse/contribute to [`rescript-webapi`](https://github.com/TheSpyder/rescript-webapi) instead of rolling our own bindings. I've intentionally not reused any other existing library because I wanted to start from scratch and follow ReScript v11+ idioms as much as possible. But once all of this settles, we need to figure out and share the common denominator with `rescript-webapi` and other similar projects to this.

## Contributing

Contributions are very welcome. We're aiming to cover close to 100% of the Bun API surface, which is quite huge task. But, it's definitively possible and the initial large effort pays dividends over time.

If you do want to contribute, _please open an issue saying you're starting work on module X_. So we don't accidentally double work.

## Versioning and releasing

This project uses [Changesets](https://github.com/changesets/changesets) to manage versions and changelogs. Run `npm run changeset` to create a changeset describing your changes. When changes are merged to `main`, a GitHub Action opens a release PR and merging that will publish a new version.


## Bindings style

_This will be fleshed out in a short while_.
Loading
Loading