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

Fix/use exports with import and require #16765

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

karliatto
Copy link
Member

Description

Changing the exports field to be more descriptive about what entrypoint is defined.
Also I like more the syntax using require and import instead of node and default that I introduced last week.
From:

    "exports": {
        "node": "./lib/index.js",
        "default": "./libESM/index.js"
    },

To:

    "exports": {
        ".": {
            "import": "./libESM/index.js",
            "require": "./lib/index.js"
        }
    },

Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

The pull request updates the module export definitions in three package.json files. In the @trezor/connect-plugin-ethereum and @trezor/connect-plugin-stellar packages, the previous separate export entries for node and default have been consolidated into a single export mapped under "." with distinct "import" and "require" paths for ES modules and CommonJS usage. Additionally, the @trezor/utils package has been enhanced with a new "exports" field that clearly defines its entry points for both module systems. These changes standardize the export structure across the packages, ensuring consistent module resolution behavior.

Possibly related PRs

  • Build: connect plugins support esm #16729: This PR involves changes to the exports field for ESM support in the @trezor/connect-plugin-ethereum package, which directly relates to the modifications presented here.

Suggested labels

connect, no-project

Suggested reviewers

  • martykan
  • mroz22
  • Nodonisko

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5fa3d45 and 345033b.

📒 Files selected for processing (3)
  • packages/connect-plugin-ethereum/package.json (1 hunks)
  • packages/connect-plugin-stellar/package.json (1 hunks)
  • packages/utils/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build-deploy
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: test
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (3)
packages/utils/package.json (1)

21-26: Clear and Correct Exports Field:
The updated "exports" field now explicitly defines the entry points for both ES modules ("import": "./libESM/index.js") and CommonJS ("require": "./lib/index.js"), which greatly improves clarity and usability. This change aligns with modern module resolution standards and enhances consumer compatibility.

packages/connect-plugin-ethereum/package.json (1)

30-35: Enhanced Module Export Structure

The updated exports field now uses a consolidated key "." with distinct import and require properties. This change improves clarity by explicitly distinguishing between the ES module and CommonJS entry points. It aligns well with modern Node.js recommendations and enhances overall module usability.

packages/connect-plugin-stellar/package.json (1)

25-30: Update exports field to distinguish ESM and CommonJS clearly.

The updated "exports" field now consolidates the module entry point definitions under "." with separate "import" and "require" paths. This change directly aligns with the PR objectives, providing a clearer and more descriptive configuration for module resolution in both ES module and CommonJS contexts. Consider verifying that any related documentation or build scripts are updated accordingly.


🪧 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. (Beta)
  • @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.

@karliatto karliatto marked this pull request as ready for review February 3, 2025 11:26
@karliatto karliatto force-pushed the fix/use-exports-with-import-and-require branch from 345033b to ce6e973 Compare February 3, 2025 13:33
@karliatto karliatto added the no-project This label is used to specify that PR doesn't need to be added to a project label Feb 3, 2025
@karliatto karliatto merged commit 418bd0f into develop Feb 3, 2025
15 of 16 checks passed
@karliatto karliatto deleted the fix/use-exports-with-import-and-require branch February 3, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-project This label is used to specify that PR doesn't need to be added to a project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants