Skip to content

Commit 1923ddc

Browse files
Merge pull request #918 from aramirezj/feat--unhide-bundling-errors-from-esbuild-adapter
feat(nf): prevents bundle adapter hiding errors when building artifacts
2 parents a98376d + c502d78 commit 1923ddc

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

libs/native-federation-core/src/lib/core/bundle-exposed-and-mappings.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import path from 'path';
21
import 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';
74
import { ExposesInfo, SharedInfo } from '@softarc/native-federation-runtime';
5+
import { NormalizedFederationConfig } from '../config/federation-config';
86
import {
97
createBuildResultMap,
108
lookupInResultMap,
119
} from '../utils/build-result-map';
10+
import { bundle } from '../utils/build-utils';
1211
import { logger } from '../utils/logger';
1312
import { normalize } from '../utils/normalize';
13+
import { FederationOptions } from './federation-options';
1414

1515
export 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

Comments
 (0)