Skip to content
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

Provide API to create a custom esbuild CLI with plugins #3539

Merged
merged 2 commits into from
Jun 30, 2024

Conversation

edewit
Copy link
Contributor

@edewit edewit commented Dec 12, 2023

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 erikjan.dewit@gmail.com

@edewit edewit changed the title added new runImpl that takes plugins Provide API to create a custom esbuild CLI with plugins Dec 21, 2023
@ia3andy
Copy link

ia3andy commented Dec 21, 2023

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

pkg/cli/cli_impl.go Outdated Show resolved Hide resolved
pkg/cli/cli_impl.go Outdated Show resolved Hide resolved
@ia3andy
Copy link

ia3andy commented Jan 24, 2024

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!

edewit and others added 2 commits March 18, 2024 13:24
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Co-authored-by: Andy Damevin <ia3andy@gmail.com>
@ia3andy
Copy link

ia3andy commented May 6, 2024

@evanw ping!

@Rattlyy
Copy link

Rattlyy commented Jun 18, 2024

bump :)

@ia3andy
Copy link

ia3andy commented Jun 24, 2024

@evanw any reason not to get this in?

@evanw
Copy link
Owner

evanw commented Jun 25, 2024

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

@ia3andy
Copy link

ia3andy commented Jun 26, 2024

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?

@evanw
Copy link
Owner

evanw commented Jun 30, 2024

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 evanw merged commit 91663db into evanw:main Jun 30, 2024
evanw added a commit that referenced this pull request Jun 30, 2024
@ia3andy
Copy link

ia3andy commented Jul 1, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants