module-federation-examples icon indicating copy to clipboard operation
module-federation-examples copied to clipboard

The module federation file is not loaded

Open ceechen0 opened this issue 1 year ago • 0 comments

Configuration of A

new ModuleFederationPlugin({
          name: 'jxjy',
          filename: 'remote.js',
          exposes: {
            './info': './src/unit-share/network-school/basic-data/info/index.vue'
          },
          remotes: {
            jxjy_remote: 'jxjy_remote@http://192.168.10.56:8080/jxjy_remote.js'
          },
          library: {
            type: 'window',
            name: 'jxjy'
          },
          shared: {
            vue: {
              singleton: true,
              version: '2.6.11'
            },
            '@hbfe-api/biz-information-management': {
              singleton: true
            },
            axios: {
              singleton: true,
              version: '0.19.2'
            }
          }
        })

Configuration of B

new ModuleFederationPlugin({
  name: 'jxjy_remote',
  filename: 'jxjy_remote.js',
  exposes: {
    './role': './src/unit-share/network-school/basic-data/account/role/index.vue'
  },
  library: {
    type: 'window',
    name: 'jxjy_remote'
  },
  remotes: {
    jxjy: 'jxjy@http://localhost:8081/remote.js'
  },
  shared: {
    vue: {
      singleton: true,
      version: '2.6.11'
    },
    '@hbfe-api/biz-information-management': {
      singleton: true
    },
    axios: {
      singleton: true,
      version: '0.19.2'
    }
  }
})

Project Information

Both projects were built using vue/cli. The publicPath has been set to auto and the uniqueName in output has been configured separately. Module federation can be used normally if only one party provides the component and one party uses the component.

The console does not prompt any errors, only a warning that the dependent version in shared does not match.

questions

The two projects are configured according to the documents. According to the principle, A project can be both A provider and a consumer. However, after such configuration, I did not find the files of project A requesting project B in the network request, nor did Project A requesting project B in the B project. Why is that? Is there a problem with my configuration? Moreover, in the network request, it can be seen that the MF file obtained by A project is provided by A project itself, and the B project is also like this.

This is A network request from Project A, and this remote.js is supposed to be what it's going to provide, but now it loads itself image

ceechen0 avatar Jul 18 '24 07:07 ceechen0