Skip to content

fix(@angular-devkit/build-angular): browser builder should not swollo… #14829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2019
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
8 changes: 6 additions & 2 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,14 @@ export abstract class ArchitectCommand<
},
);

const result = await run.output.toPromise();
const { error, success } = await run.output.toPromise();
await run.stop();

return result.success ? 0 : 1;
if (error) {
this.logger.error(error);
}

return success ? 0 : 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function augmentAppWithServiceWorker(
if (!configExists) {
throw new Error(tags.oneLine`
Error: Expected to find an ngsw-config.json configuration
file in the ${appRoot} folder. Either provide one or disable Service Worker
file in the ${getSystemPath(appRoot)} folder. Either provide one or disable Service Worker
in your angular.json configuration file.
`);
}
Expand Down
19 changes: 17 additions & 2 deletions packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export function buildWebpackBrowser(
})
.pipe(
map(() => ({ success: true })),
catchError(() => of({ success: false })),
catchError(error => of({ success: false, error: mapErrorToMessage(error) })),
);
} else {
return of({ success });
Expand All @@ -276,7 +276,10 @@ export function buildWebpackBrowser(
resolve(root, normalize(options.outputPath)),
options.baseHref || '/',
options.ngswConfigPath,
).then(() => ({ success: true }), () => ({ success: false })));
).then(
() => ({ success: true }),
error => ({ success: false, error: mapErrorToMessage(error) }),
));
} else {
return of(buildEvent);
}
Expand All @@ -291,4 +294,16 @@ export function buildWebpackBrowser(
);
}

function mapErrorToMessage(error: unknown): string | undefined {
if (error instanceof Error) {
return error.message;
}

if (typeof error === 'string') {
return error;
}

return undefined;
}

export default createBuilder<json.JsonObject & BrowserBuilderSchema>(buildWebpackBrowser);