Skip to content
Draft
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 @@ -71,6 +71,7 @@ export async function buildAction(actionContext: BuildActionContext): Promise<Ex
return result;
}

let collectedAssets = actionContext.collectedAssets;
const filesToEmit: OutputFile[] = [];

if (shouldCompileEntryPoints) {
Expand Down Expand Up @@ -102,13 +103,14 @@ export async function buildAction(actionContext: BuildActionContext): Promise<Ex
const itemsToBundle = collectEntryPointsToBundle(options, buildState);
let bundleOutput: BundleEntryPointsOutput;
try {
[bundleOutput] = await Promise.all([
[bundleOutput, , collectedAssets] = await Promise.all([
bundleEntryPoints(itemsToBundle, esmFiles, dtsFiles, {
...options,
declarationMap,
compilationMode,
}),
diagnosePromise,
collectedAssets ?? buildState.collectAssets(options, modifiedFiles),
]);
} catch (error) {
assertIsError(error);
Expand All @@ -121,10 +123,10 @@ export async function buildAction(actionContext: BuildActionContext): Promise<Ex
return result;
}

result.addWarnings(bundleOutput.warnings);
if (result.hasErrors) {
return result;
}
result.addWarnings(bundleOutput.warnings);

filesToEmit.push(...bundleOutput.filesToEmit);
buildState.recordBundleOutput(bundleOutput.bundleResults);
Expand All @@ -145,19 +147,17 @@ export async function buildAction(actionContext: BuildActionContext): Promise<Ex
filesToEmit.push(...manifestFiles);
}

const collectedAssets =
actionContext.collectedAssets ?? (await buildState.collectAssets(options, modifiedFiles));
collectedAssets ??= await buildState.collectAssets(options, modifiedFiles);
filesToEmit.push(...collectedAssets.filesToEmit);

await emitFilesToDisk(filesToEmit, (file) => path.posix.join(options.outputPath, file.path));

const filesToDelete = buildState.recordEmittedOutputs(collectedAssets, manifestFiles);

if (filesToDelete.size) {
await deleteFilesFromDisk(
Array.from(filesToDelete, (file) => path.posix.join(options.outputPath, file)),
);
}

await emitFilesToDisk(filesToEmit, (file) => path.posix.join(options.outputPath, file.path));
} catch (error) {
assertIsError(error);
result.addError(error.message);
Expand All @@ -178,7 +178,7 @@ function verifyAllowedDependencies(
options: NormalizedLibraryOptions,
result: ExecutionResult,
): boolean {
const { packageJson, allowedNonPeerDependencies } = options;
const { packageJson, packageJsonPath, allowedNonPeerDependencies } = options;
const dependencies = {
...(packageJson.dependencies ?? {}),
...(packageJson.optionalDependencies ?? {}),
Expand All @@ -189,7 +189,7 @@ function verifyAllowedDependencies(
if (!allowedNonPeerDependencies.some((regex) => regex.test(dep))) {
result.addError(
`Dependency '${dep}' must be explicitly allowed using the 'allowedNonPeerDependencies' option, ` +
`or moved to 'peerDependencies' in 'package.json'.`,
`or moved to 'peerDependencies' in '${packageJsonPath}'.`,
);
isValid = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>

const { result, logs } = await harness.executeOnce();
expect(result?.success).toBeTrue();
expect(logs.some((l) => l.level === 'warn')).toBeFalse();
expect(logs).not.toContain(jasmine.objectContaining({ level: 'warn' }));
});

it('should preserve JSDoc comments in .d.ts and annotation comments in .mjs bundles', async () => {
Expand Down Expand Up @@ -204,10 +204,13 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
);
});

it('should log failure on build error', async () => {
it('should log failure on build error without secondary bundler warnings', async () => {
await harness.writeFile(
'projects/lib/src/public-api.ts',
`export const title: number = 'invalid type';`,
`
export const title: number = 'invalid type';
export function runDynamic(code: string) { return eval(code); }
`,
);

harness.useTarget('build', {
Expand All @@ -230,6 +233,7 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
),
}),
);
expect(logs).not.toContain(jasmine.objectContaining({ level: 'warn' }));
expect(logs).not.toContain(
jasmine.objectContaining({
message: jasmine.stringMatching(/Output location:/),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
expect(logs).toContain(
jasmine.objectContaining({
level: 'error',
message: jasmine.stringMatching(/lodash-es.*allowedNonPeerDependencies/),
message: jasmine.stringMatching(
/lodash-es.*allowedNonPeerDependencies.*projects\/lib\/package\.json/,
),
}),
);
});
Expand Down
Loading