-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule_esbuild.go
67 lines (54 loc) · 1.18 KB
/
module_esbuild.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package engine
import (
_ "embed"
"github.com/evanw/esbuild/pkg/api"
)
var (
//go:embed module_esbuild.d.ts
esbuildDefine []byte
esbuildMap = map[string]any{
"analyzeMetafile": api.AnalyzeMetafile,
"formatMessages": api.FormatMessages,
"transform": api.Transform,
"build": api.Build,
"context": Transform12(api.Context, func(bc api.BuildContext, be *api.ContextError) *ContextResult {
return &ContextResult{
Context: &Context{bc},
Err: be,
}
}),
}
)
type EsBuild struct {
}
func (e EsBuild) Identity() string {
return "go/esbuild"
}
func (e EsBuild) TypeDefine() []byte {
return esbuildDefine
}
func (e EsBuild) Exports() map[string]any {
return esbuildMap
}
type ContextResult struct {
Context *Context
Err *api.ContextError
}
type Context struct {
c api.BuildContext
}
func (c *Context) Rebuild() api.BuildResult {
return c.c.Rebuild()
}
func (c *Context) Watch(options api.WatchOptions) error {
return c.c.Watch(options)
}
func (c *Context) Serve(options api.ServeOptions) (api.ServeResult, error) {
return c.c.Serve(options)
}
func (c *Context) Cancel() {
c.c.Cancel()
}
func (c *Context) Dispose() {
c.c.Dispose()
}