-
Notifications
You must be signed in to change notification settings - Fork 2k
Enhance build process with Rslib
#1214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
All contributors have signed the CLA. Thank you! ✅ |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Tavily API Key | b56404b | opencode.json | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 7 files
Confidence score: 3/5
- Removal of schema generation from build/prepublish could leave
schema.jsonmissing in the published package, which is a user-facing regression risk. - Score reflects a concrete medium-severity (7/10) packaging concern rather than a clear break, but it could impact consumers relying on the schema export.
- Pay close attention to
package.json- ensure schema generation still runs before publish to avoid missing artifacts.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="package.json">
<violation number="1" location="package.json:28">
P1: Schema generation removed from build/prepublish; exported schema.json may be missing from published package</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| "scripts": { | ||
| "build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema", | ||
| "build:all": "bun run build && bun run build:binaries", | ||
| "build": "rslib build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Schema generation removed from build/prepublish; exported schema.json may be missing from published package
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At package.json, line 28:
<comment>Schema generation removed from build/prepublish; exported schema.json may be missing from published package</comment>
<file context>
@@ -18,14 +18,18 @@
"scripts": {
- "build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema",
- "build:all": "bun run build && bun run build:binaries",
+ "build": "rslib build",
+ "build:all": "rslib build && bun run build:binaries",
"build:binaries": "bun run script/build-binaries.ts",
</file context>
The externalized commonjs request `@ast-grep/napi` from `~./oh-my-opencode/src/tools/ast-grep/constants.ts` will use "module" external type in ESM format. If you want to specify other external type, consider setting the request and type with `output.externals`
Rslib vs Old Bun Build - Key Improvements
Overview
This PR description summarizes the improvements achieved by migrating from the old
bun buildpipeline toRslibfor theoh-my-opencodeproject.Configuration & Simplicity
bun build+tscrslib buildrslib.config.tstsc --emitDeclarationOnly)Before: Complex Multi-Command Build
&&After: Single Declarative Command
Build Performance & Output
Bundle Size Reduction
Before: 2.51 MB (main library bundleless mode)
After: 1.0 MB (main library bundled mode)
Declaration Files
Before (Bundleless Mode):
After (Bundle Mode):
Benefits:
Developer Experience
Workflow Comparison
Old Workflow:
bun buildflagstscseparatelyNew Workflow:
rslib.config.ts(declarative, self-documenting)bun run buildConfiguration Example
Before: Manual inline flags repeated in package.json
{ "scripts": { "build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema" } }After: Centralized, readable configuration
Benefits:
Feature Improvements
1. Unified Pipeline
rslib buildorchestrating everything2. 57.8% Bundle Size Reduction
3. Built-in TypeScript Declaration Handling
tsc --emitDeclarationOnlysteprslib build4. Bundled Type Declarations
.d.tsfilesdist/index.d.ts(84 KB)5. Configuration-Driven Build
rslib.config.ts6. Extensibility
bun buildcapabilities7. Better Caching
8. Cleaner Output Structure
Package.json Exports
Updated for Rslib Output
{ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }, "./cli": { "types": "./dist/cli", "import": "./dist/cli/index.js" }, "./schema.json": "./dist/oh-my-opencode.schema.json" }, "bin": { "oh-my-opencode": "./bin/oh-my-opencode.js" } }Changes:
"./cli"export for programmatic imports"."export for main library"./schema.json"exportSummary
Conclusion
The migration from
bun buildtoRslibhas delivered significant improvements:The
oh-my-opencodeproject now has a modern, maintainable, and performant build pipeline powered byRslib.Summary by cubic
Migrated the build pipeline to Rslib for a single-command, config-driven build with bundled output and types, reducing the main library to ~1.0 MB and improving type consumption.
Refactors
Dependencies
Written for commit b1511b4. Summary will update on new commits.