Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes the default render mode for @rspress/plugin-playground to pure, aligns documentation for both plugin-playground and plugin-preview around this behavior, and adds an E2E fixture to validate combined usage of the two plugins.
Changes:
- Set
plugin-playground’sdefaultRenderModedefault to'pure'and remove its automatic removal of@rspress/plugin-preview, enabling them to co-exist. - Update Chinese and English documentation for
plugin-playgroundandplugin-previewto document the newdefaultRenderMode = 'pure'default and warn about changing it when using both plugins together. - Add a new E2E fixture and Playwright test (
plugin-playground-preview) that runsplugin-previewandplugin-playgroundtogether, verifying that plain,playground, andpreviewcode blocks all render correctly under the new defaults.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
website/rspress.config.ts |
Registers pluginPlayground() alongside pluginPreview() for the docs site, exercising the new “both plugins, default pure mode” behavior in real usage. |
website/package.json |
Adds @rspress/plugin-playground as a workspace dependency for the website docs so the new plugin usage in rspress.config.ts is valid. |
website/docs/zh/plugin/official-plugins/preview.mdx |
Documents that defaultRenderMode for plugin-preview is 'pure' and adds a warning that changing it can affect combined use with @rspress/plugin-playground. |
website/docs/zh/plugin/official-plugins/playground.mdx |
Reworks usage docs (step-wise sections, internal/external demos, direction layout), introduces defaultRenderMode (default 'pure') and warns against changing it when used with plugin-preview. |
website/docs/zh/plugin/official-plugins/_playgroundDemo.jsx |
Adds a simple external JSX demo component for the Chinese playground docs’ “external file” example. |
website/docs/en/plugin/official-plugins/preview.mdx |
Mirrors the Chinese preview docs updates in English, including the 'pure' default and warning about combined usage with @rspress/plugin-playground. |
website/docs/en/plugin/official-plugins/playground.mdx |
Mirrors the Chinese playground docs updates in English, including clearer usage examples, external file demos, and defaultRenderMode = 'pure' documentation. |
website/docs/en/plugin/official-plugins/_playgroundDemo.jsx |
Adds the English version of the external JSX demo component for the playground docs. |
pnpm-lock.yaml |
Adds a new importer block for the e2e/fixtures/plugin-playground-preview project, wiring its dependencies (@rspress/core, @rspress/plugin-playground, @rspress/plugin-preview, React 19, etc.) into the lockfile. |
packages/plugin-playground/src/cli/index.ts |
Updates PlaygroundOptions’s defaultRenderMode JSDoc to @default 'pure', changes the destructuring default from 'playground' to 'pure', and simplifies the config hook by removing the removePlugin('@rspress/plugin-preview') call so both plugins can run together. |
e2e/fixtures/plugin-playground/rspress.config.ts |
Explicitly sets defaultRenderMode: 'playground' for the existing playground E2E fixture, preserving its previous behavior and expectations after the global default changes to 'pure'. |
e2e/fixtures/plugin-playground-preview/tsconfig.json |
Minimal TS config enabling esModuleInterop and jsx: "react-jsx" for the new combined fixture project. |
e2e/fixtures/plugin-playground-preview/rspress.config.ts |
Defines a new fixture site that enables both pluginPreview() and pluginPlayground() together on the same docs root. |
e2e/fixtures/plugin-playground-preview/package.json |
Declares the combined fixture package, including workspace dependencies on @rspress/core, @rspress/plugin-playground, @rspress/plugin-preview, and React 19. |
e2e/fixtures/plugin-playground-preview/index.test.ts |
New Playwright E2E test that starts the combined fixture, verifies a pure code block stays a normal code block, and ensures exactly one .rspress-playground and one .rspress-preview render with the expected text. |
e2e/fixtures/plugin-playground-preview/doc/index.mdx |
MDX content used by the combined fixture: includes one plain JSX code block, one playground block, and one preview block to exercise and assert the new default 'pure' semantics across both plugins. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
**1. Changed `defaultRenderMode` default value to `'pure'` in plugin-playground** - Modified `packages/plugin-playground/src/cli/index.ts:52` - changed the default value from `'playground'` to `'pure'` - Updated the JSDoc comment `@default` from `'playground'` to `'pure'` - Updated the existing e2e test `e2e/fixtures/plugin-playground/rspress.config.ts` to explicitly set `defaultRenderMode: 'playground'` to maintain test compatibility **2. Created a new e2e case for plugin-playground and plugin-preview combined usage** - Created new fixture directory: `e2e/fixtures/plugin-playground-preview/` - Created files: - `package.json` - dependencies for both plugins - `tsconfig.json` - TypeScript config - `rspress.config.ts` - configures both `pluginPreview()` and `pluginPlayground()` - `doc/index.mdx` - test document with code blocks - `doc/component.jsx` - external component file - `index.test.ts` - test that verifies plugin-playground takes precedence when both plugins are configured (plugin-playground removes plugin-preview via `removePlugin`)
**1. `packages/plugin-playground/src/cli/index.ts`**
- 将 `defaultRenderMode` 默认值从 `'playground'` 改为 `'pure'`
- 更新 JSDoc 注释中的 `@default`
- 移除 `removePlugin('@rspress/plugin-preview')` 调用,允许两个插件同时使用
**2. `e2e/fixtures/plugin-playground/rspress.config.ts`**
- 添加 `defaultRenderMode: 'playground'` 保持原有测试行为
**3. 新建 `e2e/fixtures/plugin-playground-preview/`**
- `package.json` - 同时依赖两个插件
- `tsconfig.json`
- `rspress.config.ts` - 配置两个插件(都使用默认 `pure` 模式)
- `doc/index.mdx` - 测试三种场景:
- 无 meta:渲染为普通代码块
- `playground` meta:使用 plugin-playground
- `preview` meta:使用 plugin-preview
- `index.test.ts` - 验证两个插件可以同时工作
**plugin-preview 文档** (英文/中文): - 添加了 `:::warning` 提示不建议修改默认值,否则影响与 plugin-playground 的连用 **plugin-playground 文档** (英文/中文): - 将 `defaultRenderMode` 默认值从 `'playground'` 更新为 `'pure'` - 统一了文档格式(添加了 Type 和 Default 字段) - 添加了 `:::warning` 提示不建议修改默认值,否则影响与 plugin-preview 的连用
**1. 重写了 plugin-playground 文档(中英文)** 参考 plugin-preview 的文档风格,重新组织了文档结构: - 添加了完整的交互示例(计数器 demo) - 使用 ` ```jsx playground ` 语法展示可编辑的 Playground - 添加了外部文件引用的示例 (`_playgroundDemo.jsx`) - 添加了布局方向(direction)章节,展示 horizontal/vertical 模式 - 重新组织了配置选项,统一了格式(Type/Default) - 保留了 `defaultRenderMode` 的 warning 提示 **2. 在 website 中注册了 plugin-playground** - `website/package.json`: 添加了 `@rspress/plugin-playground` 依赖 - `website/rspress.config.ts`: - 导入 `pluginPlayground` - 在 plugins 数组中注册 `pluginPlayground()` - 创建了外部 demo 文件: - `website/docs/zh/plugin/official-plugins/_playgroundDemo.jsx` - `website/docs/en/plugin/official-plugins/_playgroundDemo.jsx` 现在 plugin-playground 文档页面会包含可交互的 Playground 示例,用户可以直接在文档中编辑代码并看到实时效果。
1. 该插件可与 plugin-preview 一起使用 2. plugin-playground 的代码编译发生在浏览器中 3. 因此用法限制比 plugin-preview 更多(例如不支持从本地文件导入模块) 4. 建议将 plugin-playground 作为 plugin-preview 的补充,用于需要实时编辑代码的场景
511d68e to
295ea2f
Compare
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 3 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 nodePath:
📦 Download Diff Report: node Bundle Diff 📁 node_mdPath:
📦 Download Diff Report: node_md Bundle Diff 📁 webPath:
📦 Download Diff Report: web Bundle Diff Generated by Rsdoctor GitHub Action |
Deploying rspress-v2 with
|
| Latest commit: |
ff4726a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cceba3d3.rspress-v2.pages.dev |
| Branch Preview URL: | https://syt-vibe-kanban-2d92-plugin.rspress-v2.pages.dev |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
change defaultRenderMode to 'pure' and support combined usage with plugin-preview
Related Issue
Checklist
Changes
1. Changed
defaultRenderModedefault value to'pure'in plugin-playgroundpackages/plugin-playground/src/cli/index.ts- changed the default value from'playground'to'pure'@defaultannotation accordingly2. Enabled combined usage of plugin-playground and plugin-preview
removePlugin('@rspress/plugin-preview')from plugin-playgroundpuremode, allowing users to explicitly specifyplaygroundorpreviewvia code block meta3. Added e2e test for combined plugin usage
e2e/fixtures/plugin-playground-preview/playgroundmeta render as Playground componentspreviewmeta render as Preview components4. Rewrote plugin-playground documentation (EN & ZH)
_playgroundDemo.jsx)defaultRenderModeto avoid affecting combined usage5. Registered plugin-playground in website
@rspress/plugin-playgroundto website dependenciespluginPlayground()inrspress.config.tsThis PR was written using Vibe Kanban