Skip to content

fix(@angular-devkit/build-webpack): emit result when webpack is closed #21428

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
Jul 27, 2021
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: 3 additions & 5 deletions packages/angular_devkit/build_angular/src/app-shell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ async function _appShellBuilder(
let spinner: Spinner | undefined;

try {
// Using `.result` instead of `.output` causes Webpack FS cache not to be created.
const [browserResult, serverResult] = await Promise.all([
browserTargetRun.output.toPromise() as Promise<BrowserBuilderOutput>,
serverTargetRun.output.toPromise() as Promise<ServerBuilderOutput>,
browserTargetRun.result as Promise<BrowserBuilderOutput>,
serverTargetRun.result as Promise<ServerBuilderOutput>,
]);

if (browserResult.success === false || browserResult.baseOutputPath === undefined) {
Expand All @@ -203,8 +202,7 @@ async function _appShellBuilder(

return { success: false, error: err.message };
} finally {
// workaround for [tsetse] All Promises in async functions must either be awaited or used in an expression.
const _ = Promise.all([browserTargetRun.stop(), serverTargetRun.stop()]);
await Promise.all([browserTargetRun.stop(), serverTargetRun.stop()]);
}
}

Expand Down
14 changes: 9 additions & 5 deletions packages/angular_devkit/build_webpack/src/webpack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,20 @@ export function runWebpack(
log(stats, config);

const statsOptions = typeof config.stats === 'boolean' ? undefined : config.stats;

obs.next({
const result = {
success: !stats.hasErrors(),
webpackStats: shouldProvideStats ? stats.toJson(statsOptions) : undefined,
emittedFiles: getEmittedFiles(stats.compilation),
outputPath: stats.compilation.outputOptions.path,
} as unknown as BuildResult);
} as unknown as BuildResult;

if (!config.watch) {
webpackCompiler.close(() => obs.complete());
if (config.watch) {
obs.next(result);
} else {
webpackCompiler.close(() => {
obs.next(result);
obs.complete();
});
}
};

Expand Down