Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地开发,链接生产环境的联邦模块时,更新内容触发热更新时,运行报错 #3201

Closed
5 tasks done
dnwu opened this issue Nov 11, 2024 · 5 comments
Closed
5 tasks done

Comments

@dnwu
Copy link

dnwu commented Nov 11, 2024

Describe the bug

img_v3_02gh_88f8a0d5-585a-4453-a9c2-5c33df085b3g
启动会报这样的提示如上
配置如下
img_v3_02gh_c97beeba-c089-4275-a16c-59f79a67345g


热更新报错如下
img_v3_02gh_babeac72-ddc5-478c-8c66-9cc3d755a93g


并且,当我构建生产者的时候,有时候会卡在build,进行不下去,一直开在如下图
image

Reproduction

Used Package Manager

npm

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 PRO 5750G with Radeon Graphics
    Memory: 3.58 GB / 15.34 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.4 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (130.0.2849.56)
    Internet Explorer: 11.0.22621.1

Validations

@2heal1
Copy link
Member

2heal1 commented Nov 11, 2024

提供下复现的 demo

@dnwu
Copy link
Author

dnwu commented Nov 11, 2024

提供下复现的 demo

demo.zip

@dnwu
Copy link
Author

dnwu commented Nov 11, 2024

提供下复现的 demo

demo.zip

provider我是发布到了nginx,开了允许跨域, 访问地址如consumer中配置一样,
本地开启consumer dev (npm run dev)后,出现以上情况

@2heal1
Copy link
Member

2heal1 commented Nov 11, 2024

这是正常的,消费者启动后,会去尝试访问生产者的 dts server,但是你这是 nginx 托管的产物,所以不会有这个 dts server ,因此报错。 这块我后面处理下错误信息,让信息更明白一点。

另外本地启动想加跨域头,不需要这么麻烦,可以设置 server.headers

  server: {
    port:3001,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods':
        'GET, POST, PUT, DELETE, PATCH, OPTIONS',
      'Access-Control-Allow-Headers': '*',
        },
  },

本地生产者 npm run dev , 消费者配置地址为 federation_components@http://localhost:3001/mf-manifest.json 就行。

@2heal1
Copy link
Member

2heal1 commented Nov 11, 2024

至于生产者构建的问题,你可以在生产者的目录执行 npx tsc 查看类型问题,修复后在重试构建。 也可以设置 dts:false 关闭类型生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants