Skip to content

Commit

Permalink
release notes for #3539
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 30, 2024
1 parent 91663db commit 3f57db8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
Plugins that return values from `onResolve` without resolving the path (i.e. without setting either `path` or `external: true`) will now cause a warning. This is because esbuild only uses return values from `onResolve` if it successfully resolves the path, and it's not good for invalid input to be silently ignored.
* Add a new Go API for running the CLI with plugins ([#3539](https://github.com/evanw/esbuild/pull/3539))
With esbuild's Go API, you can now call `cli.RunWithPlugins(args, plugins)` to pass an array of esbuild plugins to be used during the build process. This allows you to create a CLI that behaves similarly to esbuild's CLI but with additional Go plugins enabled.
This was contributed by [@edewit](https://github.com/edewit).
## 0.21.5
* Fix `Symbol.metadata` on classes without a class decorator ([#3781](https://github.com/evanw/esbuild/issues/3781))
Expand Down
9 changes: 4 additions & 5 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ func Run(osArgs []string) int {
return runImpl(osArgs, []api.Plugin{})
}

// This function invokes the esbuild CLI. It takes an array of command-line
// arguments (excluding the executable argument itself) and returns an exit
// code. It also takes adds some plugins that need to be added to the run
func RunWithPlugins(osArgs []string, plugin []api.Plugin) int {
return runImpl(osArgs, plugin)
// This is similar to "Run()" but also takes an array of plugins to be used
// during the build process.
func RunWithPlugins(osArgs []string, plugins []api.Plugin) int {
return runImpl(osArgs, plugins)
}

// This parses an array of strings into an options object suitable for passing
Expand Down
7 changes: 6 additions & 1 deletion pkg/cli/cli_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,12 @@ func runImpl(osArgs []string, plugins []api.Plugin) int {

osArgs, analyze := filterAnalyzeFlags(osArgs)
buildOptions, transformOptions, extras, err := parseOptionsForRun(osArgs)

// Add any plugins from the caller after parsing the build options
if buildOptions != nil {
buildOptions.Plugins = append(buildOptions.Plugins, plugins...)
}

if analyze != analyzeDisabled {
addAnalyzePlugin(buildOptions, analyze, osArgs)
}
Expand Down Expand Up @@ -1280,7 +1286,6 @@ func runImpl(osArgs []string, plugins []api.Plugin) int {
}
}

buildOptions.Plugins = plugins
// Handle post-build actions with a plugin so they also work in watch mode
buildOptions.Plugins = append(buildOptions.Plugins, api.Plugin{
Name: "PostBuildActions",
Expand Down

0 comments on commit 3f57db8

Please sign in to comment.