esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Support file listing via stdin or external file for 'esbuild' command

Open earlhood opened this issue 3 years ago • 3 comments

I am looking into incorporating esbuild into an existing project that does not use NPM or node.js. Therefore I am looking at the esbuild executable for minifying CSS and JS source files. Based on the documentation and --help output, files to process can only be specified as arguments on the command-line. Since I could potentially be processing a large number of files, it would be nice if esbuild supported and option where the files to process can be specified a line-at-a-time either via stdin or via an external file. My concern is without this feature, I may encounter process creation limits (e.g. Windows' CreateProcess) when trying to execute esbuild.

earlhood avatar Sep 06 '22 20:09 earlhood

The best method is probably to run esbuild repeatedly on batches of files in this case. I don’t think support for this should be built in because it’s an edge case, and the workaround is straightforward.

evanw avatar Sep 06 '22 23:09 evanw

The best method is probably to run esbuild repeatedly on batches of files in this case. I don’t think support for this should be built in because it’s an edge case, and the workaround is straightforward.

I am considering this, but it is awkward. The project build is driven by Ant scripts, so if esbuild supported an option to provide the list files via stdin or in a file makes invocation within Ant much easier when using Ant filesets for obtaining the list of files to process. It also avoids the annoying shell escaping rules (especially on Windows) if pathnames have spaces and other special characters.

earlhood avatar Sep 07 '22 17:09 earlhood

For posterity purposes: I created a custom Ant task to call esbuild a file at a time from the fileset(s) passed into the task. I lose the performance capability of esbuild processing multiple files directly, but the task does what is needed and avoids any potential OS limitations regarding command-line arguments.

earlhood avatar Sep 08 '22 14:09 earlhood

I'm closing this issue because I don't think esbuild should support this for the reason described above.

evanw avatar Dec 05 '22 04:12 evanw