Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export async function buildAction(actionContext: BuildActionContext): Promise<vo
pendingChangedEsmFiles.clear();
pendingChangedDtsFiles.clear();

for (const warning of warnings) {
for (const warning of [...warnings, ...bundleOutput.warnings]) {
context.logger.warn(warning);
}

Expand Down
29 changes: 24 additions & 5 deletions packages/angular/build/src/builders/library/pipeline/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export interface BundleEntryPointsOutput {

/** Map of entry point names to their bundle results containing bundled module IDs. */
bundleResults: Map<string, BundleResult>;

/** Warning messages emitted during bundling. */
warnings: string[];
}

/**
Expand Down Expand Up @@ -65,6 +68,9 @@ interface MultiBundleOutput {

/** Map of bundle entry names to the set of virtual module IDs included in the bundle. */
moduleIdsByBundle: Map<string, Set<string>>;

/** Warning messages emitted during the bundle invocation. */
warnings: string[];
}

/**
Expand All @@ -85,7 +91,7 @@ export async function bundleEntryPoints(
): Promise<BundleEntryPointsOutput> {
const bundleResults = new Map<string, BundleResult>();
if (items.length === 0) {
return { filesToEmit: [], bundleResults };
return { filesToEmit: [], bundleResults, warnings: [] };
}

const esmEntryPoints: NormalizedEntryPoint[] = [];
Expand Down Expand Up @@ -122,6 +128,7 @@ export async function bundleEntryPoints(
return {
filesToEmit: [...esmOutput.filesToEmit, ...dtsOutput.filesToEmit],
bundleResults,
warnings: [...esmOutput.warnings, ...dtsOutput.warnings],
};
}

Expand Down Expand Up @@ -228,7 +235,10 @@ function createMemoryFileLoaderPlugin(
* @param dir The destination output directory prefix.
* @returns The processed multi-bundle output.
*/
function processRolldownOutput(output: RolldownOutput['output'], dir: string): MultiBundleOutput {
function processRolldownOutput(
output: RolldownOutput['output'],
dir: string,
): Pick<MultiBundleOutput, 'filesToEmit' | 'moduleIdsByBundle'> {
const filesToEmit: MemoryOutputFile[] = [];
const moduleIdsByBundle = new Map<string, Set<string>>();
const chunksByFileName = new Map<string, OutputChunk>();
Expand Down Expand Up @@ -317,6 +327,7 @@ async function executeMultiBundle(
sourcemap = true;
}

const warnings: string[] = [];
const bundle = await rolldown({
context: 'this',
input,
Expand All @@ -325,6 +336,11 @@ async function executeMultiBundle(
treeshake: false,
resolve: { symlinks: !preserveSymlinks },
checks: { circularDependency: false },
onLog(level, log) {
if (level === 'warn') {
warnings.push(log.message);
}
},
experimental: {
attachDebugInfo: 'none',
},
Expand All @@ -341,7 +357,10 @@ async function executeMultiBundle(
comments: { jsdoc: isDts, legal: true, annotation: true },
});

return processRolldownOutput(output, dir);
return {
...processRolldownOutput(output, dir),
warnings,
};
} finally {
await bundle.close();
}
Expand All @@ -361,7 +380,7 @@ async function bundleAllEsm(
options: NormalizedLibraryOptions,
): Promise<MultiBundleOutput> {
if (entryPoints.length === 0) {
return { filesToEmit: [], moduleIdsByBundle: new Map() };
return { filesToEmit: [], moduleIdsByBundle: new Map(), warnings: [] };
}

return executeMultiBundle(
Expand All @@ -386,7 +405,7 @@ async function bundleAllDts(
options: NormalizedLibraryOptions,
): Promise<MultiBundleOutput> {
if (entryPoints.length === 0) {
return { filesToEmit: [], moduleIdsByBundle: new Map() };
return { filesToEmit: [], moduleIdsByBundle: new Map(), warnings: [] };
}

const dtsSourcemap = options.declarationMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,25 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
}),
);
});

it('should log Rolldown bundler warnings', async () => {
await harness.writeFile(
'projects/lib/src/public-api.ts',
`export function runDynamic(code: string) { return eval(code); }`,
);

harness.useTarget('build', {
...BASE_OPTIONS,
});

const { result, logs } = await harness.executeOnce();
expect(result?.success).toBeTrue();
expect(logs).toContain(
jasmine.objectContaining({
level: 'warn',
message: jasmine.stringContaining('eval'),
}),
);
});
});
});
Loading