Skip to content

chore: migrate Rslib to Rstack CLI#8170

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/migrate-rslib-to-rstack-cli
Jul 23, 2026
Merged

chore: migrate Rslib to Rstack CLI#8170
chenjiahan merged 1 commit into
mainfrom
chenjiahan/migrate-rslib-to-rstack-cli

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

This PR migrates package library builds from standalone Rslib configs and commands to Rstack CLI.
It consolidates library and test definitions in each package's rstack.config.ts, adds concise shared config exports, and removes direct Rslib and Rstest adapter dependencies.
Generated library artifacts remain byte-for-byte unchanged.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The repository migrates package build commands from rslib to rs lib and test commands to rs test. RSLib dependencies and configurations are removed or replaced with Rsbuild and RStack equivalents. Shared library and test configurations gain explicit package exports, minification settings, and base test behavior. Core and plugin RStack configurations now load shared settings dynamically, while preserving specialized build targets, externals, output naming, and runtime asset transformations.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: migrating package builds from Rslib to the Rstack CLI.
Description check ✅ Passed The description matches the changeset by describing the migration to Rstack CLI and removal of direct Rslib and Rstest dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
packages/core/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

packages/create-rsbuild/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

packages/plugin-babel/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

  • 10 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chenjiahan
chenjiahan merged commit 8860f72 into main Jul 23, 2026
7 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/migrate-rslib-to-rstack-cli branch July 23, 2026 03:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
packages/core/rstack.config.ts (1)

42-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Hoist the jiti check out of the regexpMap loop.

The /jiti/.test(request) branch (lines 51-54) doesn't use name/test from the loop, so it's redundantly re-evaluated on every iteration instead of once. It also reads as if tied to the current entry, which can mislead future edits.

♻️ Suggested refactor
   ({ request }, callback) => {
     const entries = Object.entries(regexpMap);
-    if (request) {
+    if (request) {
+      if (/jiti/.test(request)) {
+        callback(undefined, '../compiled/jiti/lib/jiti.mjs');
+        return;
+      }
       for (const [name, test] of entries) {
         if (request === name) {
           throw new Error(
             `"${name}" is not allowed to be imported, use "requireCompiledPackage" instead.`,
           );
         }
-        if (/jiti/.test(request)) {
-          callback(undefined, '../compiled/jiti/lib/jiti.mjs');
-          return;
-        }
         if (test.test(request)) {
           callback(undefined, `../compiled/${name}/index.js`);
           return;
         }
       }
     }
     callback();
   },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/rstack.config.ts` around lines 42 - 63, Move the
`/jiti/.test(request)` handling out of the `for (const [name, test] of entries)`
loop in the request resolver, placing it once before iterating `regexpMap`.
Preserve its callback target and early return, while leaving the `name`/`test`
matching and disallowed-import logic inside the loop.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/rstack.config.ts`:
- Around line 86-94: Update the explanatory comment above the placeholder
replacement plugin to replace stale “Rslib” and “rslib” references with the
current Rstack/Rsbuild-based rs lib tooling, while preserving the existing
explanation of the __webpack_require__.* workaround and post-bundle replacement
behavior.

---

Nitpick comments:
In `@packages/core/rstack.config.ts`:
- Around line 42-63: Move the `/jiti/.test(request)` handling out of the `for
(const [name, test] of entries)` loop in the request resolver, placing it once
before iterating `regexpMap`. Preserve its callback target and early return,
while leaving the `name`/`test` matching and disallowed-import logic inside the
loop.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 04701940-4d89-44c2-99da-0440d48ff53a

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd98a1 and 79a894c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (39)
  • package.json
  • packages/core/package.json
  • packages/core/rslib.config.ts
  • packages/core/rstack.config.ts
  • packages/create-rsbuild/package.json
  • packages/plugin-babel/package.json
  • packages/plugin-babel/rslib.config.ts
  • packages/plugin-babel/rstack.config.ts
  • packages/plugin-less/package.json
  • packages/plugin-less/rslib.config.ts
  • packages/plugin-less/rstack.config.ts
  • packages/plugin-preact/package.json
  • packages/plugin-preact/rslib.config.ts
  • packages/plugin-preact/rstack.config.ts
  • packages/plugin-react/package.json
  • packages/plugin-react/rslib.config.ts
  • packages/plugin-react/rstack.config.ts
  • packages/plugin-sass/package.json
  • packages/plugin-sass/rslib.config.ts
  • packages/plugin-sass/rstack.config.ts
  • packages/plugin-solid/package.json
  • packages/plugin-solid/rslib.config.ts
  • packages/plugin-solid/rstack.config.ts
  • packages/plugin-svelte/package.json
  • packages/plugin-svelte/rslib.config.ts
  • packages/plugin-svelte/rstack.config.ts
  • packages/plugin-svgr/package.json
  • packages/plugin-svgr/rslib.config.ts
  • packages/plugin-svgr/rstack.config.ts
  • packages/plugin-tailwindcss/package.json
  • packages/plugin-tailwindcss/rslib.config.ts
  • packages/plugin-tailwindcss/rstack.config.ts
  • packages/plugin-vue/package.json
  • packages/plugin-vue/rslib.config.ts
  • packages/plugin-vue/rstack.config.ts
  • pnpm-workspace.yaml
  • scripts/config/lib.ts
  • scripts/config/package.json
  • scripts/config/test.ts
💤 Files with no reviewable changes (13)
  • packages/plugin-preact/rslib.config.ts
  • packages/plugin-less/rslib.config.ts
  • packages/plugin-svelte/rslib.config.ts
  • packages/plugin-vue/rslib.config.ts
  • packages/plugin-solid/rslib.config.ts
  • packages/plugin-babel/rslib.config.ts
  • packages/plugin-sass/rslib.config.ts
  • packages/plugin-react/rslib.config.ts
  • packages/plugin-svgr/rslib.config.ts
  • package.json
  • packages/plugin-tailwindcss/rslib.config.ts
  • packages/core/rslib.config.ts
  • pnpm-workspace.yaml

Comment on lines +86 to +94
// Rslib currently doesn't provide a way to preserve `__webpack_require__.*`
// references in the emitted bundle.
//
// To work around this, we use "magic" placeholder identifiers during authoring
// (e.g. `RSPACK_INTERCEPT_MODULE_EXECUTION`) so rslib
// won't try to resolve/transform `__webpack_require__.*` at build time.
//
// After bundling, this plugin performs a plain string replacement to swap
// those placeholders back to the actual Rspack runtime globals.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Stale "Rslib" reference in comment after migration.

This comment still says "Rslib currently doesn't provide..." and "won't try to resolve/transform __webpack_require__.*...rslib" even though the file has migrated off Rslib to the Rstack/Rsbuild-based rs lib pipeline. Update the wording to reflect the current tooling to avoid confusing future maintainers about which tool this workaround targets.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/rstack.config.ts` around lines 86 - 94, Update the explanatory
comment above the placeholder replacement plugin to replace stale “Rslib” and
“rslib” references with the current Rstack/Rsbuild-based rs lib tooling, while
preserving the existing explanation of the __webpack_require__.* workaround and
post-bundle replacement behavior.

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.

1 participant