esbuild
esbuild copied to clipboard
Provide API to create a custom esbuild CLI with plugins
This is very important as it allows to create create a CLI version of esbuild with a custom set of Go Plugin (in our case we needed scss). Without it we have to fork esbuild and add it which is not very nice.
Signed-off-by: Erik Jan de Wit [email protected]
Thanks for creating this PR @edewit, this will help a lot!
Hey @evanw,
Could you consider getting this in, it would allow us to package our own CLI with plugins (scss) using normal GO import instead of forking the whole repository.
Cheers!
@evanw ping!
bump :)
@evanw any reason not to get this in?
Hey, thanks for the bump. There's no reason to not get this in. I think something like this makes sense and I'm supportive of it. The only reason it hasn't gotten in yet is that I haven't put aside the time yet to do the PR (i.e. think about the approach, make any changes, land it, and ship it).
Hey @evanw, that's a very good news! Thanks.
It seems this very basic PR is already enough for our use-case at least, do you have something else in mind?
There are several approaches to this. In general RunWith* functions are not a great approach to extending APIs with many optional parameters, as there could be a combinatorial explosion of options (and therefore of functions). That's why esbuild's API generally takes structs instead of individual parameters. Other approaches could be to require you to separate parsing the API options from using them in this scenario, or to provide a callback to modify the CLI options after they are parsed but before they are used. However, it could also be ok to take the approach you're proposing as plugins are somewhat of a special case (one of the few API parameters that can't be configured with the CLI).
Thanks!