web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.21k stars 107 forks source link

[Bug]: Can't resolve 'stream' in react-dom #1004

Closed topazur closed 2 months ago

topazur commented 2 months ago

Version

mac 14
chrome 123.0.6312.124
pnpm 7

Details

error Compile error: Failed to compile, check the errors for troubleshooting. File: ./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js × Resolve error: Can't resolve 'stream' in '/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs' ╭─[11:1] 11 │ 'use strict'; 12 │ var React = require('react'); 13 │ var stream = require('stream'); · ───────────────── 14 │ var ReactVersion = '18.2.0'; 15 │ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; ╰────

Tip: "stream" is a built-in Node.js module and cannot be imported in client-side code. Check if you need to import Node.js module. If needed, you can use "@rsbuild/plugin-node-polyfill".

Reproduce link

Reproduce Steps

topazur commented 2 months ago

使用 previewMode="iframe" 配置也同样报错,只要引入并使用了该组件就报错