esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Provide API to create a custom esbuild CLI with plugins

Open edewit opened this issue 1 year ago • 3 comments

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]

edewit avatar Dec 12 '23 09:12 edewit

Thanks for creating this PR @edewit, this will help a lot!

ia3andy avatar Dec 21 '23 10:12 ia3andy

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!

ia3andy avatar Jan 24 '24 09:01 ia3andy

@evanw ping!

ia3andy avatar May 06 '24 14:05 ia3andy

bump :)

Rattlyy avatar Jun 18 '24 16:06 Rattlyy

@evanw any reason not to get this in?

ia3andy avatar Jun 24 '24 15:06 ia3andy

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).

evanw avatar Jun 25 '24 23:06 evanw

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?

ia3andy avatar Jun 26 '24 08:06 ia3andy

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).

evanw avatar Jun 30 '24 16:06 evanw

Thanks!

ia3andy avatar Jul 01 '24 06:07 ia3andy