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 ¶
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 (*Compiler) Parse ¶ added in v0.53.0
func (c *Compiler) Parse( src, filename string, commonJSWrap bool, esm 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.