Skip to content

Commit

Permalink
feat(esbuild): add plugin build context to meta (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Dec 12, 2022
1 parent 76287b8 commit 00830c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/esbuild/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function getEsbuildPlugin<UserOptions = {}>(

const setup = (plugin: UnpluginOptions): EsbuildPlugin['setup'] =>
plugin.esbuild?.setup
?? (({ onStart, onEnd, onResolve, onLoad, initialOptions, esbuild: { build } }) => {
?? ((pluginBuild) => {
const { onStart, onEnd, onResolve, onLoad, initialOptions, esbuild: { build } } = pluginBuild
meta.build = pluginBuild
const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/
const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/

Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AcornNode, EmittedAsset, PluginContextMeta as RollupContextMeta, Plugin as RollupPlugin, SourceMapInput } from 'rollup'
import type { Compiler as WebpackCompiler, WebpackPluginInstance } from 'webpack'
import type { Plugin as VitePlugin } from 'vite'
import type { Plugin as EsbuildPlugin } from 'esbuild'
import type { Plugin as EsbuildPlugin, PluginBuild } from 'esbuild'
import type VirtualModulesPlugin from 'webpack-virtual-modules'

export {
Expand Down Expand Up @@ -94,6 +94,7 @@ export type UnpluginContextMeta = Partial<RollupContextMeta> & ({
}
} | {
framework: 'esbuild'
build?: PluginBuild
/** Set the host plugin name of esbuild when returning multiple plugins */
esbuildHostName?: string
})
Expand Down

0 comments on commit 00830c3

Please sign in to comment.