Skip to content
Merged
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
94 changes: 43 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,64 @@
name: CI
name: 🧪 Continuous Integration

on:
push:
branches:
- main
- master
branches-ignore: [master]
pull_request:
branches:
- main
- master
branches: [master]

jobs:
linting:
name: Biome linting and formatting
test:
name: 🧪 Test Suite
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: Cache bun
uses: actions/cache@v3
id: bun-cache
- name: 🟢 Setup Bun
uses: oven-sh/setup-bun@v1
with:
path: ~/.bun/bin
key: bun-v1.2.16

- name: Install Bun v1.2.16
if: steps.bun-cache.outputs.cache-hit != 'true'
run: |
curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.16"

- name: Add bun to PATH
run: echo "$HOME/.bun/bin" >> $GITHUB_PATH
bun-version: latest

- name: Install dependencies
- name: 📦 Install dependencies
run: bun install

- name: Run Biome checks
run: bunx biome check
- name: 🧪 Run tests
run: bun test

bun-tests:
name: Bun test suite
runs-on: ubuntu-latest
- name: 🔍 Lint and format check
run: bun run check

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 🏗️ Test build
run: bun run build

- name: Cache bun
uses: actions/cache@v3
id: bun-cache
with:
path: ~/.bun/bin
key: bun-v1.2.16

- name: Install Bun v1.2.16
if: steps.bun-cache.outputs.cache-hit != 'true'
- name: 📏 Check bundle size
run: |
curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.16"
- name: Add bun to PATH
run: echo "$HOME/.bun/bin" >> $GITHUB_PATH
BUNDLE_SIZE=$(du -sh dist/ | cut -f1)
echo "📦 Bundle size: $BUNDLE_SIZE"
echo "bundle-size=$BUNDLE_SIZE" >> $GITHUB_OUTPUT
Comment on lines 35 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Step writes an output nobody can read – missing id tag
You’re echo-ing bundle-size to $GITHUB_OUTPUT, but without id: bundle (or similar) the value can’t be referenced later. Either add an id or ditch the output entirely.

-      - name: 📏 Check bundle size
+      - id: bundle-size
+        name: 📏 Check bundle size
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.16"
- name: Add bun to PATH
run: echo "$HOME/.bun/bin" >> $GITHUB_PATH
BUNDLE_SIZE=$(du -sh dist/ | cut -f1)
echo "📦 Bundle size: $BUNDLE_SIZE"
echo "bundle-size=$BUNDLE_SIZE" >> $GITHUB_OUTPUT
- id: bundle-size
name: 📏 Check bundle size
run: |
BUNDLE_SIZE=$(du -sh dist/ | cut -f1)
echo "📦 Bundle size: $BUNDLE_SIZE"
echo "bundle-size=$BUNDLE_SIZE" >> $GITHUB_OUTPUT
🤖 Prompt for AI Agents
In .github/workflows/ci.yml around lines 35 to 38, the step writes an output to
$GITHUB_OUTPUT without specifying an id for the step, so the output cannot be
referenced later. Fix this by adding an id field (e.g., id: bundle) to the step
that runs this script, enabling other steps to access the bundle-size output.
Alternatively, remove the output if it is not needed.


compatibility:
name: 🌐 Compatibility Test
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: Verify Bun
run: bun --version
- name: 🟢 Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
- name: 📦 Install dependencies
run: bun install

- name: Run tests
run: bun test
- name: 🏗️ Build package
run: bun run build

- name: 🧪 Test package installation
run: |
# Test local package installation
npm pack
PACKAGE=$(ls *.tgz)
mkdir test-install && cd test-install
npm init -y
npm install ../$PACKAGE
echo "✅ Package installation test passed"
125 changes: 125 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: 🚀 Publish to NPM

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
name: 🧪 Test & Quality Check
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

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

- name: 📦 Install dependencies
run: bun install

- name: 🧪 Run tests
run: bun test

- name: 🔍 Run linting and formatting checks
run: bun run check

- name: 🏗️ Test build
run: bun run build

- name: 📊 Upload coverage reports
if: success()
run: echo "✅ All quality checks passed"

publish:
name: 📦 Publish to NPM
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: 📦 Install dependencies
run: bun install

- name: 🏗️ Build package
run: bun run build

- name: 🔖 Determine version bump
id: version
run: |
# Get the last commit message
COMMIT_MSG=$(git log -1 --pretty=%B)
echo "Commit message: $COMMIT_MSG"

# Determine version bump based on conventional commits
if echo "$COMMIT_MSG" | grep -q "BREAKING CHANGE\|!:"; then
echo "bump=major" >> $GITHUB_OUTPUT
echo "🔥 Major version bump detected"
elif echo "$COMMIT_MSG" | grep -q "^feat"; then
echo "bump=minor" >> $GITHUB_OUTPUT
echo "✨ Minor version bump detected"
elif echo "$COMMIT_MSG" | grep -q "^fix\|^perf\|^refactor"; then
echo "bump=patch" >> $GITHUB_OUTPUT
echo "🐛 Patch version bump detected"
else
echo "bump=patch" >> $GITHUB_OUTPUT
echo "📝 Default patch version bump"
fi

