Coder Social home page Coder Social logo

Comments (5)

ThomasLiu avatar ThomasLiu commented on July 26, 2024

重新试了一下,这次是把 plugins 内的 plugin-qiankun/examples 直接copy 出来,然后单独的 yarn,再yarn start,4个项目都跑起来,但是在chrome 上访问 8000 时,也是一样的问题。

奇怪的是,在 plugin 项目内,yarn 完,然后 build 了,再到 plugin-qiankun/examples 内 yarn start,examples 是跑得很正常的。

可重现最小仓库

在examples内的唯一改动是 .umirc.js 内的 plugins 都换成 ['@umijs/plugin-dva', '@umijs/plugin-antd', '@umijs/plugin-qiankun']

export default {
  publicPath: '/app3/',
  outputPath: './dist/app3',
  mountElementId: 'app3',
  qiankun: {
    slave: {},
  },
  plugins: ['@umijs/plugin-dva', '@umijs/plugin-antd', '@umijs/plugin-qiankun'],
  // TODO 测试约定式路由
  routes: [
    { path: '/', exact: true, component: './index.js' },
    { path: '/:abc', component: './$abc.js' },
    { path: '/users', component: './user/index.js' },
  ],
  // TODO 测试 dynamicImport
  // dynamicImport: true,
};

plugin-qiankun 是使用 yarn add @umijs/plugin-qiankun@next --dev 来安装的。package.json 内为 "@umijs/plugin-qiankun": "^2.2.0-0"

from plugins.

ThomasLiu avatar ThomasLiu commented on July 26, 2024

下载了 umi 的源码 最终找到了 applyPlugins 的源码,在umi的项目packages/runtime/src/Plugin 的test中,对于参数为 async: true 得测试也是需要await 来调用。

然后把这里 改成

async function getMasterRuntime() {
  const config = await  plugin.applyPlugins({
    key: 'qiankun',
    type: ApplyPluginsType.modify,
    initialValue: {},
    async: true,
  });
  const { master } = config;
  return master || config;
}

重新build 了一次,把生成的lib 复制到 项目的 node_modules 对应的文件夹后,就OK了( ̄▽ ̄)

from plugins.

ThomasLiu avatar ThomasLiu commented on July 26, 2024

下载了 umi 的源码 最终找到了 applyPlugins 的源码,在umi的项目packages/runtime/src/Plugin 的test中,对于参数为 async: true 得测试也是需要await 来调用。

然后把这里 改成

async function getMasterRuntime() {
  const config = await  plugin.applyPlugins({
    key: 'qiankun',
    type: ApplyPluginsType.modify,
    initialValue: {},
    async: true,
  });
  const { master } = config;
  return master || config;
}

重新build 了一次,把生成的lib 复制到 项目的 node_modules 对应的文件夹后,就OK了( ̄▽ ̄)

from plugins.

7kms avatar 7kms commented on July 26, 2024

同样遇到这个问题.
请问这个版本的源码 "@umijs/plugin-qiankun": "^2.2.0-0"怎么看. 没有相应的tag. master分支的代码也对不上.
有条件的话提个pr修复了吧.

from plugins.

kuitos avatar kuitos commented on July 26, 2024

使用 ^2.3.0-6 或者重新 npm i @umijs/plugin-qiankun@next

from plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.