Documentation
¶
Index ¶
- func AppendSourceMapChunk(j *helpers.Joiner, prevEndState SourceMapState, startState SourceMapState, ...)
- func CanEscapeIdentifier(name string, unsupportedJSFeatures compat.JSFeature, asciiOnly bool) bool
- func QuoteForJSON(text string, asciiOnly bool) []byte
- func QuoteIdentifier(js []byte, name string, unsupportedFeatures compat.JSFeature) []byte
- type LineOffsetTable
- type Options
- type PrintResult
- type RequireOrImportMeta
- type SourceMapChunk
- type SourceMapState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSourceMapChunk ¶
func AppendSourceMapChunk(j *helpers.Joiner, prevEndState SourceMapState, startState SourceMapState, sourceMap []byte)
Source map chunks are computed in parallel for speed. Each chunk is relative to the zero state instead of being relative to the end state of the previous chunk, since it's impossible to know the end state of the previous chunk in a parallel computation.
After all chunks are computed, they are joined together in a second pass. This rewrites the first mapping in each chunk to be relative to the end state of the previous chunk.
func CanEscapeIdentifier ¶ added in v0.12.7
func QuoteForJSON ¶
Types ¶
type LineOffsetTable ¶ added in v0.8.25
type LineOffsetTable struct {
// contains filtered or unexported fields
}
func GenerateLineOffsetTables ¶ added in v0.8.25
func GenerateLineOffsetTables(contents string, approximateLineCount int32) []LineOffsetTable
type Options ¶ added in v0.8.12
type Options struct { OutputFormat config.Format RemoveWhitespace bool MangleSyntax bool ASCIIOnly bool LegalComments config.LegalComments AddSourceMappings bool Indent int ToModuleRef js_ast.Ref RuntimeRequireRef js_ast.Ref UnsupportedFeatures compat.JSFeature RequireOrImportMetaForSource func(uint32) RequireOrImportMeta // If we're writing out a source map, this table of line start indices lets // us do binary search on to figure out what line a given AST node came from LineOffsetTables []LineOffsetTable // This will be present if the input file had a source map. In that case we // want to map all the way back to the original input file(s). InputSourceMap *sourcemap.SourceMap }
type PrintResult ¶
type PrintResult struct { JS []byte // This source map chunk just contains the VLQ-encoded offsets for the "JS" // field above. It's not a full source map. The bundler will be joining many // source map chunks together to form the final source map. SourceMapChunk SourceMapChunk ExtractedLegalComments map[string]bool }
type RequireOrImportMeta ¶ added in v0.11.0
type RequireOrImportMeta struct { // CommonJS files will return the "require_*" wrapper function and an invalid // exports object reference. Lazily-initialized ESM files will return the // "init_*" wrapper function and the exports object for that file. WrapperRef js_ast.Ref ExportsRef js_ast.Ref IsWrapperAsync bool }
type SourceMapChunk ¶
type SourceMapChunk struct { Buffer []byte // This end state will be used to rewrite the start of the following source // map chunk so that the delta-encoded VLQ numbers are preserved. EndState SourceMapState // There probably isn't a source mapping at the end of the file (nor should // there be) but if we're appending another source map chunk after this one, // we'll need to know how many characters were in the last line we generated. FinalGeneratedColumn int ShouldIgnore bool }
type SourceMapState ¶
type SourceMapState struct { // This isn't stored in the source map. It's only used by the bundler to join // source map chunks together correctly. GeneratedLine int // These are stored in the source map in VLQ format. GeneratedColumn int SourceIndex int OriginalLine int OriginalColumn int }
Coordinates in source maps are stored using relative offsets for size reasons. When joining together chunks of a source map that were emitted in parallel for different parts of a file, we need to fix up the first segment of each chunk to be relative to the end of the previous chunk.