Source File
config.go
Belonging Package
github.com/evanw/esbuild/internal/config
package config
import (
)
type LanguageTarget int8
type JSXOptions struct {
Parse bool
Factory []string
Fragment []string
}
type TSOptions struct {
Parse bool
}
type Platform uint8
const (
PlatformBrowser Platform = iota
PlatformNode
PlatformNeutral
)
ClassFields bool
}
type SourceMap uint8
const (
SourceMapNone SourceMap = iota
SourceMapInline
SourceMapLinkedWithComment
SourceMapExternalWithoutComment
SourceMapInlineAndExternal
)
type Loader int
const (
LoaderNone Loader = iota
LoaderJS
LoaderJSX
LoaderTS
LoaderTSX
LoaderJSON
LoaderText
LoaderBase64
LoaderDataURL
LoaderFile
LoaderBinary
LoaderCSS
LoaderDefault
)
func ( Loader) () bool {
return == LoaderTS || == LoaderTSX
}
func ( Loader) () bool {
return == LoaderJS || == LoaderJSX || == LoaderTS || == LoaderTSX
}
type Format uint8
FormatESModule
)
func ( Format) () bool {
return == FormatPreserve || == FormatESModule
}
func ( Format) () string {
switch {
case FormatIIFE:
return "iife"
case FormatCommonJS:
return "cjs"
case FormatESModule:
return "esm"
}
return ""
}
type StdinInfo struct {
Loader Loader
Contents string
SourceFile string
AbsResolveDir string
}
type WildcardPattern struct {
Prefix string
Suffix string
}
type ExternalModules struct {
NodeModules map[string]bool
AbsPaths map[string]bool
Patterns []WildcardPattern
}
type Mode uint8
const (
ModePassThrough Mode = iota
ModeConvertFormat
ModeBundle
)
type Options struct {
Mode Mode
PreserveSymlinks bool
RemoveWhitespace bool
MinifyIdentifiers bool
MangleSyntax bool
CodeSplitting bool
WatchMode bool
WriteToStdout bool
OmitRuntimeForTests bool
PreserveUnusedImportsTS bool
UseDefineForClassFields bool
ASCIIOnly bool
KeepNames bool
IgnoreDCEAnnotations bool
Defines *ProcessedDefines
TS TSOptions
JSX JSXOptions
Platform Platform
UnsupportedJSFeatures compat.JSFeature
UnsupportedCSSFeatures compat.CSSFeature
ExtensionOrder []string
MainFields []string
AbsNodePaths []string // The "NODE_PATH" variable from Node.js
ExternalModules ExternalModules
AbsOutputFile string
AbsOutputDir string
AbsOutputBase string
OutputExtensionJS string
OutputExtensionCSS string
GlobalName []string
TsConfigOverride string
ExtensionToLoader map[string]Loader
OutputFormat Format
PublicPath string
InjectAbsPaths []string
InjectedDefines []InjectedDefine
InjectedFiles []InjectedFile
Banner string
Footer string
ChunkPathTemplate []PathTemplate
AssetPathTemplate []PathTemplate
Plugins []Plugin
HashPlaceholder
)
type PathTemplate struct {
Data string
Placeholder PathPlaceholder
}
type PathPlaceholders struct {
Name *string
Hash *string
}
func ( PathPlaceholders) ( PathPlaceholder) *string {
switch {
case NamePlaceholder:
return .Name
case HashPlaceholder:
return .Hash
}
return nil
}
func ( []PathTemplate) string {
return [0].Data
}
:= strings.Builder{}
for , := range {
.WriteString(.Data)
switch .Placeholder {
case NamePlaceholder:
.WriteString("[name]")
case HashPlaceholder:
.WriteString("[hash]")
}
}
return .String()
}
func ( []PathTemplate, PathPlaceholder) bool {
for , := range {
if .Placeholder == {
return true
}
}
return false
}
:= false
for , := range {
if .Get(.Placeholder) != nil || (.Placeholder == NoPlaceholder && +1 < len()) {
= true
break
}
}
if ! {
return
}
:= make([]PathTemplate, 0, len())
for , := range {
if := .Get(.Placeholder); != nil {
.Data += *
.Placeholder = NoPlaceholder
}
if := len() - 1; >= 0 && [].Placeholder == NoPlaceholder {
:= &[]
.Data += .Data
.Placeholder = .Placeholder
} else {
= append(, )
}
}
return
}
func ( Mode, Format) bool {
return == ModeBundle || ( == ModeConvertFormat && == FormatIIFE)
}
type InjectedDefine struct {
Source logger.Source
Data js_ast.E
Name string
}
type InjectedFile struct {
Path string
SourceIndex uint32
Exports []string
IsDefine bool
}
var filterMutex sync.Mutex
var filterCache map[string]*regexp.Regexp
func ( string) ( *regexp.Regexp) {
(func() {
filterMutex.Lock()
defer filterMutex.Unlock()
if filterCache != nil {
, = filterCache[]
}
})()
if {
return
}
filterMutex.Lock()
defer filterMutex.Unlock()
if filterCache == nil {
filterCache = make(map[string]*regexp.Regexp)
}
filterCache[] =
return
}
func ( string, string, string) (*regexp.Regexp, error) {
if == "" {
return nil, fmt.Errorf("[%s] %q is missing a filter", , )
}
:= compileFilter()
if == nil {
return nil, fmt.Errorf("[%s] %q filter is not a valid Go regular expression: %q", , , )
}
return , nil
}
func ( logger.Path, *regexp.Regexp, string) bool {
return ( == "" || .Namespace == ) && .MatchString(.Text)
}
type Plugin struct {
Name string
OnResolve []OnResolve
OnLoad []OnLoad
}
type OnResolve struct {
Name string
Filter *regexp.Regexp
Namespace string
Callback func(OnResolveArgs) OnResolveResult
}
type OnResolveArgs struct {
Path string
Importer logger.Path
ResolveDir string
Kind ast.ImportKind
PluginData interface{}
}
type OnResolveResult struct {
PluginName string
Path logger.Path
External bool
PluginData interface{}
Msgs []logger.Msg
ThrownError error
}
type OnLoad struct {
Name string
Filter *regexp.Regexp
Namespace string
Callback func(OnLoadArgs) OnLoadResult
}
type OnLoadArgs struct {
Path logger.Path
PluginData interface{}
}
type OnLoadResult struct {
PluginName string
Contents *string
AbsResolveDir string
Loader Loader
PluginData interface{}
Msgs []logger.Msg
ThrownError error
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |