1- import webpack from 'webpack' ;
2-
3- import { readdirSync } from 'fs' ;
1+ import { existsSync , readdirSync } from 'fs' ;
42import { env } from 'process' ;
5-
3+ import webpack from 'webpack' ;
64import { camelCase , capitalize } from 'lodash-es' ;
75import { readJsonFromVisual } from './utils.js' ;
86
97const ngJson = readJsonFromVisual ( 'angular.json' ) ;
108const projectName = env . VISUAL_NAME ! ;
119const visualRoot = ngJson . projects [ projectName ] . root ;
1210const sourceRoot = ngJson . projects [ projectName ] . sourceRoot ;
13- const pkg = readJsonFromVisual ( visualRoot + '/package.json' ) ;
11+ const pkgJson = readJsonFromVisual ( visualRoot + '/package.json' ) ;
1412const exposes = { } ;
1513
1614const getDirectories = ( source : string ) =>
@@ -19,8 +17,10 @@ const getDirectories = (source: string) =>
1917 . map ( dirent => dirent . name ) ;
2018
2119getDirectories ( sourceRoot ) . forEach ( dir => {
22- const exposedModule = capitalize ( camelCase ( dir ) ) ;
23- exposes [ exposedModule ] = `./${ sourceRoot } /${ dir } /${ dir } .component.ts` ;
20+ if ( existsSync ( `${ sourceRoot } /${ dir } /manifest.json` ) ) {
21+ const exposedModule = capitalize ( camelCase ( dir ) ) ;
22+ exposes [ exposedModule ] = `./${ sourceRoot } /${ dir } ` ;
23+ }
2424} ) ;
2525
2626const ModuleFederationPlugin = webpack . container . ModuleFederationPlugin ;
@@ -32,19 +32,19 @@ export default {
3232 output : {
3333 scriptType : 'text/javascript' ,
3434 publicPath : 'auto' ,
35- uniqueName : pkg . name ,
35+ uniqueName : pkgJson . name ,
3636 } ,
3737 optimization : {
3838 runtimeChunk : false ,
3939 } ,
4040 plugins : [
4141 new ModuleFederationPlugin ( {
42- name : pkg . name ,
42+ name : pkgJson . name ,
4343 library : {
4444 type : 'var' ,
45- name : pkg . name ,
45+ name : pkgJson . name ,
4646 } ,
47- filename : pkg . filename ,
47+ filename : pkgJson . filename ,
4848 exposes,
4949 shared : {
5050 '@angular/core' : {
0 commit comments