Skip to content

Commit

Permalink
fix(esbuild): pass original build for custom esbuild setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Dec 30, 2024
1 parent 3704b97 commit 9f85a26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/esbuild/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export function getEsbuildPlugin<UserOptions = Record<string, never>>(

function buildSetup() {
return (plugin: UnpluginOptions): EsbuildPlugin['setup'] => {
return (_build) => {
const build = _build as EsbuildPluginBuild
return (rawBuild) => {
const build = rawBuild as EsbuildPluginBuild
const context = createBuildContext(build)
const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build

Expand Down Expand Up @@ -305,7 +305,7 @@ function buildSetup() {
}

if (plugin.esbuild?.setup)
return plugin.esbuild.setup(build)
return plugin.esbuild.setup(rawBuild)
}
}
}
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CompilationContext as FarmCompilationContext, JsPlugin as FarmPlugin } from '@farmfe/core'
import type { Compilation as RspackCompilation, Compiler as RspackCompiler, LoaderContext as RspackLoaderContext, RspackPluginInstance } from '@rspack/core'
import type { BuildOptions, Plugin as EsbuildPlugin, Loader } from 'esbuild'
import type { BuildOptions, Plugin as EsbuildPlugin, Loader, PluginBuild } from 'esbuild'
import type { Plugin as RolldownPlugin } from 'rolldown'
import type { AstNode, EmittedAsset, PluginContextMeta as RollupContextMeta, Plugin as RollupPlugin, SourceMapInput } from 'rollup'
import type { Plugin as VitePlugin } from 'vite'
Expand Down Expand Up @@ -97,7 +97,7 @@ export interface UnpluginOptions {
onResolveFilter?: RegExp
onLoadFilter?: RegExp
loader?: Loader | ((code: string, id: string) => Loader)
setup?: (build: EsbuildPluginBuild) => void | Promise<void>
setup?: (build: PluginBuild) => void | Promise<void>
config?: (options: BuildOptions) => void
}
farm?: Partial<FarmPlugin>
Expand Down

0 comments on commit 9f85a26

Please # to comment.