sourcemap

package
v0.0.1-beta.8 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package sourcemap builds the generated-TypeScript -> original-.go source map (Source Map v3) that goesm attaches to every generated module.

goesm only produces this first hop. esbuild reads it from the generated file's sourceMappingURL comment and composes it into the final JavaScript -> .go map, so final map emission stays esbuild's job.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UTF16Len

func UTF16Len(s string) int

UTF16Len returns the length of s in UTF-16 code units.

Types

type Builder

type Builder struct {
	Mappings []Mapping
	// contains filtered or unexported fields
}

Builder collects sources and mappings.

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Add

func (b *Builder) Add(m Mapping)

Add records a mapping.

func (*Builder) AddSource

func (b *Builder) AddSource(name, content string) int

AddSource registers a source file and returns its index.

func (*Builder) InlineComment

func (b *Builder) InlineComment(file string) string

InlineComment returns a sourceMappingURL comment embedding the map.

func (*Builder) JSON

func (b *Builder) JSON(file string) []byte

JSON encodes the map.

func (*Builder) SourceIndex

func (b *Builder) SourceIndex(name string) (int, bool)

SourceIndex returns the index of a registered source.

func (*Builder) UTF16Col

func (b *Builder) UTF16Col(i, line, byteCol int) int

UTF16Col converts a 1-based byte column on a 1-based line of source i (as reported by go/token) into a 0-based UTF-16 column.

type Mapping

type Mapping struct {
	GenLine, GenCol int
	Source          int
	SrcLine, SrcCol int
}

Mapping maps a generated position to an original position. All lines and columns are 0-based; columns are UTF-16 code units as the spec requires.

Jump to

Keyboard shortcuts

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