config

package
v0.14.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileFilterForPlugin

func CompileFilterForPlugin(pluginName string, kind string, filter string) (*regexp.Regexp, error)

func HasPlaceholder

func HasPlaceholder(template []PathTemplate, placeholder PathPlaceholder) bool

func PluginAppliesToPath

func PluginAppliesToPath(path logger.Path, filter *regexp.Regexp, namespace string) bool

func ShouldCallRuntimeRequire

func ShouldCallRuntimeRequire(mode Mode, outputFormat Format) bool

func TemplateToString

func TemplateToString(template []PathTemplate) string

Types

type DefineArgs

type DefineArgs struct {
	Loc             logger.Loc
	FindSymbol      func(logger.Loc, string) js_ast.Ref
	SymbolForDefine func(int) js_ast.Ref
}

type DefineData

type DefineData struct {
	DefineFunc DefineFunc

	// True if accessing this value is known to not have any side effects. For
	// example, a bare reference to "Object.create" can be removed because it
	// does not have any observable side effects.
	CanBeRemovedIfUnused bool

	// True if a call to this value is known to not have any side effects. For
	// example, a bare call to "Object()" can be removed because it does not
	// have any observable side effects.
	CallCanBeUnwrappedIfUnused bool
}

type DefineFunc

type DefineFunc func(DefineArgs) js_ast.E

type DotDefine

type DotDefine struct {
	Parts []string
	Data  DefineData
}

type ExternalModules

type ExternalModules struct {
	NodeModules map[string]bool
	AbsPaths    map[string]bool
	Patterns    []WildcardPattern
}

type Format

type Format uint8
const (
	// This is used when not bundling. It means to preserve whatever form the
	// import or export was originally in. ES6 syntax stays ES6 syntax and
	// CommonJS syntax stays CommonJS syntax.
	FormatPreserve Format = iota

	// IIFE stands for immediately-invoked function expression. That looks like
	// this:
	//
	//   (() => {
	//     ... bundled code ...
	//   })();
	//
	// If the optional GlobalName is configured, then we'll write out this:
	//
	//   let globalName = (() => {
	//     ... bundled code ...
	//     return exports;
	//   })();
	//
	FormatIIFE

	// The CommonJS format looks like this:
	//
	//   ... bundled code ...
	//   module.exports = exports;
	//
	FormatCommonJS

	// The ES module format looks like this:
	//
	//   ... bundled code ...
	//   export {...};
	//
	FormatESModule
)

func (Format) KeepES6ImportExportSyntax

func (f Format) KeepES6ImportExportSyntax() bool

func (Format) String

func (f Format) String() string

type InjectableExport

type InjectableExport struct {
	Alias string
	Loc   logger.Loc
}

type InjectedDefine

type InjectedDefine struct {
	Source logger.Source
	Data   js_ast.E
	Name   string
}

type InjectedFile

type InjectedFile struct {
	Source     logger.Source
	Exports    []InjectableExport
	DefineName string
}

type JSXExpr

type JSXExpr struct {
	Parts    []string
	Constant js_ast.E
}

type JSXOptions

type JSXOptions struct {
	Factory  JSXExpr
	Fragment JSXExpr
	Parse    bool
	Preserve bool
}

type LegalComments

type LegalComments uint8
const (
	LegalCommentsInline LegalComments = iota
	LegalCommentsNone
	LegalCommentsEndOfFile
	LegalCommentsLinkedWithComment
	LegalCommentsExternalWithoutComment
)

func (LegalComments) HasExternalFile

func (lc LegalComments) HasExternalFile() bool

type Loader

type Loader int
const (
	LoaderNone Loader = iota
	LoaderJS
	LoaderJSX
	LoaderTS
	LoaderTSX
	LoaderJSON
	LoaderText
	LoaderBase64
	LoaderDataURL
	LoaderFile
	LoaderBinary
	LoaderCSS
	LoaderDefault
)

func (Loader) CanHaveSourceMap

func (loader Loader) CanHaveSourceMap() bool

func (Loader) IsTypeScript

func (loader Loader) IsTypeScript() bool

type MaybeBool

type MaybeBool uint8
const (
	Unspecified MaybeBool = iota
	True
	False
)

type Mode

type Mode uint8
const (
	ModePassThrough Mode = iota
	ModeConvertFormat
	ModeBundle
)

type ModuleType

type ModuleType uint8
const (
	ModuleUnknown ModuleType = iota
	ModuleCommonJS
	ModuleESM
)

type OnLoad

type OnLoad struct {
	Name      string
	Filter    *regexp.Regexp
	Namespace string
	Callback  func(OnLoadArgs) OnLoadResult
}

type OnLoadArgs

type OnLoadArgs struct {
	Path       logger.Path
	PluginData interface{}
}

type OnLoadResult

type OnLoadResult struct {
	PluginName string

	Contents      *string
	AbsResolveDir string
	Loader        Loader
	PluginData    interface{}

	Msgs        []logger.Msg
	ThrownError error

	AbsWatchFiles []string
	AbsWatchDirs  []string
}

