package bundler

import "github.com/evanw/esbuild/internal/bundler"

Index

Functions

func DefaultExtensionToLoaderMap

func DefaultExtensionToLoaderMap() map[string]config.Loader

func HashForFileName

func HashForFileName(hashBytes []byte) string

func PathRelativeToOutbase

func PathRelativeToOutbase(
	inputFile *graph.InputFile,
	options *config.Options,
	fs fs.FS,
	avoidIndex bool,
	customFilePath string,
) (relDir string, baseName string)

Returns the path of this file relative to "outbase", which is then ready to be joined with the absolute output directory path. The directory and name components are returned separately for convenience.

func ResolveFailureErrorTextSuggestionNotes

func ResolveFailureErrorTextSuggestionNotes(
	res *resolver.Resolver,
	path string,
	kind ast.ImportKind,
	pluginName string,
	fs fs.FS,
	absResolveDir string,
	platform config.Platform,
	originatingFilePath string,
	modifiedImportPath string,
) (text string, suggestion string, notes []logger.MsgData)

func RunOnResolvePlugins

func RunOnResolvePlugins(
	plugins []config.Plugin,
	res *resolver.Resolver,
	log logger.Log,
	fs fs.FS,
	fsCache *cache.FSCache,
	importSource *logger.Source,
	importPathRange logger.Range,
	importer logger.Path,
	path string,
	importAttributes logger.ImportAttributes,
	kind ast.ImportKind,
	absResolveDir string,
	pluginData interface{},
) (*resolver.ResolveResult, bool, resolver.DebugMeta)

Types

type Bundle

type Bundle struct {
	// contains filtered or unexported fields
}

func ScanBundle

func ScanBundle(
	call config.APICall,
	log logger.Log,
	fs fs.FS,
	caches *cache.CacheSet,
	entryPoints []EntryPoint,
	options config.Options,
	timer *helpers.Timer,
) Bundle

This creates a bundle by scanning over the whole module graph starting from the entry points until all modules are reached. Each module has some number of import paths which are resolved to module identifiers (i.e. "onResolve" in the plugin API). Each unique module identifier is loaded once (i.e. "onLoad" in the plugin API).

func (*Bundle) Compile

func (b *Bundle) Compile(log logger.Log, timer *helpers.Timer, mangleCache map[string]interface{}, link Linker) ([]graph.OutputFile, string)

type DataForSourceMap

type DataForSourceMap struct {
	// This data is for the printer. It maps from byte offsets in the file (which
	// are stored at every AST node) to UTF-16 column offsets (required by source
	// maps).
	LineOffsetTables []sourcemap.LineOffsetTable

	// This contains the quoted contents of the original source file. It's what
	// needs to be embedded in the "sourcesContent" array in the final source
	// map. Quoting is precomputed because it's somewhat expensive.
	QuotedContents [][]byte
}

This is data related to source maps. It's computed in parallel with linking and must be ready by the time printing happens. This is beneficial because it is somewhat expensive to produce.

type EntryPoint

type EntryPoint struct {
	InputPath                string
	OutputPath               string
	InputPathInFileNamespace bool
}

type Linker

type Linker func(
	options *config.Options,
	timer *helpers.Timer,
	log logger.Log,
	fs fs.FS,
	res *resolver.Resolver,
	inputFiles []graph.InputFile,
	entryPoints []graph.EntryPoint,
	uniqueKeyPrefix string,
	reachableFiles []uint32,
	dataForSourceMaps func() []DataForSourceMap,
) []graph.OutputFile

Source Files

bundler.go

Version
v0.25.0 (latest)
Published
Feb 8, 2025
Platform
linux/amd64
Imports
30 packages
Last checked
4 days ago

Tools for package owners.