compiler

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: AGPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOpts = map[string]interface{}{

		"plugins": []interface{}{

			[]interface{}{"transform-es2015-template-literals", map[string]interface{}{"loose": false, "spec": false}},
			"transform-es2015-literals",

			[]interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}},
			"transform-es2015-object-super",

			[]interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}},

			"transform-exponentiation-operator",
		},
		"ast":           false,
		"sourceMaps":    false,
		"babelrc":       false,
		"compact":       false,
		"retainLines":   true,
		"highlightCode": false,
	}
)

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

A Compiler compiles JavaScript source code (ES5.1 or ES6) into a goja.Program

func New

func New(logger logrus.FieldLogger) *Compiler

New returns a new Compiler

func (*Compiler) Compile added in v0.18.0

func (c *Compiler) Compile(src, filename, pre, post string,
	strict bool, compatMode lib.CompatibilityMode) (*goja.Program, string, error)

Compile the program in the given CompatibilityMode, wrapping it between pre and post code

func (*Compiler) Transform

func (c *Compiler) Transform(src, filename string) (code string, srcmap *SourceMap, err error)

Transform the given code into ES5

type Pool added in v0.34.0

type Pool struct {
	// contains filtered or unexported fields
}

Pool is a pool of compilers so it can be used easier in parallel tests as they have their own babel.

func NewPool added in v0.34.0

func NewPool(logger logrus.FieldLogger, count int) *Pool

NewPool creates a Pool that will be using the provided logger and will preallocate (in parallel) the count of compilers each with their own babel.

func (*Pool) Get added in v0.34.0

func (c *Pool) Get() *Compiler

Get a compiler from the pool.

func (*Pool) Put added in v0.34.0

func (c *Pool) Put(co *Compiler)

Put a compiler back in the pool.

type SourceMap

type SourceMap struct {
	Version    int
	File       string
	SourceRoot string
	Sources    []string
	Names      []string
	Mappings   string
}

Jump to

Keyboard shortcuts

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