Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented May 21, 2025

close #27

Summary by CodeRabbit

  • New Features
    • Upgraded to support rspress version 2, introducing compatibility with the latest major release.
  • Dependency Updates
    • Updated multiple dependencies and development dependencies to newer versions.
    • Added support for Sass via a new dependency.
  • Bug Fixes
    • Improved type definitions for Markdown processing and image normalization.
    • Enhanced Table of Contents styling by updating CSS classes.
  • Refactor
    • Removed custom Shiki syntax highlighting integration and related styles.
    • Simplified code highlighting logic in JSON/YAML viewers.
  • Chores
    • Removed obsolete files and cleaned up unused type imports and properties.

@JounQin JounQin requested a review from Copilot May 21, 2025 09:14
@JounQin JounQin self-assigned this May 21, 2025
@JounQin JounQin added dependencies Pull requests that update a dependency file breaking labels May 21, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 21, 2025

🦋 Changeset detected

Latest commit: c64dcf4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@alauda/doom Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented May 21, 2025

Walkthrough

This update migrates the project to use @rspress/core v2 (beta), updates and adds several dependencies, and removes the custom Shiki syntax highlighting integration. Related plugins, types, and CSS for Shiki are deleted, and the configuration is refactored to use a Sass plugin instead. Minor code and type adjustments accompany these changes.

Changes

File(s) Change Summary
.changeset/pre.json Added pre-release changeset configuration specifying release mode, tag, and initial version for @alauda/doom.
.changeset/rotten-cows-cough.md Added major version changeset indicating migration to rspress v2.
package.json Updated multiple dependencies and devDependencies, added @rsbuild/plugin-sass, and upgraded @rspress/core to v2 beta.
patches/unist-util-visit-parents+5.1.3.patch Deleted TypeScript type definitions for recursive tree traversal types.
src/cli/index.ts Removed explicit appDirectory: CWD property from the build function call.
src/cli/load-config.ts Replaced Shiki plugin and configuration with Sass plugin in builder config; removed ssg config and updated markdown config to use built-in Shiki transformers.
src/plugins/auto-toc/remark-auto-toc.ts Appended "rspress-toc-exclude" to the className of the generated TOC div.
src/plugins/replace/index.ts Added TypeScript module augmentation for unified and mdast to extend Data interfaces with custom properties.
src/plugins/replace/utils.ts Fixed type import from YAML to Yaml and updated function return type accordingly.
src/plugins/replace/normalize-img-src.ts Updated type annotation for content parameter from Content to RootContent.
src/plugins/replace/remark-replace.ts Updated type annotations from Content to RootContent in arrays handling Markdown AST nodes.
src/plugins/replace/resolve-reference.ts Updated type annotations from Content to RootContent in interface and local variables.
src/plugins/replace/resolve-release.ts Updated type annotations from Content to RootContent in cached release note content.
src/plugins/replace/rehype-normalize-link.ts Removed fallback default empty object when destructuring alt and src from node.properties.
src/plugins/shiki/highlighter.ts, src/plugins/shiki/rehypePlugin.ts, src/plugins/shiki/index.ts Deleted all custom Shiki highlighter logic, plugin, and related types/exports.
src/runtime/components/JsonViewer.tsx Removed codeHighlighter="prism" prop from YAML and JSON code rendering components.
src/types.ts Removed shiki property from UserConfig interface and related type import.
styles/global.scss Removed import of shiki.css.
styles/shiki.css Deleted custom Shiki syntax highlighting CSS.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ConfigLoader
    participant Builder

    User->>CLI: Run build command
    CLI->>ConfigLoader: Load config (no explicit Shiki plugin)
    ConfigLoader->>Builder: Pass config with pluginSass, built-in Shiki transformers
    Builder-->>CLI: Build process completes
    CLI-->>User: Output build result
Loading

Assessment against linked issues

Objective Addressed Explanation
Migrate to rspress v2 (beta) (#27)
Remove custom Shiki integration in favor of built-in
Update dependencies to support rspress v2
Refactor config/plugins as required by rspress v2

Poem

A hop, a skip, a version two,
The code has changed—so much to do!
Shiki’s gone, Sass hops in place,
Dependencies now keep up the pace.
With rspress beta, we leap ahead,
The rabbit’s code is freshly fed!
🐇✨

✨ 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the project to rspress v2, removing shiki integrations and updating dependencies to align with the new version. Key changes include:

  • Removal of shiki-related CSS, types, and plugin files.
  • Updates to markdown configuration and build tooling (including the addition of sass support).
  • Bump and adjustment of several dependency versions.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
styles/shiki.css Removed custom shiki theme styles.
styles/global.scss Removed import of the shiki.css file.
src/types.ts Eliminated obsolete shiki types from module declarations.
src/runtime/components/JsonViewer.tsx Removed the codeHighlighter prop from code components.
src/plugins/shiki/rehypePlugin.ts Removed the rehype plugin for shiki.
src/plugins/shiki/index.ts Removed shiki plugin implementation and related exports.
src/plugins/shiki/highlighter.ts Removed highlighter creation logic.
src/plugins/replace/utils.ts Updated mdast type import from YAML to Yaml.
src/plugins/replace/index.ts Added module declarations for unified and mdast.
src/plugins/auto-toc/remark-auto-toc.ts Updated class attribute to exclude toc in auto-generated content.
src/cli/load-config.ts Removed shikiPlugin configuration and added pluginSass to builders.
src/cli/index.ts Removed the appDirectory parameter from the build configuration.
patches/unist-util-visit-parents+5.1.3.patch Removed obsolete patch for unist-util-visit-parents.
package.json Updated multiple dependency versions reflecting migration changes.
.changeset/pre.json Added new changeset file for pre-release version management.
Comments suppressed due to low confidence (3)

src/plugins/shiki/rehypePlugin.ts:1

  • The complete removal of the shiki rehype plugin indicates a breaking change; please verify that no other modules depend on this integration.
import { logger } from '@rspress/shared/logger'

src/cli/load-config.ts:225

  • The removal of the shikiPlugin configuration alters markdown highlighting behavior; update the migration guide and documentation to reflect these changes.
shikiPlugin({ ... })

src/cli/index.ts:222

  • The removal of the appDirectory parameter from the build configuration is a breaking change; ensure that related documentation is updated accordingly.
appDirectory: CWD,

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 21, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@alauda/doom@28

commit: c64dcf4

@JounQin JounQin force-pushed the feat/rspress_v2 branch from 4331850 to 346e8e4 Compare May 21, 2025 09:17
Signed-off-by: JounQin <admin@1stg.me>
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🛑 Comments failed to post (1)
src/cli/load-config.ts (1)

5-5: 💡 Verification agent

🧩 Analysis chain

Make sure the new dependency is properly installed.

The added import for pluginSass matches the new dependency in package.json, but static analysis indicates it can't resolve the module path. Verify the installation is complete and correctly configured.


🏁 Script executed:

#!/bin/bash
# Check if @rsbuild/plugin-sass is properly installed and can be resolved

# Look for the package in node_modules
if [ -d "node_modules/@rsbuild/plugin-sass" ]; then
  echo "✅ @rsbuild/plugin-sass is installed in node_modules"
else
  echo "❌ @rsbuild/plugin-sass is not found in node_modules"
fi

# Check if it can be resolved through Node.js
node -e "try { require.resolve('@rsbuild/plugin-sass'); console.log('✅ Module can be resolved'); } catch(e) { console.log('❌ Module cannot be resolved:', e.message); }"

Length of output: 462


Install @rsbuild/plugin-sass and verify resolution

The import in src/cli/load-config.ts (line 5) is failing because the package isn’t installed. To fix:

  • Add @rsbuild/plugin-sass to your dependencies in package.json, for example:

     "dependencies": {
    +  "@rsbuild/plugin-sass": "^<latest-version>",
        …  
     }
  • Run your package manager (e.g. npm install or yarn add @rsbuild/plugin-sass).

  • Confirm node_modules/@rsbuild/plugin-sass now exists.

  • Re-run node -e "require.resolve('@rsbuild/plugin-sass')" to ensure the module can be resolved.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

// package.json
{
  "dependencies": {
    "@rsbuild/plugin-sass": "^<latest-version>",
    …
  }
}
🧰 Tools
🪛 ESLint

[error] 5-5: Unable to resolve path to module '@rsbuild/plugin-sass'.

(import-x/no-unresolved)

🤖 Prompt for AI Agents
In src/cli/load-config.ts at line 5, the import of pluginSass from
'@rsbuild/plugin-sass' fails because the package is not installed. To fix this,
add '@rsbuild/plugin-sass' to your package.json dependencies and run your
package manager (npm or yarn) to install it. After installation, verify that
node_modules/@rsbuild/plugin-sass exists and that Node.js can resolve the module
by running require.resolve('@rsbuild/plugin-sass').

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

📜 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 4331850 and c64dcf4.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (21)
  • .changeset/pre.json (1 hunks)
  • .changeset/rotten-cows-cough.md (1 hunks)
  • package.json (3 hunks)
  • patches/unist-util-visit-parents+5.1.3.patch (0 hunks)
  • src/cli/index.ts (0 hunks)
  • src/cli/load-config.ts (3 hunks)
  • src/plugins/auto-toc/remark-auto-toc.ts (1 hunks)
  • src/plugins/replace/index.ts (1 hunks)
  • src/plugins/replace/normalize-img-src.ts (2 hunks)
  • src/plugins/replace/rehype-normalize-link.ts (1 hunks)
  • src/plugins/replace/remark-replace.ts (3 hunks)
  • src/plugins/replace/resolve-reference.ts (3 hunks)
  • src/plugins/replace/resolve-release.ts (2 hunks)
  • src/plugins/replace/utils.ts (2 hunks)
  • src/plugins/shiki/highlighter.ts (0 hunks)
  • src/plugins/shiki/index.ts (0 hunks)
  • src/plugins/shiki/rehypePlugin.ts (0 hunks)
  • src/runtime/components/JsonViewer.tsx (1 hunks)
  • src/types.ts (0 hunks)
  • styles/global.scss (0 hunks)
  • styles/shiki.css (0 hunks)
💤 Files with no reviewable changes (8)
  • src/cli/index.ts
  • styles/global.scss
  • src/types.ts
  • src/plugins/shiki/rehypePlugin.ts
  • src/plugins/shiki/highlighter.ts
  • styles/shiki.css
  • src/plugins/shiki/index.ts
  • patches/unist-util-visit-parents+5.1.3.patch
✅ Files skipped from review due to trivial changes (5)
  • .changeset/rotten-cows-cough.md
  • src/plugins/replace/normalize-img-src.ts
  • src/plugins/replace/resolve-reference.ts
  • src/plugins/replace/resolve-release.ts
  • src/plugins/replace/remark-replace.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • .changeset/pre.json
  • src/runtime/components/JsonViewer.tsx
  • src/plugins/replace/utils.ts
  • src/plugins/auto-toc/remark-auto-toc.ts
  • src/plugins/replace/index.ts
  • package.json
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/cli/load-config.ts (1)
src/plugins/shiki/transformers/callouts.ts (1)
  • createTransformerCallouts (9-24)
🪛 ESLint
src/cli/load-config.ts

[error] 5-5: Unable to resolve path to module '@rsbuild/plugin-sass'.

(import-x/no-unresolved)

🔇 Additional comments (3)
src/cli/load-config.ts (2)

229-244: Well-structured Shiki configuration for rspress v2

This configuration properly implements the Shiki syntax highlighting system for rspress v2, replacing the previous custom implementation. The combination of built-in transformers and the custom callouts transformer provides comprehensive syntax highlighting capabilities.

The configuration includes essential transformers for code highlighting features like:

  • Word and line highlighting
  • Diff notation
  • Error level indication
  • Focus highlighting
  • And the custom callouts implementation

This aligns well with the migration to rspress v2 mentioned in the PR objectives.


282-282: Plugin configuration updated for rspress v2

The builder configuration has been updated to use pluginSass() instead of the previous shikiPlugin, aligning with the PR's objective to migrate to rspress v2 and remove the custom Shiki integration.

This change complements the removal of Shiki CSS styles mentioned in the AI summary and follows the architectural recommendations for rspress v2.

src/plugins/replace/rehype-normalize-link.ts (1)

51-51:

Details

❓ Verification inconclusive

Potential runtime error from removal of fallback object assignment

The code now directly destructures alt and src from node.properties without a fallback empty object. This change could potentially lead to TypeErrors if node.properties is ever undefined or null.

Consider verifying if node.properties is guaranteed to be defined in all cases, or restore the fallback for safer operation:

-      const { alt, src } = node.properties
+      const { alt, src } = node.properties || {}

🏁 Script executed:

#!/bin/bash
# Check if there are any similar destructuring patterns in the codebase and how they're handled

# First look for other occurrences of destructuring from node.properties
echo "Checking for other node.properties destructuring patterns:"
rg "const .* = node\.properties" -A 1 -B 1

# Check the unist/hast documentation in node_modules
echo "Checking if node.properties is documented as potentially undefined:"
fd -t f "README.md" node_modules/hast

Length of output: 639


To verify whether node.properties can ever be undefined in this plugin, let’s inspect the full contents of the file and see how node is typed and used throughout:


🏁 Script executed:

#!/bin/bash
# Locate and print the plugin file for review
set -eux
file=$(fd -t f "rehype-normalize-link.ts" src)
echo "=== $file ==="
cat "$file"

Length of output: 2179


Let’s verify the HAST Element type to see if properties is always defined:


🏁 Script executed:

#!/bin/bash
set -eux
# Find and inspect the HAST type definitions for Element
file=$(fd -t f "index.d.ts" node_modules/hast | head -n1)
echo "=== $file ==="
grep -R "interface Element" -n "$file"
grep -R "properties" -n "$file" | sed -n '1,20p'

Length of output: 272


I wasn’t able to locate the HAST Element type definitions to confirm whether properties is always present. Could you please check your project’s HAST interfaces (e.g. in node_modules/hast/index.d.ts or @types/hast) and verify if the properties field on Element is defined as optional? If it is, restoring the fallback is safest:

-      const { alt, src } = node.properties
+      const { alt, src } = node.properties || {}

@JounQin JounQin merged commit 0a8ec2a into main May 21, 2025
16 checks passed
@JounQin JounQin deleted the feat/rspress_v2 branch May 21, 2025 09:25
github-actions bot pushed a commit that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: migrate to rspress v2 (beta)

2 participants