config

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefineData added in v0.5.22

type DefineData struct {
	DefineFunc DefineFunc

	// 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(FindSymbol) ast.E

type DotDefine

type DotDefine struct {
	Parts []string
	Data  DefineData
}

type ExternalModules added in v0.5.20

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

type FindSymbol

type FindSymbol func(name string) ast.Ref

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 ModuleName is configured, then we'll write out this:
	//
	//   let moduleName = (() => {
	//     ... 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

type JSXOptions

type JSXOptions struct {
	Parse    bool
	Factory  []string
	Fragment []string
}

type LanguageTarget

type LanguageTarget int8

type Loader

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

type Options

type Options struct {
	// true: imports are scanned and bundled along with the file
	// false: imports are left alone and the file is passed through as-is
	IsBundling bool

	RemoveWhitespace  bool
	MinifyIdentifiers bool
	MangleSyntax      bool
	CodeSplitting     bool

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

	OmitRuntimeForTests bool

	Strict   StrictOptions
	Defines  *ProcessedDefines
	TS       TSOptions
	JSX      JSXOptions
	Platform Platform

	UnsupportedFeatures compat.Feature

	ExtensionOrder  []string
	ExternalModules ExternalModules

	AbsOutputFile     string
	AbsOutputDir      string
	ModuleName        string
	TsConfigOverride  string
	ExtensionToLoader map[string]Loader
	OutputFormat      Format

	// If present, metadata about the bundle is written as JSON here
	AbsMetadataFile string

	SourceMap SourceMap
	Stdin     *StdinInfo
}

type Platform

type Platform uint8
const (
	PlatformBrowser Platform = iota
	PlatformNode
)

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
)

type StdinInfo

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

type StrictOptions

type StrictOptions struct {
	// Loose:  "a ?? b" => "a != null ? a : b"
	// Strict: "a ?? b" => "a !== null && a !== void 0 ? a : b"
	//
	// The disadvantage of strictness here is code bloat. The only observable
	// difference between the two is when the left operand is the bizarre legacy
	// value "document.all". This value is special-cased in the standard for
	// legacy reasons such that "document.all != null" is false even though it's
	// not "null" or "undefined".
	NullishCoalescing bool

	// Loose:  "class Foo { foo = 1 }" => "class Foo { constructor() { this.foo = 1; } }"
	// Strict: "class Foo { foo = 1 }" => "class Foo { constructor() { __publicField(this, 'foo', 1); } }"
	//
	// The disadvantage of strictness here is code bloat and performance. The
	// advantage is following the class field specification accurately. For
	// example, loose mode will incorrectly trigger setter methods while strict
	// mode won't.
	ClassFields bool
}

type TSOptions

type TSOptions struct {
	Parse bool
}

Jump to

Keyboard shortcuts

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