Angular 块文件不是使用 Angular Module Federation Webpack 创建的

Angular chunk files not created with Angular Module Federation Webpack

我正在点击以下链接使用 Angular 模块联合创建 MFE。

https://github.com/benorama/mfe-basic-demo

https://www.angulararchitects.io/en/aktuelles/the-microfrontend-revolution-part-2-module-federation-with-angular/

项目运行后,

ng serve mfe1

我可以看到在终端中生成了块文件,但是当我在文件资源管理器中看到时实际上没有文件,我找不到 mfe1RemoteEntry.js

这是我的 webpack 文件,

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: "mfe1",
    publicPath: "auto"
  },
  optimization: {
    runtimeChunk: false
  },   
  resolve: {
    alias: {
      ...sharedMappings.getAliases(),
    }
  },
  plugins: [
    new ModuleFederationPlugin({
      
        name: "mfe1",
        filename: "mfe1RemoteEntry.js",
        exposes: {
            './TodoModule': './projects/mfe1/src/app/todo/todo.module.ts',
        },    
        shared: share({
          "@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
          "@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
          "@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
          "@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },

          ...sharedMappings.getDescriptors()
        })
        
    }),
    sharedMappings.getPlugin()
  ],
};

有什么想法吗?

当您 运行 'ng serve' 时,生成的块将只在内存中而不在磁盘上。使用 'ng build' 构建项目后,文件将在磁盘上。