This guide is for internal developers working on the @remoteoss/remote-flows package.
- Node.js 20 or higher, (CI uses 24 to have 2FA)
- npm
- Clone the repository:
git clone https://github.com/remoteoss/remote-flows.git
cd remote-flows- Install dependencies:
npm install- Link the package for local development:
npm link
npm run dev- Set up the example app:
cd example
npm install
npm link @remoteoss/remote-flows- Create
.envfile in the example directory:
VITE_CLIENT_ID=your_client_id
VITE_CLIENT_SECRET=your_client_secret
VITE_REFRESH_TOKEN=your_refresh_token
VITE_REMOTE_GATEWAY=partners # for sandbox
# VITE_REMOTE_GATEWAY=production # for production- Start the example app:
npm run devThe example app will be available at http://localhost:3001.
npm run dev- Build the package in watch modenpm run build- Build the package for productionnpm test- Run testsnpm run type-check- Run TypeScript type checkingnpm run format- Format code with Prettiernpm run size- Analyze bundle sizenpm run size:check- Check if bundle size is within limitsnpm run size:badge- Generate badge and history data
remote-flows/
├── src/
│ ├── flows/ # Flow components (CostCalculator, Termination, etc.)
│ ├── components/ # Shared components
│ ├── hooks/ # Custom React hooks
│ └── utils/ # Utility functions
├── example/ # Example application
├── scripts/ # Build and analysis scripts
└── .github/ # CI/CD workflows
Run the test suite:
npm testRun type checking:
npm run type-checkWe have automated bundle size tracking to ensure the package stays performant.
Size limits are defined in .sizelimit.json:
{
"limits": {
"total": 524288, // 512 KB (raw)
"totalGzip": 131072, // 128 KB (gzip)
"css": 20480, // 20 KB (raw)
"cssGzip": 10240, // 10 KB (gzip)
"maxChunkSize": 262144, // 256 KB (raw)
"maxChunkSizeGzip": 65536 // 64 KB (gzip)
}
}To analyze the current bundle size:
npm run sizeThis will output:
- Total bundle size (raw and gzipped)
- JavaScript breakdown
- CSS breakdown
- Top 10 largest files
- JSON report in
out/bundle-analysis.json
To verify the bundle is within limits:
npm run size:checkThis command will fail if any limits are exceeded.
The comparison script compares two bundle analyses:
npx tsx scripts/compare-sizes.ts out/base-bundle.json out/current-bundle.jsonThis generates a detailed markdown report showing:
- Size changes (current vs previous)
- Percentage changes
- Limit violations
- File-by-file comparison
Runs on every push and pull request:
- Type checking
- Tests
- Build
- Format check
Runs on pull requests to main:
- Analyzes bundle size for both PR and base branch
- Posts comparison report as PR comment
- Fails if size limits are exceeded
- Shows current size when comparison isn't available (e.g., when adding new features)
Runs when a release PR is merged:
- Publishes package to npm
- Creates GitHub release
When you open a PR, the size-check workflow will automatically:
- Build and analyze your PR's bundle
- Build and analyze the base branch bundle
- Compare the two and post a detailed report
The report includes:
- Size changes with percentage differences
- Current size vs limits
- Violations (if any)
- Largest files with changes
- Full file breakdown in collapsible section
If the comparison script doesn't exist in the base branch (e.g., when adding this feature), it will show the current PR's bundle size instead.
The repository includes an automated bundle size badge in the README that updates on every push to main.
Badge Setup: See Bundle Size Badge Setup Guide for complete setup instructions.
The badge workflow (.github/workflows/update-badge.yml):
- Builds and analyzes the bundle on every push to
main - Updates a GitHub Gist with current size and historical data
- Powers a shields.io badge in the README
- Tracks the last 50 size measurements for trend analysis
Badge Colors:
- 🟢 Green: < 120 KB gzipped
- 🟡 Yellow: 120-150 KB gzipped
- 🔴 Red: > 150 KB gzipped
Testing badge generation locally:
First, generate the bundle analysis and badge data:
npm run build
npm run size -- --output out/bundle-analysis.json
npm run size:badge out/bundle-analysis.jsonThis creates out/size-data.json with the shields.io endpoint format:
{
"schemaVersion": 1,
"label": "bundle size",
"message": "150.57 KB",
"color": "brightgreen"
}This format is ready to be uploaded directly to the GitHub Gist for use with the shields.io endpoint badge.
Manually updating the badge:
If you need to manually update the GitHub Gist with the latest badge data:
./scripts/update-gist.sh YOUR_GIST_TOKENOr set the token as an environment variable:
export GIST_TOKEN=your_token
./scripts/update-gist.shThis is useful when testing badge changes or when you need to update the badge without pushing to main.
We use an automated release workflow with two different processes depending on the type of release.
For regular releases with new features and fixes:
- Install gh CLI:
brew install gh - Authenticate:
gh auth login - Run release script:
npm run release - Review and merge the PR
- GitHub will automatically publish to npm
For urgent fixes that need to be released from a previous version without including unreleased changes from main.
- Critical bugs in production that can't wait for the next regular release
- Security vulnerabilities that need immediate patching
- Breaking issues affecting users on a specific version
Note: Hotfixes always bump the patch version only (e.g., 1.2.2 → 1.2.3), never minor or major versions.
Start from the version tag you want to hotfix:
# Example: Create hotfix for v1.2.2
git checkout -b hotfix-branch v1.2.2Make your changes and commit them using conventional commits:
# Make your changes
git add .
git commit -m "fix: description of the hotfix"Run the hotfix release script:
npm run release:fixThis script will:
- Show the current version (e.g., 1.2.2)
- Prompt you to enter the hotfix description (e.g., "- Fix authentication timeout issue")
- Bump to the next patch version (e.g., 1.2.3)
- Update CHANGELOG.md with your description
- Create a release branch (e.g.,
release/1.2.3) - Push the branch and create a PR
Review the automatically created PR
- Go to Actions → Release workflow
- Click "Run workflow"
- Select branch:
release/1.2.3(or your release branch name) - Click "Run workflow"
The workflow will:
- Build and test from your release branch
- Automatically detect that this is an older version and publish to npm with
--tag legacy - Create a git tag (e.g.,
v1.2.3) - Create a GitHub release with changelog content
Note: The workflow now automatically detects when publishing an older version and applies the appropriate npm dist-tag, so hotfixes won't conflict with the latest tag.
If the fix should also be in main, make the necessary changes and do a normal release.
Follow semantic versioning:
- Patch (0.0.x): Bug fixes, security patches (used for hotfixes)
- Minor (0.x.0): New features, backward-compatible changes
- Major (x.0.0): Breaking changes
- Tree-shake unused code
- Lazy load heavy components
- Monitor the size report on every PR
- Consider alternatives before adding large dependencies
- Run
npm run formatbefore committing - Ensure
npm run type-checkpasses - Write tests for new features
- Update flow-specific READMEs when changing APIs
Each flow has its own README:
When modifying a flow, update its README accordingly.
- Run
npm run size:checklocally to see violations - Run
npm run sizeto see detailed breakdown - Identify large files or new dependencies
- Optimize or split code as needed
- If the increase is justified, update limits in
.sizelimit.json
- Ensure you've linked the package:
npm link @remoteoss/remote-flows - Restart both the package dev server and example dev server
- Check for build errors in both terminals
- Run
npm run type-checkto see all errors - Ensure dependencies are up to date
- Check for TypeScript version compatibility