- name: 🔖 Bump version
run: |
npm version ${{ steps.version.outputs.bump }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "📈 Version bumped to $NEW_VERSION"

- name: 🏷️ Create Git tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add package.json
git commit -m "🔖 chore: bump version to $NEW_VERSION [skip ci]"
git tag "v$NEW_VERSION"
git push origin master --tags

- name: 📦 Publish to NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: 📝 Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: Release v${{ env.NEW_VERSION }}
body: |
## 🎉 What's Changed

This release was automatically generated from the latest changes in master.

### 📦 Installation
```bash
npm install mini-react@${{ env.NEW_VERSION }}
```

### 🔗 NPM Package
https://www.npmjs.com/package/mini-react/v/${{ env.NEW_VERSION }}
draft: false
prerelease: false
46 changes: 46 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Source files (we publish compiled dist/)
src/
index.ts

# Build configuration
tsconfig.json
tsconfig.build.json
biome.json
bunfig.toml

# Tests and examples
tests/
example/
*.test.ts
*.test.tsx
*.test.js
*.test.jsx

# Development files
.gitignore
.cursor
.vscode/
.idea/

# Logs and caches
*.log
.cache
.DS_Store
coverage/
.nyc_output/

# Lock files and package managers
bun.lock
yarn.lock
package-lock.json
.pnpm-debug.log*

# Build artifacts not needed
*.tsbuildinfo
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Environment files
.env*
1 change: 1 addition & 0 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@biomejs/biome": "1.9.4",
"@happy-dom/global-registrator": "^17.5.6",
"@types/bun": "latest",
"typescript": "^5.0.0",
},
"peerDependencies": {
"typescript": "^5.0.0",
Expand Down
34 changes: 23 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
{
"name": "mini-react",
"version": "1.0.0",
"version": "0.0.0",
"description": "A minimal React implementation with JSX support",
"main": "index.ts",
"module": "index.ts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./index.ts",
"require": "./index.ts"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
},
"./jsx-runtime": {
"import": "./src/jsx-runtime.ts",
"require": "./src/jsx-runtime.ts"
"types": "./dist/src/jsx-runtime.d.ts",
"import": "./dist/src/jsx-runtime.js",
"require": "./dist/src/jsx-runtime.js"
},
"./jsx-dev-runtime": {
"import": "./src/jsx-dev-runtime.ts",
"require": "./src/jsx-dev-runtime.ts"
"types": "./dist/src/jsx-dev-runtime.d.ts",
"import": "./dist/src/jsx-dev-runtime.js",
"require": "./dist/src/jsx-dev-runtime.js"
}
},
"files": ["dist/**/*", "README.md", "LICENSE"],
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@happy-dom/global-registrator": "^17.5.6",
"@types/bun": "latest"
"@types/bun": "latest",
"typescript": "^5.0.0"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"clean": "rm -rf dist",
"prebuild": "npm run clean",
"prepare": "npm run build",
"test": "bun test",
"lint": "biome lint .",
"format": "biome format .",
"check": "biome check .",
"lint:write": "biome lint --write .",
"format:write": "biome format --write .",
"check:write": "biome check --write ."
"check:write": "biome check --write .",
"prepublishOnly": "npm run test && npm run check && npm run build"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export interface RefHook<T = unknown> {
type: "ref";
current: T;
}

/**
* Union type for hooks stored in component instances.
* Note: The generic parameter T only applies to StateHook and ContextHook, EffectHook ignores it.
Expand Down Expand Up @@ -185,7 +184,6 @@ export type MutableRefObject<T> = {
};

export type UseRefHook = <T>(initialValue: T) => MutableRefObject<T>;

// ******************* //
// VDOM Instance Types //
// ******************* //
Expand Down
25 changes: 25 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./",
"declaration": true,
Comment on lines +4 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

rootDir set to “./” is a little too YOLO
Right now the compiler thinks the entire repo is fair game. If someone drops an extra file at the project root it’ll end up in dist/ faster than you can say chat, that’s a bug. Point this at "src" (and maybe the root index.ts) so we only emit what we actually ship.

-    "rootDir": "./",
+    "rootDir": "./src",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"outDir": "./dist",
"rootDir": "./",
"declaration": true,
"outDir": "./dist",
- "rootDir": "./",
+ "rootDir": "./src",
"declaration": true,
🤖 Prompt for AI Agents
In tsconfig.build.json around lines 4 to 6, the rootDir is set to "./", which
causes the compiler to include the entire repository in the output. Change the
rootDir value to "src" to restrict compilation to the source directory and avoid
accidentally including unrelated files in the dist output.

"declarationMap": true,
"sourceMap": true,
"noEmit": false,
"emitDeclarationOnly": false,
"skipLibCheck": true,
"moduleResolution": "node",
"allowImportingTsExtensions": false,
"verbatimModuleSyntax": false
},
"include": ["src/**/*", "index.ts"],
"exclude": [
"tests/**/*",
"example/**/*",
"**/*.test.ts",
"**/*.test.tsx",
"dist/**/*",
"node_modules/**/*"
]
}