容器条目:AppComponent[0] - 错误:找不到模块:错误:模块联合插件中无法解析”

问题描述 投票:0回答:1

我正在尝试使用模块联合插件将组件或模块公开为远程组件或模块,但是 面临以下错误。

容器条目:AppComponent[0] - 错误:找不到模块:错误:无法解析“/src/main/webapp”中的“./src/app/app.component.ts”

请在下面找到 webpack.config.js 配置。

const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
const mf = require('@angular-architects/module-federation/webpack');
const path = require('path');
const share = mf.share;

const sharedMappings = new mf.SharedMappings();
sharedMappings.register(path.join(__dirname, '../../tsconfig.json'), [
  /* mapped paths to share */
]);
module.exports = {
  output: {
    uniqueName: 'myApp',
    publicPath: 'auto',
    scriptType: 'text/javascript'
  },
  optimization: {
    runtimeChunk: false
  },
  resolve: {
    alias: {
      ...sharedMappings.getAliases()
    },
 
  },
  plugins: [
    new ModuleFederationPlugin({
      name: "my_app",
      filename: "my_app.js",
       exposes: {
        "AppComponent": './src/app/app.component.ts'
      },
      
      shared: share({
        '@angular/core': { singleton: true, strictVersion: true, requiredVersion: '12.2.17' },
        '@angular/common': { singleton: true, strictVersion: true, requiredVersion: '12.2.17' },
        '@angular/router': { singleton: true, strictVersion: true, requiredVersion: '12.2.17' },

        ...sharedMappings.getDescriptors()
      })
    }),
    sharedMappings.getPlugin()
  ]
};
angular webpack-module-federation mfe
1个回答
0
投票

将曝光更改为

{“AppComponent”:require.resolve('./src/app/app.component.ts')}

© www.soinside.com 2019 - 2024. All rights reserved.