Skip to content

Conversation

@tclxshunquan-wang
Copy link
Contributor

@tclxshunquan-wang tclxshunquan-wang commented Jun 27, 2025

Summary by CodeRabbit

  • New Features

    • Added support for React fragments in inspector plugins, improving compatibility with React code using fragments.
  • Bug Fixes

    • Inspector plugins now correctly handle React fragments without adding unnecessary source annotations.
  • Tests

    • Introduced new test suites to verify correct handling and source injection for React fragments.
  • Chores

    • Updated and synchronized dependencies across multiple packages.
    • Removed unused dependencies from example projects and packages.
    • Improved TypeScript configuration and dependency management for better maintainability.
  • Style

    • Minor updates to example projects to wrap elements in React fragments for consistency.

@coderabbitai
Copy link

coderabbitai bot commented Jun 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces support for React fragments in the inspector Babel and SWC plugins, ensuring these plugins can now properly identify and process both <Fragment> and <React.Fragment> elements. The change includes new tests and fixtures for fragment handling, dependency updates across multiple packages, and minor configuration adjustments in example projects and package files.

Changes

Files/Paths Change Summary
packages/inspector-babel-plugin/src/inspector-babel-plugin.ts,
crates/inspector-swc-plugin/transform/src/lib.rs
Added helper functions to detect React fragments and updated logic to skip processing them in plugins.
packages/inspector-babel-plugin/tests/fixtures/react-fragment.tsx,
crates/inspector-swc-plugin/tests/fixtures/react-fragment.tsx
Added new React component fixtures demonstrating usage of both Fragment and React.Fragment.
packages/inspector-babel-plugin/tests/react-fragment.spec.ts,
crates/inspector-swc-plugin/tests/react-fragment.spec.ts
Added test suites to verify correct handling and annotation of React fragments in transformed code.
.changeset/cool-pigs-warn.md,
.changeset/smooth-steaks-scream.md
Added changeset notes summarizing fragment support and dependency updates.
packages/inspector-babel-plugin/package.json,
crates/inspector-swc-plugin/package.json,
packages/inspector-common/package.json,
packages/inspector-component/package.json,
packages/inspector-middleware/package.json,
packages/inspector/package.json,
packages/next-inspector/package.json,
website/package.json
Updated devDependencies: upgraded Vitest-related packages, added/updated @types/react, removed next/postcss.
crates/inspector-swc-plugin/tsconfig.json Added path alias for @hyperse/inspector-common.
Cargo.toml Pinned swc_config dependency to exact version 3.1.1.
examples/example-nextjs/package.json,
examples/example-rspack/package.json
Removed babel-loader from devDependencies; updated next version in Next.js example.
examples/example-nextjs/src/app/(home)/page.tsx,
examples/example-rspack/src/App.tsx,
examples/example-webpack/src/App.tsx
Wrapped UI elements in <Fragment>; added or updated imports accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant InspectorPlugin (Babel/SWC)
    participant React Code

    User->>InspectorPlugin (Babel/SWC): Transform React code with fragments
    InspectorPlugin (Babel/SWC)->>React Code: Parse JSX elements
    alt Element is Fragment or React.Fragment
        InspectorPlugin (Babel/SWC)-->>React Code: Skip adding source annotation
    else Other JSX elements
        InspectorPlugin (Babel/SWC)->>React Code: Add source annotation
    end
    InspectorPlugin (Babel/SWC)-->>User: Output transformed code
Loading

Poem

In fields of code where fragments play,
The inspector hops in, clearing the way.
No tags or traces on fragments you'll see—
Just pure React magic, as clean as can be.
With dependencies fresh and tests in bloom,
The rabbit leaps on, dispelling the gloom!
🐇✨


📜 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 253d9af and 68bf503.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (23)
  • .changeset/cool-pigs-warn.md (1 hunks)
  • .changeset/smooth-steaks-scream.md (1 hunks)
  • Cargo.toml (1 hunks)
  • crates/inspector-swc-plugin/package.json (1 hunks)
  • crates/inspector-swc-plugin/tests/fixtures/react-fragment.tsx (1 hunks)
  • crates/inspector-swc-plugin/tests/react-fragment.spec.ts (1 hunks)
  • crates/inspector-swc-plugin/transform/src/lib.rs (2 hunks)
  • crates/inspector-swc-plugin/tsconfig.json (1 hunks)
  • examples/example-nextjs/package.json (1 hunks)
  • examples/example-nextjs/src/app/(home)/page.tsx (2 hunks)
  • examples/example-rspack/package.json (0 hunks)
  • examples/example-rspack/src/App.tsx (2 hunks)
  • examples/example-webpack/src/App.tsx (2 hunks)
  • packages/inspector-babel-plugin/package.json (1 hunks)
  • packages/inspector-babel-plugin/src/inspector-babel-plugin.ts (2 hunks)
  • packages/inspector-babel-plugin/tests/fixtures/react-fragment.tsx (1 hunks)
  • packages/inspector-babel-plugin/tests/react-fragment.spec.ts (1 hunks)
  • packages/inspector-common/package.json (1 hunks)
  • packages/inspector-component/package.json (1 hunks)
  • packages/inspector-middleware/package.json (1 hunks)
  • packages/inspector/package.json (1 hunks)
  • packages/next-inspector/package.json (2 hunks)
  • website/package.json (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 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.

@tianyingchun tianyingchun merged commit 5364868 into hyperse-io:main Jun 27, 2025
5 of 7 checks passed
@tclxshunquan-wang tclxshunquan-wang deleted the feat/upt-swc branch August 29, 2025 14:08
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.

2 participants