umijs / plugins

🍣 The one-stop shop for official Umi plugins and presets.
351 stars 237 forks source link

ant-design-pro v6 使用 qiankun 在开发环境能正常使用,build 后 主应用 加载 子应用会报 initFocus is not a function 错误 #938

Open yanthink opened 1 year ago

yanthink commented 1 year ago

image

主应用和子应用都使用 ant-design-pro 6.0.0 开发, dev 环境能正常使用,build 后 主应用 加载 子应用会报 initFocus is not a function 错误

主应用配置

config/config.ts

qiankun: {
   master: {},
},

src/app.tsx

export const qiankun = {
  apps: [
    {
      name: 'app1',
      entry: '//localhost:8888',
    },
  ],
  routes: [
    {
      path: '/app1/*',
      name: 'app1',
      microApp: 'app1',
      microAppProps: {
        autoCaptureError: true,
      },
    },
  ],
};

子应用配置

config/config.ts

qiankun: {
    slave: {
      shouldNotModifyDefaultBase: true,
    },
 },

src/app.tsx

export const qiankun = {
  bootstrap() {
    console.log('react app bootstraped');
  },
  mount(props) {
    console.log(props);
  },
  unmount(props) {
    console.log(props);
  },
  update(props) {
    console.log(props);
  },
};

OS: MacOS 13.0 (22A380)

Node:v19.7.0

浏览器 | browser:Chrome 113.0.5672.92

yanthink commented 1 year ago

umi 配置加上 esbuildMinifyIIFE: true 就好了,建议官方在 umijs 微前端文档FAQ里加上,不然对新手太不友好了。