-
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
Return list of dependencies/files used in Build API call with bundle: true #673
Comments
Look at the Keep in mind that the approach you described can lead to incorrect behavior. If you build twice, it's possible for none of the original input files to change and for the second build to still be different than the first. This is possible because new input files may be added that take precedence over the original input files in path resolution order. For example, if the list of implicit extensions to resolve against is Just a friendly warning that this approach is very hard to get right! It's safer to just watch the whole project directory and explicitly exclude files you know don't invalidate the build instead of trying to only include files that you know invalidate the build. |
Hah! I was just coming back here because I saw I completely missed {
warnings: [],
metafile: ...
} Not end of the world though! And you're right! I think my assumption is that a feature like this would always return an up-to-date list of what is currently being depended on with each build/rebuild. What I usually do in scenarios like this is err on the side of watching too much vs. keeping it exactly in sync. So using your example — if |
I'm going to close this then since it seems like the original issue is resolved.
I agree. This is already tracked by #633. |
Not exactly what you're looking for, but if you use |
Hello! 👋
Apologies if this is something that is already possible that I missed or if has been previously addressed. Would it be possible to make the Build API in bundle mode (I'm interested in the JavaScript interface, but imagine this would make sense in the Go API too) return a list of all the absolute paths to files it loaded/parsed to prepare a bundle?
My use case here is creating a watch mode — I'm thrilled that
esbuild
made the choice to not be a tool with yet another file watcher, but one thing I've not been able to figure out how to do is determine what filesesbuild
ends up parsing.In my ideal scenario, a call to
build({ bundle: true, incremental: true })
would return a list in the return object of all the absolute paths to files it used, and I could then take that list to hook it up to a file watcher of my choosing and selectively callresult.rebuild()
when any of them change.I could see this being useful with code that interfaces with the Serve API too — by watching for changes to any files it reports back as dependencies, I could smartly force a refresh of a page (and trigger the rebuild) only when necessary. (The only catch here is there is no direct way to get updated dependency lists like a
rebuild()
could, so perhaps it'd need an event emitter interface to do so? Not sure.)Most guides to setting up file watchers with
esbuild
I've seen assume that every file in a glob should be the trigger (src/**/*.js
), but it'd be great to have the information in hand to make smarter calls. One of my favorite examples of this in another space is withdart-sass
andnode-sass
, which returns a handy list of used files under theincludedFiles
key, which is enough to create ways to selectively re-compile CSS as needed. My hope isesbuild
could do something similar.Thank you!
The text was updated successfully, but these errors were encountered: