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

umi4 联邦模块 exposes出去的组件访问不到umi history对象 #12884

Open
StrongerD opened this issue Jan 6, 2025 · 1 comment
Open

Comments

@StrongerD
Copy link

What happens?

通过联邦模块eposes出去的组件访问不到umi history对象

子应用umi配置

mf: {
  name: 'homeRemote',
  remoteHash: false,
  library: { type: 'window', name: 'homeRemote' },
  shared: {
    react: { singleton: true, eager: true, requiredVersion: '18.3.1' },
    'react-dom': { singleton: true, eager: true, requiredVersion: '18.3.1' },
  }
}

主应用联邦配置

mf: {
  remotes: [
    {
      name: 'homeRemote',
      entry: `http://localhost:8100/remote.js`,
    },
  ],
},

主应用消费配置

import { safeMfImport } from 'umi';

const HomePage = React.lazy(() => {
  return safeMfImport('homeRemote/HomePage', { default: 'loading' });
});

export default withCoreContext((props: any) => {
  return (
    <React.Suspense fallback={<HomeSkeleton />}>
      <HomePage
          globalState={{
            token: props.cookie,
            profile: props.profile,
          }}
      />
    </React.Suspense>
  );
});

子应用exposes代码
image

image

How To Reproduce

Steps to reproduce the behavior: 1. 2.

Expected behavior 1. 2.

Context

  • Umi Version: 4.2.5
  • Node Version: 16.14.0
  • Platform: macOS
@1119879311
Copy link

1119879311 commented Jan 17, 2025

这个umi 太垃圾了,提个问题都给关闭了, 分包怎么都禁用不了,看下这个配置有啥问题吗,官方文档都是流水一文带过,禁用分包都有bug,在 umi3x 的版本有效,升级umi4x 就失效了,按照文档也无效

import { defineConfig } from "umi";

export default defineConfig({
  alias: {
    "@": "./src",
  },
  extraBabelPlugins: [],
  codeSplitting: false,
  legacy: {
    nodeModulesTransform: false,
  },
  copy: [{ from: "./src/assets", to: "./dist/static" }],
  chainWebpack(config, { webpack }) {

    config.plugin('extract-css').use(require('mini-css-extract-plugin'), [
      {
        filename: `main.css`,
        chunkFilename: `[name].chunk.css`,
      },
    ]);
    config.output.filename('app.js')
  },

});

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