Skip to content
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

More precise core-js version #556

Merged
merged 1 commit into from
Mar 14, 2025
Merged

More precise core-js version #556

merged 1 commit into from
Mar 14, 2025

Conversation

alexeyr-ci2
Copy link
Contributor

@alexeyr-ci2 alexeyr-ci2 commented Mar 12, 2025

Summary

Instead of fixed core-js version, take the current one from node_modules.

Pull Request checklist

  • [ ] Add/update test to cover these changes
  • [ ] Update documentation
  • Update CHANGELOG file

Summary by CodeRabbit

  • Documentation

    • Updated release notes to reflect changes in dependency version management.
  • New Features

    • Now automatically detects and uses the current version of a core dependency, ensuring the most up-to-date functionality.
  • Refactor

    • Enhanced version retrieval processes for increased accuracy and streamlined error messaging.

Sorry, something went wrong.

Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request updates the way the core-js version is determined and documented. The CHANGELOG.md now includes a "Changed" section noting that the version is dynamically retrieved from the node_modules directory. In the Babel preset configuration, a new function, coreJsVersion, is introduced to fetch the version via packageFullVersion, which handles errors and defaults to "3.8" if needed. Additionally, helper functions related to package version retrieval in package/utils/helpers.js are renamed and modified, with packageFullVersion returning the complete version and a new packageMajorVersion extracting the major version.

Changes

File(s) Change Summary
CHANGELOG.md
package/babel/preset.js
Added dynamic retrieval of the core-js version. Introduced coreJsVersion with enhanced error handling and updated the Babel preset configuration.
package/utils/helpers.js Renamed packageMajorVersion to packageFullVersion to return the full version string. Added a new implementation for extracting the major version.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant BP as Babel Preset
    participant CSV as coreJsVersion
    participant PFV as packageFullVersion
    
    BP->>CSV: Request core-js version
    CSV->>PFV: Retrieve package version from package.json
    alt Package exists
        PFV-->>CSV: Return full version string
        CSV-->>BP: Return computed major.minor version
    else MODULE_NOT_FOUND Error
        PFV-->>CSV: Throw error
        CSV-->>BP: Catch error, return default "3.8"
    end

Suggested reviewers

  • tomdracz
  • G-Rath

Poem

In a burrow of code I hop with glee,
Dynamic versions set the dependencies free.
Core-js now sings a flexible tune,
Babel grooves under the coding moon.
With helpers refined as crisp as dew,
This rabbit celebrates the change anew!
🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

🪧 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 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 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 generate docstrings to generate docstrings for 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.

@alexeyr-ci2 alexeyr-ci2 force-pushed the alexeyr/core-js-version branch from b8ad4b6 to ea3289d Compare March 12, 2025 19:33
Copy link

@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: 1

🧹 Nitpick comments (1)
package/utils/helpers.js (1)

44-51: Consider documenting the version extraction differences.

There's an inconsistency between how versions are extracted:

  • coreJsVersion uses regex to extract major.minor (e.g., "3.8")
  • packageMajorVersion extracts only the major version (e.g., "3")

While this may be intentional, it could lead to confusion. Consider adding comments to explain the different extraction patterns or standardize them if they should behave similarly.

🧰 Tools
🪛 ESLint

[error] 51-51: Insert ⏎·

(prettier/prettier)

🪛 GitHub Check: Linting

[failure] 51-51:
Insert ⏎·

🪛 GitHub Actions: Node based checks

[error] 51-51: Insert ⏎· prettier/prettier

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 685cb85 and ea3289d.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • package/babel/preset.js (3 hunks)
  • package/utils/helpers.js (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

19-19: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)

🪛 ESLint
package/utils/helpers.js

[error] 51-51: Insert ⏎·

(prettier/prettier)

🪛 GitHub Check: Linting
package/utils/helpers.js

[failure] 51-51:
Insert ⏎·

🪛 GitHub Actions: Node based checks
package/utils/helpers.js

[error] 51-51: Insert ⏎· prettier/prettier

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Generator specs (ubuntu-latest, 3.3, gemfiles/Gemfile-rails.7.2.x)
  • GitHub Check: Generator specs (ubuntu-latest, 3.3, gemfiles/Gemfile-rails.7.0.x)
  • GitHub Check: Generator specs (ubuntu-latest, 3.1, gemfiles/Gemfile-rails.7.2.x)
  • GitHub Check: Generator specs (ubuntu-latest, 3.0, gemfiles/Gemfile-rails.7.0.x)
  • GitHub Check: Generator specs (ubuntu-latest, 2.7, gemfiles/Gemfile-rails.6.1.x)
  • GitHub Check: Generator specs (ubuntu-latest, 3.1, gemfiles/Gemfile-rails.7.0.x)
  • GitHub Check: Generator specs (ubuntu-latest, 2.7, gemfiles/Gemfile-rails.7.0.x)
🔇 Additional comments (7)
CHANGELOG.md (1)

17-19: LGTM! Good documentation of the change.

The addition to the CHANGELOG clearly explains the change from using a fixed core-js version to dynamically taking the current one from node_modules. This matches the PR objectives and provides good context for other developers.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

19-19: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)

package/babel/preset.js (4)

1-1: Correctly updated imports to include the new functionality.

The import has been properly updated to include the packageFullVersion function that's needed for the new functionality.


3-13: Well-implemented version detection with fallback.

This coreJsVersion function is well structured with proper error handling. It:

  1. Tries to get the version using the new packageFullVersion function
  2. Extracts the major.minor version (e.g., "3.8" from "3.8.1")
  3. Provides a sensible fallback if the module isn't found
  4. Properly re-throws other errors

The approach gracefully handles the case where core-js isn't installed, maintaining compatibility.


36-36: Good implementation of dynamic version detection.

Using the coreJsVersion() function instead of hardcoding "3.8" is a good improvement that makes the configuration more adaptable to the actual installed package version.


25-25: Improved error message formatting.

The error message has been simplified by using direct string interpolation instead of JSON.stringify, making it more readable.

package/utils/helpers.js (2)

44-49: Good implementation of full version retrieval.

The packageFullVersion function provides a clean way to get the complete version string from a package's package.json file.


59-60: Successfully updated exports.

The module exports have been correctly updated to include both the new packageFullVersion function and the existing packageMajorVersion function.

}

const packageMajorVersion = (packageName) => packageFullVersion(packageName).match(/^\d+/)[0]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix formatting issue with missing newline.

While the implementation of packageMajorVersion is functionally correct, there's a linting error showing that a newline is missing after this line according to the project's coding standards.

Apply this diff to fix the formatting issue:

-const packageMajorVersion = (packageName) => packageFullVersion(packageName).match(/^\d+/)[0]
+const packageMajorVersion = (packageName) => packageFullVersion(packageName).match(/^\d+/)[0]

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 ESLint

[error] 51-51: Insert ⏎·

(prettier/prettier)

🪛 GitHub Check: Linting

[failure] 51-51:
Insert ⏎·

🪛 GitHub Actions: Node based checks

[error] 51-51: Insert ⏎· prettier/prettier

@alexeyr-ci2 alexeyr-ci2 force-pushed the alexeyr/core-js-version branch from ea3289d to 25b4b71 Compare March 12, 2025 19:43
Copy link

@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

🧹 Nitpick comments (1)
CHANGELOG.md (1)

17-20: Markdown List Style Consistency:
The new changelog entry on line 19 uses a dash (-) as the list marker. The markdown linting guidelines recommend using an asterisk (*) for unordered lists. To ensure consistency and adherence to the markdown style guide, consider switching to an asterisk.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

19-19: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea3289d and 25b4b71.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • package/babel/preset.js (3 hunks)
  • package/utils/helpers.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • package/babel/preset.js
  • package/utils/helpers.js
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

19-19: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Generator specs (ubuntu-latest, 3.0, gemfiles/Gemfile-rails.6.1.x)
  • GitHub Check: test

`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(
currentEnv
)}".`
`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${currentEnv}".`
Copy link
Member

Choose a reason for hiding this comment

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

why this change? you might just see Object without the old code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this actually happen? The documentation says

api.env() returns the current envName string.

@justin808 justin808 merged commit 4edd361 into main Mar 14, 2025
55 checks passed
@justin808 justin808 deleted the alexeyr/core-js-version branch March 14, 2025 07:28
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.

None yet

4 participants