Skip to content

fix(packages/ui): bundle rspress plugins to fix Node.js 24 ESM resolution#54

Merged
zrosenbauer merged 2 commits intomainfrom
fix/bundle-rspress-plugins
Mar 21, 2026
Merged

fix(packages/ui): bundle rspress plugins to fix Node.js 24 ESM resolution#54
zrosenbauer merged 2 commits intomainfrom
fix/bundle-rspress-plugins

Conversation

@zrosenbauer
Copy link
Member

@zrosenbauer zrosenbauer commented Mar 21, 2026

Summary

  • Rspress plugins (devkit, file-tree, katex, supersub) ship extensionless relative imports in their ESM dist files, causing ERR_MODULE_NOT_FOUND on Node.js 24 which enforces strict ESM resolution
  • Moves these 4 plugins from dependencies to devDependencies in @zpress/ui so Rslib bundles them inline instead of externalizing them — the bundler resolves imports internally, bypassing the extension issue entirely
  • Removes the 4 pnpm patches that manually added .js extensions (no longer needed)

Test plan

  • pnpm build passes — all 9 packages build successfully
  • Verified dist/index.mjs contains no import ... from "rspress-plugin-*" statements (plugins are inlined)
  • zpress dev runs without ERR_MODULE_NOT_FOUND on Node.js 24

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Node.js 24 import errors by bundling several RSPress plugins into the UI package so they load correctly.
  • Chores

    • Updated packaging and build configuration for the UI output and reclassified plugin packages to development-only dependencies to ensure consistent ESM behavior.

…tion

Move rspress-plugin-{devkit,file-tree,katex,supersub} from dependencies to
devDependencies so Rslib bundles them into the UI output instead of
externalizing them. This eliminates ERR_MODULE_NOT_FOUND errors caused by
extensionless relative imports in the plugins' dist files, which Node.js 24
rejects under strict ESM resolution.

Remove the now-unnecessary pnpm patches that manually added .js extensions.

Co-Authored-By: Claude <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 21, 2026

🦋 Changeset detected

Latest commit: 88b86bc

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

This PR includes changesets to release 3 packages
Name Type
@zpress/ui Patch
@zpress/cli Patch
@zpress/kit Patch

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

@vercel
Copy link

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
oss-zpress Ignored Ignored Preview Mar 21, 2026 6:28am

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f1de2571-ce18-44da-8fc8-d63b1763e355

📥 Commits

Reviewing files that changed from the base of the PR and between 4e0d929 and 88b86bc.

📒 Files selected for processing (1)
  • packages/ui/rslib.config.ts

📝 Walkthrough

Walkthrough

A changeset marks a patch release for @zpress/ui that bundles four rspress plugins into the UI build and removes pnpm patch entries; plugin patches that adjusted compiled dist/ ESM imports and runtime shims were deleted and the plugins were moved to devDependencies.

Changes

Cohort / File(s) Summary
Changeset Metadata
.changeset/bundle-rspress-plugins.md
Added a changeset documenting a patch release for bundling rspess plugins into @zpress/ui.
Root manifest
package.json
Removed pnpm.patchedDependencies entries and corresponding patch file references for the four rspress plugins.
UI package manifest
packages/ui/package.json
Moved rspress-plugin-devkit, rspress-plugin-file-tree, rspress-plugin-katex, rspress-plugin-supersub from dependencies to devDependencies.
Deleted patch files
patches/rspress-plugin-devkit@1.0.0.patch, patches/rspress-plugin-file-tree@1.0.4.patch, patches/rspress-plugin-katex@1.0.0.patch, patches/rspress-plugin-supersub@1.0.0.patch
Removed patches that modified compiled dist/ files to add explicit .js extensions, ESM fileURL-to-path shims, and createRequire based CSS resolution workarounds.
UI bundler config
packages/ui/rslib.config.ts
Added shims for the esm build enabling __dirname, __filename, and require in the bundled ESM output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 Patches shelved, the bundle grows,
Plugins tucked where the output goes.
No missing imports, smooth runway,
I hop and hum — build saved the day! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: bundling rspress plugins to fix Node.js 24 ESM resolution issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bundle-rspress-plugins

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

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.

🧹 Nitpick comments (1)
packages/ui/package.json (1)

80-83: Consider adding a CI guard to prevent regressions.

A lightweight post-build check (e.g., fail if dist/index.mjs still contains from "rspress-plugin-") would catch future externalization drift early.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ui/package.json` around lines 80 - 83, Add a post-build CI guard
that scans the built bundle (dist/index.mjs) for any remaining external import
patterns like from "rspress-plugin-" and fails the job if found; implement this
as a lightweight script (e.g., npm script or CI step) that greps/dist file for
the string "from \"rspress-plugin-\"" and exits non-zero when matched, wire it
into existing build/test pipeline so the build step that produces dist/index.mjs
is followed by this check to prevent externalization drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/ui/package.json`:
- Around line 80-83: Add a post-build CI guard that scans the built bundle
(dist/index.mjs) for any remaining external import patterns like from
"rspress-plugin-" and fails the job if found; implement this as a lightweight
script (e.g., npm script or CI step) that greps/dist file for the string "from
\"rspress-plugin-\"" and exits non-zero when matched, wire it into existing
build/test pipeline so the build step that produces dist/index.mjs is followed
by this check to prevent externalization drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b3274dee-cd60-495e-9342-18a6a939cae4

📥 Commits

Reviewing files that changed from the base of the PR and between 44ab8aa and 4e0d929.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/bundle-rspress-plugins.md
  • package.json
  • packages/ui/package.json
  • patches/rspress-plugin-devkit@1.0.0.patch
  • patches/rspress-plugin-file-tree@1.0.4.patch
  • patches/rspress-plugin-katex@1.0.0.patch
  • patches/rspress-plugin-supersub@1.0.0.patch
💤 Files with no reviewable changes (5)

Add shims.esm config to inject __dirname, __filename, and require
polyfills into the ESM output. The bundled rspress plugins use
require.resolve() and __dirname which don't exist natively in ESM.

Co-Authored-By: Claude <noreply@anthropic.com>
@zrosenbauer zrosenbauer merged commit 03f1229 into main Mar 21, 2026
5 checks passed
@zrosenbauer zrosenbauer deleted the fix/bundle-rspress-plugins branch March 21, 2026 06:32
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