web-infra-dev / garfish

A powerful micro front-end framework 🚚
https://www.garfishjs.org
Other
2.56k stars 207 forks source link

setExternal 配置未生效 #511

Closed yuanlf closed 2 years ago

yuanlf commented 2 years ago

Describe the bug

1)基座项目设置了共享依赖 Garfish.setExternal({ react: React, "react-dom": ReactDOM, "react-router-dom": ReactRouterDom, }); 2)子项目 webpack 中配置了 externals externals: { react: "React", "react-dom": "ReactDOM", "react-router-dom": "ReactRouterDOM", }, 3)加载子项目时,会提示如下错误 [Garfish warning]: Package "ReactDOM" is not found [Garfish warning]: Package "React" is not found

Reproduction

https://www.garfishjs.org/

Used Package Manager

npm

System Info

System:
    OS: macOS 12.4
    CPU: (8) x64 Apple M1 Pro
    Memory: 17.45 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 12.22.12 - /usr/local/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.6.0 - /usr/local/bin/npm
  Browsers:
    Safari: 15.5

Validations

zhoushaw commented 2 years ago

子应用 external 改成:

externals: {
react: "react",
"react-dom": "react-dom",
"react-router-dom": "react-router-dom",
},
yuanlf commented 2 years ago

子应用 external 改成:

externals: {
react: "react",
"react-dom": "react-dom",
"react-router-dom": "react-router-dom",
},

可行,谢谢