Open mckravchyk opened 2 months ago
The "what file changed" information in esbuild is maybe not valuable for general users since it's not complete.
esbuild implements the custom file watcher that basically polls file system at a low interval to make it compatible in all systems and use less cpu resources. When it finds a file changed, it will start a new build task without needing to know "all changed files" since it will fetch all files in that task anyway.
If you want to print all changed files in esbuild's rebuild task, you can use another file watcher implementation like chokidar to gather file change events and print them in esbuild plugin's onEnd()
callback. The other file watcher may use more efficient way to monit fs which is generally faster than esbuild's build end event.
When it finds a file changed, it will start a new build task without needing to know "all changed files" since it will fetch all files in that task anyway.
Please consider this a feature request to pass the changed file to the build task and expose it in an event (onStart or onEnd). Using another file watcher feels like a hack if ESBuild is already watching it and it would be really useful for implementing hot reload. For instance, currently it's not possible to distinguish between CSS and JS file change if they are part of the same bundle. I worked around this by creating a separate bundle for SCSS files.
I understand your request. However, Hot-reloading for CSS only is alreay possible and is documented. The 'change' event sent to browser means the output files changed, not the source changed.
Thanks, that's good to know. I'm still hoping this feature will be considered though.
Is there a way to detect which file has triggered a rebuild in watch mode? I have tried using
onResolve
but it shows more like all paths involved in the bundling. It would be useful for implementing hot reload.By the way, this tool is awesome! I just upgraded from Rollup that consumed 1.8GB of memory to run its watch mode for multiple bundles while ESBuild uses almost nothing. Thanks so much for developing it!