type OnResolve

type OnResolve struct {
	Name      string
	Filter    *regexp.Regexp
	Namespace string
	Callback  func(OnResolveArgs) OnResolveResult
}

type OnResolveArgs

type OnResolveArgs struct {
	Path       string
	Importer   logger.Path
	ResolveDir string
	Kind       ast.ImportKind
	PluginData interface{}
}

type OnResolveResult

type OnResolveResult struct {
	PluginName string

	Path             logger.Path
	External         bool
	IsSideEffectFree bool
	PluginData       interface{}

	Msgs        []logger.Msg
	ThrownError error

	AbsWatchFiles []string
	AbsWatchDirs  []string
}

type OnStart

type OnStart struct {
	Name     string
	Callback func() OnStartResult
}

type OnStartResult

type OnStartResult struct {
	Msgs        []logger.Msg
	ThrownError error
}

type Options

type Options struct {
	Mode              Mode
	ModuleType        ModuleType
	PreserveSymlinks  bool
	RemoveWhitespace  bool
	MinifyIdentifiers bool
	MangleSyntax      bool
	ProfilerNames     bool
	CodeSplitting     bool
	WatchMode         bool
	AllowOverwrite    bool
	LegalComments     LegalComments

	// If true, make sure to generate a single file that can be written to stdout
	WriteToStdout bool

	OmitRuntimeForTests     bool
	PreserveUnusedImportsTS bool
	UseDefineForClassFields MaybeBool
	ASCIIOnly               bool
	KeepNames               bool
	IgnoreDCEAnnotations    bool
	TreeShaking             bool

	Defines  *ProcessedDefines
	TS       TSOptions
	JSX      JSXOptions
	Platform Platform

	IsTargetUnconfigured   bool // If true, TypeScript's "target" setting is respected
	UnsupportedJSFeatures  compat.JSFeature
	UnsupportedCSSFeatures compat.CSSFeature
	TSTarget               *TSTarget

	// This is the original information that was used to generate the
	// unsupported feature sets above. It's used for error messages.
	OriginalTargetEnv string

	ExtensionOrder  []string
	MainFields      []string
	Conditions      []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

	JSBanner  string
	JSFooter  string
	CSSBanner string
	CSSFooter string

	EntryPathTemplate []PathTemplate
	ChunkPathTemplate []PathTemplate
	AssetPathTemplate []PathTemplate

	Plugins []Plugin

	NeedsMetafile bool

	SourceMap             SourceMap
	SourceRoot            string
	ExcludeSourcesContent bool

	Stdin *StdinInfo
}

type PathPlaceholder

type PathPlaceholder uint8
const (
	NoPlaceholder PathPlaceholder = iota

	// The relative path from the original parent directory to the configured
	// "outbase" directory, or to the lowest common ancestor directory
	DirPlaceholder

	// The original name of the file, or the manual chunk name, or the name of
	// the type of output file ("entry" or "chunk" or "asset")
	NamePlaceholder

	// A hash of the contents of this file, and the contents and output paths of
	// all dependencies (except for their hash placeholders)
	HashPlaceholder
)

type PathPlaceholders

type PathPlaceholders struct {
	Dir  *string
	Name *string
	Hash *string
}

func (PathPlaceholders) Get

func (placeholders PathPlaceholders) Get(placeholder PathPlaceholder) *string

type PathTemplate

type PathTemplate struct {
	Data        string
	Placeholder PathPlaceholder
}

func SubstituteTemplate

func SubstituteTemplate(template []PathTemplate, placeholders PathPlaceholders) []PathTemplate

type Platform

type Platform uint8
const (
	PlatformBrowser Platform = iota
	PlatformNode
	PlatformNeutral
)

type Plugin

type Plugin struct {
	Name      string
	OnStart   []OnStart
	OnResolve []OnResolve
	OnLoad    []OnLoad
}

type ProcessedDefines

type ProcessedDefines struct {
	IdentifierDefines map[string]DefineData
	DotDefines        map[string][]DotDefine
}

func ProcessDefines

func ProcessDefines(userDefines map[string]DefineData) ProcessedDefines

This transformation is expensive, so we only want to do it once. Make sure to only call processDefines() once per compilation. Unfortunately Golang doesn't have an efficient way to copy a map and the overhead of copying all of the properties into a new map once for every new parser noticeably slows down our benchmarks.

type SourceMap

type SourceMap uint8
const (
	SourceMapNone SourceMap = iota
	SourceMapInline
	SourceMapLinkedWithComment
	SourceMapExternalWithoutComment
	SourceMapInlineAndExternal
)

type StdinInfo

type StdinInfo struct {
	Loader        Loader
	Contents      string
	SourceFile    string
	AbsResolveDir string
}

type TSOptions

type TSOptions struct {
	Parse bool
}

type TSTarget

type TSTarget struct {
	Source                logger.Source
	Range                 logger.Range
	Target                string
	UnsupportedJSFeatures compat.JSFeature
}

type WildcardPattern

type WildcardPattern struct {
	Prefix string
	Suffix string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL