modern.js icon indicating copy to clipboard operation
modern.js copied to clipboard

[Bug]: 开启 `Rspress Module Doc` 功能,代码块设置 iframe,报 Can't resolve 'react/jsx-dev-runtime'

Open BeaconSage opened this issue 1 year ago • 0 comments

版本信息

System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (8) x64 AMD Ryzen 7 5825U with Radeon Graphics
    Memory: 8.12 GB / 15.62 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  npmPackages:
    @modern-js/eslint-config: 2.58.0 => 2.58.0 
    @modern-js/module-tools: 2.58.0 => 2.58.0 
    @modern-js/plugin-rspress: 1.27.1 => 1.27.1 
    @modern-js/plugin-tailwindcss: 2.58.0 => 2.58.0

问题详情

初始化项目, 开启 Rspress Module Doc 功能,在 doc/index.mdx 中 输入代码块,并设置类型为 iframepnpm dev 后报 Can't resolve 'react/jsx-dev-runtime' 截屏2024-08-10 00 33 29

demo: test.tar.gz

复现链接

附件 test.tar.gz

复现步骤

  1. pnpm dev
  2. 控制台报错
File: /home/beacon/Documents/test/node_modules/.rspress/virtual-demo/_index_1.entry.tsx:1:1
  × Module not found: Can't resolve 'react/jsx-dev-runtime' in '/home/beacon/Documents/test/node_modules/.rspress/virtual-demo'
   ╭─[1:34]
 1 │ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
   ·                                   ───────────────────────
 2 │ import { render } from 'react-dom';
 3 │ import "/home/beacon/Documents/test/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]__react-_yafijyfmxaorishhjxftxnjjba/node_modules/@rspress/plugin-preview/static/global-styles/entry.css";
   ╰────

BeaconSage avatar Aug 09 '24 16:08 BeaconSage