-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Docs question] Does watch mode enable incremental compilation? #1049
Comments
Ah, sorry. Yes watch mode enables incremental compilation. |
Thank you! Feel free to close this at your discretion. |
Sure, a repro could be good. Or at least describing what you mean by different behavior. |
FWIW "incremental" in the docs was meant to describe this behavior: #980 ( |
I tried creating a repro and I realized what the problem is. The subtlety escaped me the first time. Watch mode means esbuild reacts to filesystem events and triggers The confusion is what happens when you have both: my expectation was that when My expectation: const esbuild = require("esbuild")
function sleep(timeoutMS) {
return new Promise(resolve => setTimeout(resolve, timeoutMS))
}
async function main() {
const result = await esbuild.build({
entryPoints: ["in.js"],
outfile: "out.js",
incremental: true,
watch: {
onRebuild(error, result) {
console.log("a rebuild event occurred")
},
},
})
await sleep(1_000)
result.rebuild() // <- I expected this to trigger watch.onRebuild
await sleep(1_000)
result.rebuild() // <- I expected this to trigger watch.onRebuild
}
main() I tested this with 0.10.0 just to make sure. I think this is just a situation where the wording was lost on me. I assumed Just to be clear -- I am totally OK with this behavior. I think if anything the docs should just try to slightly emphasize these differences if they don’t already. Something like: So in this case I probably won’t need to use result.rebuild anymore especially because you’ve added the new APIs for
I’m actually totally OK with this behavior. This makes sense to me. That being said, if you did provide an imperative handler to manually fire the
Because Honestly this is probably just confusion from working with esbuild pre-0.10.0. I don’t know if I would have confused myself this way if I were starting now. |
Wait you said watch mode enables incremental compilation, but that is only internally, right? I don’t get access to I think this is why I had to ask because I couldn’t figure out whether incremental was enabled myself. const esbuild = require("esbuild")
async function main() {
const result = await esbuild.build({
entryPoints: ["in.js"],
outfile: "out.js",
watch: {
onRebuild(error, result) {
console.log("a rebuild event occurred")
},
},
})
console.log(result.rebuild === undefined) // true
}
main() |
I just meant that watch mode uses incremental compilation. When watch mode is enabled, rebuilds are not done completely from scratch. I did not mean that |
Ah OK. So It sounds like users shouldn’t reach for Sorry for the confusion! And thank you. The tl;dr for someone stumbling on this thread is: use |
In the docs in the second paragraph of this section, it reads:
Does enabling
watch
also enableincremental
compilation? My confusion is because the text reads "you can optionally provide a callback that will be called whenever an incremental build has completed" but there is noincremental
flag in the provided example.Thank you.
The text was updated successfully, but these errors were encountered: