Skip to content

Bun experiment #1418

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

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Bun experiment #1418

wants to merge 1 commit into from

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Jan 16, 2024

https://bun.sh


PR-Codex overview

This PR focuses on updating dependencies and configuration files.

Detailed summary

  • Added directories and files to .eslintignore and .prettierignore
  • Added new directories and files to .gitignore
  • Updated devDependencies for @commitlint/cli and @commitlint/config-conventional
  • Updated prettier-config/index.js with new configuration options
  • Updated tsconfig/base.json with new compiler options
  • Updated eslint-config/.eslintrc.js with new extends and parser options
  • Updated package.json scripts
  • Updated dependencies and devDependencies in package.json

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Enhanced ESLint and Prettier configurations for improved code quality and formatting.
    • Introduced new Hardhat plugins for better project monitoring and contract analysis.
  • Bug Fixes

    • Updated dependencies to ensure compatibility and stability within the project.
  • Documentation

    • Improved TypeScript configuration for better type-checking and debugging.
  • Chores

    • Removed unnecessary workspace entries from project configuration.
    • Streamlined build and testing scripts for efficiency.

@jaybuidl jaybuidl added Type: Toolchain ⚒️ Build tools configuration, CI/CD maintenance labels Jan 16, 2024
@jaybuidl jaybuidl self-assigned this Jan 16, 2024
Copy link

@jaybuidl jaybuidl changed the title Bun experiment [WIP] Bun experiment Jan 16, 2024
Base automatically changed from chore/node20 to dev January 23, 2024 21:37
Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Walkthrough

The changes encompass updates to configuration files and package management within a TypeScript project. Key modifications include the expansion of ignored files and directories in ESLint and Prettier configurations, enhancements to the Hardhat configuration with new plugins, and adjustments to scripts and dependencies in the package.json files. TypeScript compiler options have been refined, and new dependencies have been introduced. Overall, these changes aim to streamline the development process and improve project organization.

Changes

File(s) Change Summary
contracts/.eslintignore Expanded the list of ignored files and directories for ESLint, including build artifacts and environment files.
contracts/.prettierignore Updated the list of ignored files and directories for Prettier, focusing on build artifacts, environment files, and specific lock files.
contracts/hardhat.config.ts Modified the configuration by rearranging import statements and adding/removing Hardhat plugins to enhance functionality.
contracts/package.json Simplified test scripts, updated dependencies, and modified viem generation scripts, including a transition to bun run.
eslint-config/.eslintrc.js Enhanced linting setup with updated parser options, simplified unused variable rules, and added a new rule for handling promises.
package.json Removed workspace entries and updated versions of commit linting packages.
prettier-config/index.js Updated formatting options, including trailing commas and added overrides for TypeScript and Solidity files.
tsconfig/base.json Changed TypeScript compiler options, including target ECMAScript version, added libraries, and enabled metadata generation features.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant ESLint
    participant Prettier
    participant Hardhat
    participant TypeScript

    Developer->>ESLint: Run linting
    ESLint->>Developer: Return linting results

    Developer->>Prettier: Run formatting
    Prettier->>Developer: Return formatting results

    Developer->>Hardhat: Deploy contracts
    Hardhat->>Developer: Confirm deployment

    Developer->>TypeScript: Compile code
    TypeScript->>Developer: Return compilation results
Loading

Poem

🐰 In the meadow where code does play,
Changes hop in a bright new way.
ESLint and Prettier dance in line,
With Hardhat plugins, all will shine.
TypeScript's tunes are crisp and clear,
Hooray for updates, let’s give a cheer! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate unit testing code for this file.
    -- @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 generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @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.

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 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 or @coderabbitai title 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
eslint-config/.eslintrc.js (1)

54-54: LGTM!

Turning off the @typescript-eslint/no-inferrable-types rule allows for more flexibility in type declarations, especially in scenarios where explicit type annotations are preferred for clarity or consistency.

Consider adding a comment to explain the rationale behind turning off this rule, as it may deviate from the default recommended settings. This can help maintain consistency and clarity for future contributors.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 24e11b1 and a296bb8.

Files ignored due to path filters (2)
  • bun.lockb is excluded by !**/bun.lockb
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (8)
  • contracts/.eslintignore (1 hunks)
  • contracts/.prettierignore (1 hunks)
  • contracts/hardhat.config.ts (1 hunks)
  • contracts/package.json (3 hunks)
  • eslint-config/.eslintrc.js (3 hunks)
  • package.json (1 hunks)
  • prettier-config/index.js (3 hunks)
  • tsconfig/base.json (1 hunks)
Additional comments not posted (29)
contracts/.prettierignore (1)

1-23: LGTM!

The additions to the .prettierignore file are logically grouped and cover common directories and files that do not need to be formatted by Prettier. This will help streamline the development process by preventing unnecessary formatting checks on files that do not require it.

The changes are unlikely to have any negative impact on the project.

contracts/.eslintignore (1)

1-23: LGTM!

The additions to the .eslintignore file are appropriate and align with common practices for TypeScript projects. Ignoring build artifacts, coverage reports, and lock files helps keep the linting process focused on the source code.

tsconfig/base.json (6)

2-2: LGTM!

The comment provides useful context about the origin of the configuration.


6-8: LGTM!

Including the es2020 library ensures that the TypeScript compiler recognizes the appropriate standard library features.


12-14: LGTM!

Including the bun-types ensures that the TypeScript compiler recognizes the Bun runtime environment types.


18-18: LGTM!

Enabling the declarationMap option allows for better debugging by mapping declarations back to their original source files.


24-24: Verify the usage of decorators in the project.

The emitDecoratorMetadata option is essential for projects using decorators. If the project is not using decorators, this option can be safely removed.

Run the following script to search for decorator usage:


5-5: Verify compatibility with the es2020 target.

Ensure that the codebase does not use any features introduced after es2020, as they may not be supported with this target.

Run the following script to search for potential incompatible features:

Verification successful

Changing the target to ES2020 is consistent with existing configurations

The modification of the "target" to "es2020" in the base tsconfig.json file aligns with the existing configuration in the web project. The web/tsconfig.json already specifies "target": "es2020", and the project uses Parcel for building, which can handle modern JavaScript features and perform necessary transpilation.

While some ES2021 features (like the 'at()' method) were found in the web code, this is not a concern because:

  1. The web project has its own TypeScript configuration targeting ES2020.
  2. Parcel, the build tool used in the web project, can transpile newer features for browser compatibility.

This change in the base configuration actually improves consistency across the project.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for potential es2021 features in .ts files.

# Test: Search for es2021 features. Expect: No occurrences of es2021 features.
rg --type ts -e 'replaceAll|at\(' 

Length of output: 3904


Script:

#!/bin/bash
# Description: Search for additional ES2021 features and check for separate tsconfig files

# Search for other ES2021 features
echo "Searching for additional ES2021 features:"
rg --type ts -e 'Promise\.any|AggregateError|WeakRef|FinalizationRegistry|Intl\.ListFormat|Intl\.Segmenter'

# Check for separate tsconfig files
echo -e "\nChecking for separate tsconfig files:"
fd tsconfig.json

# Look for build scripts
echo -e "\nSearching for build scripts:"
rg --type yaml -e 'build:|compile:' package.json

Length of output: 501


Script:

#!/bin/bash
# Description: Examine TypeScript configurations and build scripts

# Check the contents of web/tsconfig.json
echo "Contents of web/tsconfig.json:"
cat web/tsconfig.json

# Look for package.json in the web directory
echo -e "\nContents of web/package.json (if exists):"
cat web/package.json 2>/dev/null || echo "web/package.json not found"

# Verify the contents of the base tsconfig.json
echo -e "\nContents of tsconfig/base.json:"
cat tsconfig/base.json

Length of output: 6460

prettier-config/index.js (4)

4-4: Trailing comma option updated to enforce consistency.

