Open
Description
复现 demo
https://github.com/festina-lente-z/react-vite-garfish-demo/tree/feat/garfish-exports-undefined
问题
react子应用关闭沙箱,vite启动时,引入 rxjs 报错,但是打开沙箱引入 GarfishEsModule() 插件正常显示。报错如下图所示:
我自己这边进行排查之后,发现 rxjs 和 garfish 的 window 冲突了。
我在源码中加入了 console.log(window)
,代码如下
const blobUrl = this.createBlobUrl(`import.meta.url='${url}';console.log(window);${this.app.isNoEntryScript(url) ? noEntryEnvVarStr : envVarStr}${scriptCode}
${sourcemap}`);
当运行到 rxjs 内部时,打印的 window 与其他依赖不一致:
请问有比较好的解决方案吗?
Reproduction
https://github.com/festina-lente-z/react-vite-garfish-demo/tree/feat/garfish-exports-undefined
Used Package Manager
pnpm
System Info
System:
OS: macOS 14.2.1
CPU: (8) arm64 Apple M2
Memory: 67.70 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
Yarn: 1.22.21 - /opt/homebrew/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm
pnpm: 8.15.3 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 123.0.6312.87
Safari: 17.2.1
npmPackages:
@garfish/bridge-react-v18: ^1.17.5 => 1.17.5
@garfish/es-module: ^1.17.5 => 1.17.5
garfish: ^1.17.5 => 1.17.5
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Garfish issue and not a framework-specific issue.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels