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

Provide ability to cancel build #2725

Closed
benmccann opened this issue Dec 7, 2022 · 2 comments
Closed

Provide ability to cancel build #2725

benmccann opened this issue Dec 7, 2022 · 2 comments

Comments

@benmccann
Copy link

We wanted Vite to be able to cancel a build. We came up with a workaround for being able to do it that I'm sharing here, but we felt it was a bit too hacky to merge it at the moment and are going to hold off until the functionality is hopefully supported here

Screenshot from 2022-12-07 13-37-11

@evanw
Copy link
Owner

evanw commented Dec 8, 2022

Hmm, this could get complicated with incremental builds. I'll have to think about the right API for this so heads up that this might not be added super quickly. Thanks for the report.

@evanw
Copy link
Owner

evanw commented Jan 16, 2023

The new context object makes this straightforward, so I'm going to add this API there. The context object is primarily meant for incremental builds but you can use it even if you are only building once. That might look like this:

let ctx = esbuild.context({
  // ...
})
try {
  setTimeout(() => ctx.cancel(), 500)
  return await ctx.rebuild()
} finally {
  // Remember to dispose of the context when you're done
  await ctx.dispose()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants