compiler

package
v0.0.0-...-2fc1e16 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: AGPL-3.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

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

		"plugins": []interface{}{

			[]interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}},
		},
		"ast":           false,
		"sourceMaps":    false,
		"babelrc":       false,
		"compact":       false,
		"retainLines":   true,
		"highlightCode": false,
	}
)

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	Options Options
	// 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

func (c *Compiler) Compile(src, filename string, isESM bool) (*goja.Program, string, error)

Compile the program in the given CompatibilityMode, wrapping it between pre and post code TODO isESM will be used once goja support ESM modules natively

func (*Compiler) Transform

func (c *Compiler) Transform(src, filename string, inputSrcMap []byte) (code string, srcMap []byte, err error)

Transform the given code into ES5

type Options

type Options struct {
	CompatibilityMode lib.CompatibilityMode
	SourceMapLoader   func(string) ([]byte, error)
	Strict            bool
}

Options are options to the compiler

type Pool

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

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

func (c *Pool) Get() *Compiler

Get a compiler from the pool.

func (*Pool) Put

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

Put a compiler back in the pool.

Jump to

Keyboard shortcuts

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