compiler

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: AGPL-3.0 Imports: 13 Imported by: 4

Documentation

Overview

Package compiler implements additional functionality for k6 to compile js code. more specifically wrapping code in CommonJS wrapper or transforming it through esbuild for typescript support. TODO this package name makes little sense now that it only parses and tranforms javascript. Although people do call such transformation - compilation, so maybe it is still fine

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

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

A Compiler compiles JavaScript or TypeScript source code into a sobek.Program

func New

func New(logger logrus.FieldLogger) *Compiler

New returns a new Compiler

func (*Compiler) Parse added in v0.53.0

func (c *Compiler) Parse(
	src, filename string, commonJSWrap bool,
) (prg *ast.Program, finalCode string, err error)

Parse parses the provided source. It wraps as the same as CommonJS support. The returned program can be compiled directly by Sobek. Additionally, it returns the end code that has been parsed including any required transformations.

func (*Compiler) WithUsage added in v0.54.0

func (c *Compiler) WithUsage(u *usage.Usage)

WithUsage allows the compiler to be given usage.Usage to use

type Options added in v0.36.0

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

Options are options to the compiler

Jump to

Keyboard shortcuts

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