1- import path from 'path' ;
21import fs from 'fs' ;
2+ import path from 'path' ;
33
4- import { NormalizedFederationConfig } from '../config/federation-config' ;
5- import { FederationOptions } from './federation-options' ;
6- import { bundle } from '../utils/build-utils' ;
74import { ExposesInfo , SharedInfo } from '@softarc/native-federation-runtime' ;
5+ import { NormalizedFederationConfig } from '../config/federation-config' ;
86import {
97 createBuildResultMap ,
108 lookupInResultMap ,
119} from '../utils/build-result-map' ;
10+ import { bundle } from '../utils/build-utils' ;
1211import { logger } from '../utils/logger' ;
1312import { normalize } from '../utils/normalize' ;
13+ import { FederationOptions } from './federation-options' ;
1414
1515export interface ArtefactInfo {
1616 mappings : SharedInfo [ ] ;
@@ -40,18 +40,24 @@ export async function bundleExposedAndMappings(
4040
4141 logger . info ( 'Building federation artefacts' ) ;
4242
43- const result = await bundle ( {
44- entryPoints,
45- outdir : fedOptions . outputPath ,
46- tsConfigPath : fedOptions . tsConfig ,
47- external : externals ,
48- dev : ! ! fedOptions . dev ,
49- watch : fedOptions . watch ,
50- mappedPaths : config . sharedMappings ,
51- kind : 'mapping-or-exposed' ,
52- hash,
53- optimizedMappings : config . features . ignoreUnusedDeps ,
54- } ) ;
43+ let result ;
44+ try {
45+ result = await bundle ( {
46+ entryPoints,
47+ outdir : fedOptions . outputPath ,
48+ tsConfigPath : fedOptions . tsConfig ,
49+ external : externals ,
50+ dev : ! ! fedOptions . dev ,
51+ watch : fedOptions . watch ,
52+ mappedPaths : config . sharedMappings ,
53+ kind : 'mapping-or-exposed' ,
54+ hash,
55+ optimizedMappings : config . features . ignoreUnusedDeps ,
56+ } ) ;
57+ } catch ( error ) {
58+ logger . error ( 'Error building federation artefacts' ) ;
59+ throw error ;
60+ }
5561
5662 const resultMap = createBuildResultMap ( result , hash ) ;
5763
@@ -70,8 +76,8 @@ export async function bundleExposedAndMappings(
7076 dev : ! fedOptions . dev
7177 ? undefined
7278 : {
73- entryPoint : normalize ( path . normalize ( item . fileName ) ) ,
74- } ,
79+ entryPoint : normalize ( path . normalize ( item . fileName ) ) ,
80+ } ,
7581 } ) ;
7682 }
7783
@@ -84,10 +90,10 @@ export async function bundleExposedAndMappings(
8490 dev : ! fedOptions . dev
8591 ? undefined
8692 : {
87- entryPoint : normalize (
88- path . join ( fedOptions . workspaceRoot , item . fileName )
89- ) ,
90- } ,
93+ entryPoint : normalize (
94+ path . join ( fedOptions . workspaceRoot , item . fileName )
95+ ) ,
96+ } ,
9197 } ) ;
9298 }
9399
@@ -111,8 +117,8 @@ export function describeExposed(
111117 dev : ! options . dev
112118 ? undefined
113119 : {
114- entryPoint : localPath ,
115- } ,
120+ entryPoint : localPath ,
121+ } ,
116122 } ) ;
117123 }
118124
@@ -136,8 +142,8 @@ export function describeSharedMappings(
136142 dev : ! fedOptions . dev
137143 ? undefined
138144 : {
139- entryPoint : normalize ( path . normalize ( m . path ) ) ,
140- } ,
145+ entryPoint : normalize ( path . normalize ( m . path ) ) ,
146+ } ,
141147 } ) ;
142148 }
143149
0 commit comments