Skip to content
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

fix(bundling): fix esbuild build watch #12448

Merged
merged 1 commit into from Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 39 additions & 40 deletions packages/esbuild/src/executors/esbuild/esbuild.impl.ts
Expand Up @@ -57,46 +57,45 @@ export async function* esbuildExecutor(
options,
context
);
const result = await esbuild.build({
...esbuildOptions,
watch:
// Only emit info on one of the watch processes.
idx === 0
? {
onRebuild: async (
error: esbuild.BuildFailure,
result: esbuild.BuildResult
) => {
if (!options.skipTypeCheck) {
const { errors } = await runTypeCheck(
options,
context
);
hasTypeErrors = errors.length > 0;
}
const success = !error && !hasTypeErrors;

if (!success) {
logger.info(BUILD_WATCH_FAILED);
} else {
logger.info(BUILD_WATCH_SUCCEEDED);
}

next({
success: !!error && !hasTypeErrors,
outfile: esbuildOptions.outfile,
});
},
}
: true,
});

next({
success,
outfile: esbuildOptions.outfile,
});

return result;
const watch =
// Only emit info on one of the watch processes.
idx === 0
? {
onRebuild: async (
error: esbuild.BuildFailure,
result: esbuild.BuildResult
) => {
if (!options.skipTypeCheck) {
const { errors } = await runTypeCheck(options, context);
hasTypeErrors = errors.length > 0;
}
const success = !error && !hasTypeErrors;

if (!success) {
logger.info(BUILD_WATCH_FAILED);
} else {
logger.info(BUILD_WATCH_SUCCEEDED);
}

next({
success: !!error && !hasTypeErrors,
outfile: esbuildOptions.outfile,
});
},
}
: true;
try {
const result = await esbuild.build({ ...esbuildOptions, watch });

next({
success: true,
outfile: esbuildOptions.outfile,
});

return result;
} catch {
next({ success: false });
}
})
);
const processOnExit = () => {
Expand Down