Skip to content

Commit ab5cf42

Browse files
committed
fixup! fix(@angular/build): capture and report Rolldown warnings and errors in library builder
1 parent cd490df commit ab5cf42

2 files changed

Lines changed: 25 additions & 52 deletions

File tree

‎packages/angular/build/src/builders/library/pipeline/build-action.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,14 @@ export async function buildAction(actionContext: BuildActionContext): Promise<vo
152152
throw error;
153153
}
154154

155-
for (const warning of [...warnings, ...bundleOutput.warnings]) {
156-
context.logger.warn(warning);
157-
}
158-
159-
if (bundleOutput.errors.length > 0) {
160-
throw new Error(bundleOutput.errors.join('\n'));
161-
}
162-
163155
buildState.hasCompilationError = false;
164156
pendingChangedEsmFiles.clear();
165157
pendingChangedDtsFiles.clear();
166158

159+
for (const warning of [...warnings, ...bundleOutput.warnings]) {
160+
context.logger.warn(warning);
161+
}
162+
167163
filesToEmit.push(...bundleOutput.filesToEmit);
168164
for (const [name, bundleResult] of bundleOutput.bundleResults) {
169165
buildState.previousBundleResults.set(name, bundleResult);

‎packages/angular/build/src/builders/library/pipeline/bundler.ts‎

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ export interface BundleEntryPointsOutput {
3737

3838
/** Warning messages emitted during bundling. */
3939
warnings: string[];
40-
41-
/** Error messages emitted during bundling. */
42-
errors: string[];
4340
}
4441

4542
/**
@@ -74,9 +71,6 @@ interface MultiBundleOutput {
7471

7572
/** Warning messages emitted during the bundle invocation. */
7673
warnings: string[];
77-
78-
/** Error messages emitted during the bundle invocation. */
79-
errors: string[];
8074
}
8175

8276
/**
@@ -97,7 +91,7 @@ export async function bundleEntryPoints(
9791
): Promise<BundleEntryPointsOutput> {
9892
const bundleResults = new Map<string, BundleResult>();
9993
if (items.length === 0) {
100-
return { filesToEmit: [], bundleResults, warnings: [], errors: [] };
94+
return { filesToEmit: [], bundleResults, warnings: [] };
10195
}
10296

10397
const esmEntryPoints: NormalizedEntryPoint[] = [];
@@ -135,7 +129,6 @@ export async function bundleEntryPoints(
135129
filesToEmit: [...esmOutput.filesToEmit, ...dtsOutput.filesToEmit],
136130
bundleResults,
137131
warnings: [...esmOutput.warnings, ...dtsOutput.warnings],
138-
errors: [...esmOutput.errors, ...dtsOutput.errors],
139132
};
140133
}
141134

@@ -324,27 +317,24 @@ async function executeMultiBundle(
324317
const isDts = extension === 'd.ts';
325318
const dir = isDts ? TYPES_OUTPUT_DIR : FESM_OUTPUT_DIR;
326319
const warnings: string[] = [];
327-
const errors: string[] = [];
328-
let bundle: Awaited<ReturnType<typeof rolldown>> | undefined;
320+
const bundle = await rolldown({
321+
context: 'this',
322+
input,
323+
plugins,
324+
treeshake: false,
325+
resolve: { symlinks: !preserveSymlinks },
326+
checks: { circularDependency: false },
327+
onLog(level, log) {
328+
if (level === 'warn') {
329+
warnings.push(log.message);
330+
}
331+
},
332+
experimental: {
333+
attachDebugInfo: 'none',
334+
},
335+
});
329336

330337
try {
331-
bundle = await rolldown({
332-
context: 'this',
333-
input,
334-
plugins,
335-
treeshake: false,
336-
resolve: { symlinks: !preserveSymlinks },
337-
checks: { circularDependency: false },
338-
onLog(level, log) {
339-
if (level === 'warn') {
340-
warnings.push(log.message);
341-
}
342-
},
343-
experimental: {
344-
attachDebugInfo: 'none',
345-
},
346-
});
347-
348338
const { output } = await bundle.generate({
349339
format: 'es',
350340
dir,
@@ -355,25 +345,12 @@ async function executeMultiBundle(
355345
comments: { jsdoc: isDts, legal: true, annotation: true },
356346
});
357347

358-
const { filesToEmit, moduleIdsByBundle } = processRolldownOutput(output, dir);
359-
360-
return {
361-
filesToEmit,
362-
moduleIdsByBundle,
363-
warnings,
364-
errors,
365-
};
366-
} catch (error) {
367-
errors.push(error instanceof Error ? error.message : String(error));
368-
369348
return {
370-
filesToEmit: [],
371-
moduleIdsByBundle: new Map(),
349+
...processRolldownOutput(output, dir),
372350
warnings,
373-
errors,
374351
};
375352
} finally {
376-
await bundle?.close();
353+
await bundle.close();
377354
}
378355
}
379356

@@ -391,7 +368,7 @@ async function bundleAllEsm(
391368
options: NormalizedLibraryOptions,
392369
): Promise<MultiBundleOutput> {
393370
if (entryPoints.length === 0) {
394-
return { filesToEmit: [], moduleIdsByBundle: new Map(), warnings: [], errors: [] };
371+
return { filesToEmit: [], moduleIdsByBundle: new Map(), warnings: [] };
395372
}
396373

397374
return executeMultiBundle(
@@ -417,7 +394,7 @@ async function bundleAllDts(
417394
options: NormalizedLibraryOptions,
418395
): Promise<MultiBundleOutput> {
419396
if (entryPoints.length === 0) {
420-
return { filesToEmit: [], moduleIdsByBundle: new Map(), warnings: [], errors: [] };
397+
return { filesToEmit: [], moduleIdsByBundle: new Map(), warnings: [] };
421398
}
422399

423400
const dtsSourcemap = options.declarationMap;

0 commit comments

Comments
 (0)