js

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TemplatePlaceholder = "//__TEMPLATE_INSERT_IMPORTS__"
)

Variables

This section is empty.

Functions

func BindgenCmd

func BindgenCmd() *cli.Cmd

func CreateJSBindings

func CreateJSBindings(spec BindgenOptions) (code string, err error)

func Minify

func Minify(opts MinifyOptions) (code []byte, sourceMap []byte, err error)

Minify javascript source code using esbuild (no typescript support).

func Transpile

func Transpile(opts TranspileOptions) (js string, err error)

Types

type BindgenFlags

type BindgenFlags struct {
	BuildOpts toolchain.Options

	WASM           string             `cli:"wasm,#path to the wasm blob (required, for import filtering)"`
	OutputFile     string             `cli:"o|output,#set file path to write the generated output, if not set, write generated bindings to stdout"`
	Mode           string             `cli:"m|mode,def=raw,comp=raw,comp=cjs,comp=amd,comp=umd,#set target module system to transpile typescript"`
	Minify         bool               `cli:"minify,#write minified code and source map along with the bindgen output file"`
	Platform       toolchain.Platform `cli:"p|platform,def=js/wasm,#set os/arch pair"`
	Tags           []string           `cli:"t|tag,#go build tags"`
	CustomTemplate string             `cli:"T|template,#set path to a custom bindgen template file"`
	ES             string             `cli:"es,def=5,comp=3,comp=5,comp=6,#set ES language when transpiling typescript"`
	ModuleName     string             `cli:"n|name,def=bindings,#set module name for generated bindings"`
}

type BindgenOptions

type BindgenOptions struct {
	Mode          string
	ES            string
	ModuleName    string
	CustomWrapper string
	Deps          []*toolchain.Package
	Filter        WasmImportFilter
}

type MinifyOptions

type MinifyOptions struct {
	SourceCode string
	ES         api.Target
}

type SimpleWasmImportFilter

type SimpleWasmImportFilter map[WasmImportKey]bool

func CreateSimpleFilterFromWasm

func CreateSimpleFilterFromWasm(blob []byte) (filter SimpleWasmImportFilter, err error)

func (SimpleWasmImportFilter) Keep

func (m SimpleWasmImportFilter) Keep(module, field string) bool

type TranspileOptions

type TranspileOptions struct {
	Src            string
	ModuleName     string
	CompileOptions map[string]any
}

type WasmImportFilter

type WasmImportFilter interface {
	Keep(module, field string) bool
}

type WasmImportKey

type WasmImportKey struct {
	Module string
	Field  string
}

Jump to

Keyboard shortcuts

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