Documentation
¶
Overview ¶
Package build connects the pipeline: Go frontend (loader) -> semantic lowering (lower) -> TypeScript files -> esbuild (Go API) -> ES modules.
esbuild owns TypeScript syntax stripping, JS printing, target lowering, bundling, tree shaking, minification, code splitting and final source map emission. It never sees Go and makes no Go-semantic decisions.
Index ¶
- func ReadOverlay(file string) (map[string][]byte, error)
- func ToolexecOverlay(dir, prog string, overlay map[string][]byte, patterns []string) (map[string][]byte, error)
- func WriteDTS(dir string, mods []*lower.Module) error
- func WriteTS(dir string, mods []*lower.Module) error
- type DiagError
- type Lowered
- type Options
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadOverlay ¶
ReadOverlay reads an overlay file in the go command's -overlay format, {"Replace": {"/abs/file.go": "/path/with/contents.go"}}, into file contents keyed by absolute path. Deleting files (an empty replacement) is not supported.
func ToolexecOverlay ¶
func ToolexecOverlay(dir, prog string, overlay map[string][]byte, patterns []string) (map[string][]byte, error)
ToolexecOverlay runs the build of patterns through the -toolexec program prog and returns overlay extended with the source its compiles saw. An empty prog returns overlay as is.
func WriteDTS ¶
WriteDTS writes the declaration file of each entry package's module next to the module, at p.d.ts for the module p.ts (see lower.Module.DTS).
Types ¶
type Lowered ¶
type Lowered struct {
Mods []*lower.Module
Entries []string // import paths of the root packages, in the order of the patterns
// Warnings name standard library and dependency functions that goesm
// cannot lower yet; they were replaced by stubs that panic when called.
Warnings []string
// Cached is the number of modules taken from the module cache (see
// modCache) instead of being lowered.
Cached int
}
Lowered is the result of the frontend and the semantic lowering.
type Options ¶
type Options struct {
Dir string // working directory (module root or below)
Patterns []string // Go package patterns, e.g. ./main
OutDir string // output directory (default "dist")
TSDir string // where generated TypeScript is written ("" = temp dir)
Split bool // one ES module per Go package instead of one bundle
Minify bool
// Overlay replaces or adds files by absolute path, as go build -overlay
// does. Nil means the files on disk.
Overlay map[string][]byte
// Toolexec is a program run on the build's compile commands, as with
// go build -toolexec (see internal/toolexec).
Toolexec string
}
Options for a build.