The trailingComma option has been updated from "es5" to "all", which will enforce trailing commas wherever possible in the codebase, including function parameters and calls. This change promotes consistency in code formatting across the project.

Note that this may introduce trailing commas in places where they were not present before, so be prepared for a significant number of formatting changes in the codebase.


16-17: Solidity formatting options updated for compatibility.

The Prettier configuration for Solidity files (.sol) has been updated with two new options:

  1. compiler: "0.8.18": This option specifies the Solidity compiler version to use for formatting Solidity files, ensuring compatibility with the latest features and syntax.

  2. parser: "solidity-parse": This option specifies the parser to use for Solidity files, which is necessary for proper formatting.

These changes will improve the formatting of Solidity files and maintain compatibility with the latest Solidity version.


26-35: New override added for TypeScript files.

A new override has been introduced for TypeScript files (.ts) with the following options:

  1. parser: "typescript": This option specifies the parser to use for TypeScript files, ensuring proper formatting.

  2. importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]: This option defines the order in which import statements should be organized. Third-party modules will be placed first, followed by local imports.

  3. importOrderParserPlugins: ["typescript"]: This option specifies the parser plugins to use for organizing import statements in TypeScript files.

  4. importOrderSeparation: true: This option adds a separator between import groups, improving readability.

  5. importOrderSortSpecifiers: true: This option sorts the imported symbols within each import statement alphabetically.

These options work together to maintain a structured and organized import statement format in TypeScript files, enhancing code readability and maintainability.


Line range hint 1-38: Overall, the changes in this Prettier configuration file are excellent!

The updates made to the Prettier configuration file are focused on improving formatting consistency and compatibility across different file types, including JSON, Solidity, and TypeScript. The changes include:

  1. Updating the trailingComma option to enforce consistency in code formatting.
  2. Adding Solidity-specific options to ensure compatibility with the latest Solidity features and syntax.
  3. Introducing a new override for TypeScript files to maintain a structured and organized import statement format.

These changes will enhance the overall code quality and maintainability of the project. Great job!

eslint-config/.eslintrc.js (4)

2-7: LGTM!

Extending the ESLint configuration with recommended settings from various plugins is a good practice to enable a comprehensive set of linting rules for a TypeScript project.


10-10: LGTM!

Specifying the project configuration file in parserOptions is essential for TypeScript projects to enable type-checking and other features in ESLint. This ensures that ESLint can leverage TypeScript's type information for more accurate linting.


24-25: LGTM!

Simplifying the varsIgnorePattern and argsIgnorePattern rules for no-unused-vars to only ignore variables and arguments that start with an underscore is a good practice. This streamlines the linting process by reducing false positives for intentionally unused variables and arguments.


47-53: LGTM!

Introducing the @typescript-eslint/no-floating-promises rule to enforce handling of promises is a good practice. It helps prevent potential unhandled promise rejections and improves the overall reliability of the codebase. The rule options to ignore IIFE and void expressions allow for flexibility in certain scenarios where the promise handling is intentional.

package.json (2)

Line range hint 17-23: Verify the impact of removing the bots and kleros-sdk workspaces.

The "bots" and "kleros-sdk" entries have been removed from the workspaces array. This change suggests a potential restructuring or simplification of the project's workspace organization.

Please ensure that the removal of these workspaces doesn't break any dependencies or workflows within the project. You can run the following script to check for any broken dependencies or workflows:

If there are no errors, then the removal of the bots and kleros-sdk workspaces hasn't broken any dependencies or workflows.

Verification successful

Removal of bots and kleros-sdk workspaces appears to be safe.

Based on the analysis of the codebase:

  1. No references to 'bots' or 'kleros-sdk' were found in .js, .ts, or .json files.
  2. No dependencies on 'bots' or 'kleros-sdk' were found in the package.json files of the remaining workspaces.

These findings suggest that the removal of these workspaces is unlikely to break any dependencies or workflows within the project. The change appears to be a safe simplification of the project's workspace organization.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Navigate to the root of the monorepo
cd "$(git rev-parse --show-toplevel)"

# Install dependencies
yarn install

# Check for any broken dependencies
yarn workspaces info

# Check for any broken imports
yarn workspaces foreach -ptv run tsc --noEmit

Length of output: 359


Script:

#!/bin/bash
# Check if npm is available
if command -v npm &> /dev/null; then
    echo "npm is available"
    npm list --depth=0
    npm list --depth=1 bots kleros-sdk
else
    echo "npm is not available"
fi

# Search for references to bots and kleros-sdk in the codebase
echo "Searching for 'bots' references:"
grep -R --include="*.js" --include="*.ts" --include="*.json" "bots" .
echo "Searching for 'kleros-sdk' references:"
grep -R --include="*.js" --include="*.ts" --include="*.json" "kleros-sdk" .

# Inspect package.json files in other workspaces for dependencies
echo "Checking dependencies in workspace package.json files:"
find . -name "package.json" -not -path "*/node_modules/*" -exec sh -c 'echo "File: {}"; grep -E "\"(bots|kleros-sdk)\":" {}' \;

Length of output: 876


33-34: Verify compatibility of the updated commitlint packages.

The @commitlint/cli and @commitlint/config-conventional packages have been updated to version ^18.4.2. This update can bring bug fixes, performance improvements, and new features.

Please ensure that the updated versions are compatible with the project's existing configuration and dependencies. You can run the following script to verify that the commitlint setup is working as expected:

If there are no errors, then the updated commitlint packages are compatible with the project.

contracts/package.json (7)

25-25: Verify the testing process after simplifying the test script.

The change simplifies the testing command by removing the TS_NODE_TRANSPILE_ONLY=1 prefix, which can improve the developer experience.

Please ensure that removing the prefix does not introduce any unintended consequences or break the testing process. Consider running the following verification steps:

  1. Execute the simplified test script and ensure that all tests pass successfully.
  2. Verify that the TypeScript transpilation process during testing remains unaffected by the change.
  3. Confirm that the test coverage and results are consistent with the previous configuration.

If any issues arise during the verification process, please investigate and address them accordingly.


32-35: Monitor the viem generation process for relevant warnings.

The change removes the NODE_NO_WARNINGS=1 prefix from the viem generation scripts, which may allow warnings to be displayed during the generation process.

Please consider the following:

  1. Run the viem generation scripts and observe any warnings that are displayed.
  2. Assess the relevance and impact of the warnings on the generated output and the development process.
  3. If any critical warnings are encountered, investigate and address them appropriately.
  4. Consider documenting any notable warnings and their implications in the project's documentation or release notes.

Monitoring the warnings during the viem generation process can provide valuable insights and help maintain the quality of the generated code.


39-39: Verify the compatibility and functionality of the viem:test script with the Bun runtime.

The change updates the viem:test script to use bun run instead of NODE_OPTIONS=--experimental-fetch ts-node, indicating a transition to the Bun runtime for executing the script.

Please consider the following verification steps:

  1. Ensure that all required dependencies for the viem:test script are compatible with the Bun runtime.
  2. Execute the viem:test script using bun run and verify that it runs successfully without any errors or compatibility issues.
  3. Compare the execution time and performance of the script using the Bun runtime against the previous Node.js configuration to assess any improvements or regressions.
  4. Verify that the script's functionality and output remain consistent with the expected behavior.

If any compatibility issues or discrepancies are encountered during the verification process, please investigate and address them accordingly to ensure a smooth transition to the Bun runtime.


40-44: Verify the execution of the bot scripts using the updated hardhat run command.

The change updates the bot scripts to use hardhat run instead of yarn hardhat run, suggesting a shift from using Yarn to directly invoking Hardhat for running the scripts.

Please consider the following verification steps:

  1. Ensure that all required dependencies and configurations are properly set up for running the bot scripts with Hardhat.
  2. Execute each bot script using the updated hardhat run command and verify that they run successfully without any errors or issues.
  3. Compare the execution behavior and output of the bot scripts using the updated command against the previous Yarn-based configuration to ensure consistency.
  4. Verify that the bot scripts' functionality and interactions with the relevant networks and contracts remain unaffected by the change.

If any issues or discrepancies are encountered during the verification process, please investigate and address them accordingly to ensure a smooth transition to using hardhat run for executing the bot scripts.


71-71: Verify the impact of downgrading the @types/node package version.

The change downgrades the @types/node package version from ^20.11.3 to ^18.0.0, which may affect compatibility with certain Node.js features and APIs.

Please consider the following verification steps:

  1. Review the project's codebase and identify any usage of Node.js features or APIs that may be affected by the downgrade.
  2. Ensure that all required Node.js functionality is still available and properly typed with the downgraded @types/node version.
  3. Run the project's test suite and verify that there are no type-related errors or compatibility issues arising from the downgrade.
  4. Consider documenting any notable changes or limitations introduced by the downgrade in the project's documentation or release notes.

If any compatibility issues or breaking changes are identified during the verification process, please assess the impact and consider updating the codebase or exploring alternative solutions to ensure the project's stability and functionality.


74-74: Verify the integration of Bun and the usage of the bun-types package.

The addition of the bun-types package suggests that the project is introducing support for the Bun runtime, which can offer performance improvements and additional functionality.

Please consider the following verification steps:

  1. Ensure that the project's codebase is compatible with the Bun runtime and that any necessary adaptations are made to leverage Bun's features effectively.
  2. Verify that the bun-types package is properly installed and that the TypeScript compiler can access the Bun-specific type definitions.
  3. Review the project's code and identify areas where Bun-specific APIs or features are being used, ensuring that they are properly typed and utilized.
  4. Run the project's test suite and verify that there are no type-related errors or compatibility issues related to the integration of Bun.
  5. Consider documenting the integration of Bun and any notable changes or benefits it brings to the project in the project's documentation or release notes.

If any issues or incompatibilities are identified during the verification process, please investigate and address them accordingly to ensure a smooth integration of Bun into the project.


83-84: Monitor the hardhat-deploy and hardhat-deploy-ethers packages for critical updates and security patches.

The change in version specifications from caret (^) to exact versions for hardhat-deploy and hardhat-deploy-ethers suggests a stricter dependency management approach, ensuring more predictable and reproducible builds.

Please consider the following:

  1. Regularly monitor the release notes and changelogs of the hardhat-deploy and hardhat-deploy-ethers packages for any critical updates, bug fixes, or security patches.
  2. Assess the impact and relevance of any updates to the project's requirements and functionality.
  3. If any critical updates or security patches are released, consider updating the exact versions of the packages in the project's dependencies to incorporate the necessary changes.
  4. Thoroughly test the project after updating the package versions to ensure compatibility and stability.

By actively monitoring the packages and selectively updating to incorporate critical updates and security patches, the project can maintain a balance between stability and staying up to date with important fixes and enhancements.

contracts/hardhat.config.ts (4)

2-2: LGTM!

Adding an empty line improves readability by separating import statements from the rest of the code.


6-7: LGTM!

The changes introduce two new imports:

  • The dotenv package is imported to load environment variables from a .env file, which is a common practice for managing configuration.
  • The hardhat-contract-sizer plugin is imported to analyze contract sizes, which can be useful for optimizing gas usage.

10-16: LGTM!

The changes introduce several new Hardhat plugins and rearrange the import statements:

  • hardhat-deploy-tenderly for deploying contracts to Tenderly.
  • hardhat-docgen for generating documentation.
  • hardhat-gas-reporter for reporting gas usage.
  • hardhat-tracer for tracing Solidity function calls.
  • hardhat-watcher for watching and recompiling contracts.
  • solidity-coverage for Solidity code coverage.

The HardhatUserConfig type is also imported from hardhat/config.

These plugins can enhance the development workflow and provide useful features for testing, deployment, and documentation.


17-18: LGTM!

The changes add an empty line for readability and import simulation tasks from a local file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant