1
- import path from 'path' ;
2
1
import fs from 'fs' ;
2
+ import path from 'path' ;
3
3
4
- import { NormalizedFederationConfig } from '../config/federation-config' ;
5
- import { FederationOptions } from './federation-options' ;
6
- import { bundle } from '../utils/build-utils' ;
7
4
import { ExposesInfo , SharedInfo } from '@softarc/native-federation-runtime' ;
5
+ import { NormalizedFederationConfig } from '../config/federation-config' ;
8
6
import {
9
7
createBuildResultMap ,
10
8
lookupInResultMap ,
11
9
} from '../utils/build-result-map' ;
10
+ import { bundle } from '../utils/build-utils' ;
12
11
import { logger } from '../utils/logger' ;
13
12
import { normalize } from '../utils/normalize' ;
13
+ import { FederationOptions } from './federation-options' ;
14
14
15
15
export interface ArtefactInfo {
16
16
mappings : SharedInfo [ ] ;
@@ -40,18 +40,24 @@ export async function bundleExposedAndMappings(
40
40
41
41
logger . info ( 'Building federation artefacts' ) ;
42
42
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
+ }
55
61
56
62
const resultMap = createBuildResultMap ( result , hash ) ;
57
63
@@ -70,8 +76,8 @@ export async function bundleExposedAndMappings(
70
76
dev : ! fedOptions . dev
71
77
? undefined
72
78
: {
73
- entryPoint : normalize ( path . normalize ( item . fileName ) ) ,
74
- } ,
79
+ entryPoint : normalize ( path . normalize ( item . fileName ) ) ,
80
+ } ,
75
81
} ) ;
76
82
}
77
83
@@ -84,10 +90,10 @@ export async function bundleExposedAndMappings(
84
90
dev : ! fedOptions . dev
85
91
? undefined
86
92
: {
87
- entryPoint : normalize (
88
- path . join ( fedOptions . workspaceRoot , item . fileName )
89
- ) ,
90
- } ,
93
+ entryPoint : normalize (
94
+ path . join ( fedOptions . workspaceRoot , item . fileName )
95
+ ) ,
96
+ } ,
91
97
} ) ;
92
98
}
93
99
@@ -111,8 +117,8 @@ export function describeExposed(
111
117
dev : ! options . dev
112
118
? undefined
113
119
: {
114
- entryPoint : localPath ,
115
- } ,
120
+ entryPoint : localPath ,
121
+ } ,
116
122
} ) ;
117
123
}
118
124
@@ -136,8 +142,8 @@ export function describeSharedMappings(
136
142
dev : ! fedOptions . dev
137
143
? undefined
138
144
: {
139
- entryPoint : normalize ( path . normalize ( m . path ) ) ,
140
- } ,
145
+ entryPoint : normalize ( path . normalize ( m . path ) ) ,
146
+ } ,
141
147
} ) ;
142
148
}
143
149
0 commit comments