Skip to content

fix: bun compatibility #2129

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

Merged
merged 1 commit into from
May 21, 2025
Merged

fix: bun compatibility #2129

merged 1 commit into from
May 21, 2025

Conversation

ymc9
Copy link
Member

@ymc9 ymc9 commented May 21, 2025

  • explicitly pass "types": [] to tsconfig to avoid bun compilation errors
  • detect bun as package manager when running "zenstack init"

fixes #2124

- explicitly pass "types": [] to tsconfig to avoid bun compilation errors
- detect bun as package manager

fixes Error compiling generated code #2124
Copy link
Contributor

coderabbitai bot commented May 21, 2025

📝 Walkthrough

Walkthrough

The changes add support for the Bun package manager in package utility functions and update TypeScript compiler options in the code generation process. Specifically, Bun is now recognized and handled for package installation, and the generated project's compiler options include skipDefaultLibCheck: true and an empty types array.

Changes

Files/Paths Change Summary
packages/schema/src/utils/pkg-utils.ts Added Bun package manager support in package detection and installation logic.
packages/sdk/src/code-gen.ts Updated createProject to set skipDefaultLibCheck: true and types: [] in TypeScript config.

Assessment against linked issues

Objective Addressed Explanation
Prevent TypeScript errors from Bun type definitions in generated code (#2124)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 47be505 and cde3afd.

📒 Files selected for processing (2)
  • packages/schema/src/utils/pkg-utils.ts (3 hunks)
  • packages/sdk/src/code-gen.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/schema/src/utils/pkg-utils.ts (1)
packages/schema/src/utils/exec-utils.ts (1)
  • execSync (6-10)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build-test (20.x)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
🔇 Additional comments (3)
packages/sdk/src/code-gen.ts (1)

18-19: Good addition for Bun compatibility!

Adding skipDefaultLibCheck: true and types: [] to the TypeScript compiler options is a perfect solution for Bun compatibility.

  • skipDefaultLibCheck: true prevents checking TypeScript's built-in definition files, which can cause issues with Bun's runtime environment
  • types: [] explicitly avoids including automatic type definitions that might conflict with Bun's environment

These changes help avoid TypeScript compilation errors when using Bun without affecting other package managers or runtime environments.

packages/schema/src/utils/pkg-utils.ts (2)

70-70: Good implementation of Bun detection!

Adding support for detecting Bun via its lock file follows the existing pattern for other package managers and ensures that the correct package manager is identified when Bun is used.

Also applies to: 80-80


103-110:

✅ Verification successful

Verify Bun installation command structure

The implementation for Bun package installation looks good, but let's verify the command structure is correct for Bun.

  • The --cwd flag may need verification as Bun CLI might use a different flag for specifying the working directory
  • Make sure the order of flags (--exact and --dev) is correct according to Bun's CLI documentation

🌐 Web query:

What is the correct syntax for installing packages with Bun CLI and specifying a different working directory?

💡 Result:

The correct syntax for installing packages with Bun CLI while specifying a different working directory is to use the -C or --cwd option followed by the path to the desired directory.

For example:

bun install -C /path/to/your/project

or

bun install --cwd /path/to/your/project

This tells Bun to run the install command in the specified directory instead of the current one.


🌐 Web query:

What flags does Bun CLI’s `bun install` command support for installing exact versions (`--exact`) and dev dependencies (`--dev`), and is there any required ordering of these flags?

💡 Result:

The Bun CLI’s bun install command supports the following flags related to installing exact versions and dev dependencies:

  • --exact: This flag installs packages using exact version numbers rather than version ranges. It ensures that the dependency is installed at the exact version specified.
  • --dev: This flag installs packages as development dependencies, meaning they are listed in the devDependencies section of package.json.

Regarding the ordering, Bun CLI does not require any specific order when using these flags together. You can combine them in any order such as:

bun install <package-name> --exact --dev

or

bun install <package-name> --dev --exact

Both commands will achieve the same result: installing the package as an exact version in the devDependencies.

If you want, I can check the latest official Bun documentation or source for any recent updates or specific remarks on the flag usage. Would you like me to do that?


Bun install command flags are correct

I’ve verified that Bun CLI supports --cwd (or -C) for specifying the working directory, as well as --exact and --dev for exact-version and dev‐dependency installs. There’s no required ordering for these flags, so the existing implementation is valid—no changes needed.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ymc9 ymc9 merged commit d27094f into dev May 21, 2025
11 checks passed
@ymc9 ymc9 deleted the fix/bun-compat branch May 21, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant