resolver

package
v0.7.15 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BrowserFalseNamespace = "empty"

This namespace is used when a module has been disabled by being mapped to "false" using the "browser" field of "package.json".

Variables

View Source
var BuiltInNodeModules = map[string]bool{
	"assert":         true,
	"async_hooks":    true,
	"buffer":         true,
	"child_process":  true,
	"cluster":        true,
	"console":        true,
	"constants":      true,
	"crypto":         true,
	"dgram":          true,
	"dns":            true,
	"domain":         true,
	"events":         true,
	"fs":             true,
	"http":           true,
	"http2":          true,
	"https":          true,
	"inspector":      true,
	"module":         true,
	"net":            true,
	"os":             true,
	"path":           true,
	"perf_hooks":     true,
	"process":        true,
	"punycode":       true,
	"querystring":    true,
	"readline":       true,
	"repl":           true,
	"stream":         true,
	"string_decoder": true,
	"sys":            true,
	"timers":         true,
	"tls":            true,
	"trace_events":   true,
	"tty":            true,
	"url":            true,
	"util":           true,
	"v8":             true,
	"vm":             true,
	"worker_threads": true,
	"zlib":           true,
}

Functions

func IsPackagePath added in v0.5.20

func IsPackagePath(path string) bool

Package paths are loaded from a "node_modules" directory. Non-package paths are relative or absolute paths.

Types

type PathPair added in v0.7.0

type PathPair struct {
	// Either secondary will be empty, or primary will be "module" and secondary
	// will be "main"
	Primary   logger.Path
	Secondary logger.Path
}

Path resolution is a mess. One tricky issue is the "module" override for the "main" field in "package.json" files. Bundlers generally prefer "module" over "main" but that breaks packages that export a function in "main" for use with "require()", since resolving to "module" means an object will be returned. We attempt to handle this automatically by having import statements resolve to "module" but switch that out later for "main" if "require()" is used too.

func (*PathPair) HasSecondary added in v0.7.0

func (pp *PathPair) HasSecondary() bool

type ResolveResult added in v0.4.6

type ResolveResult struct {
	PathPair   PathPair
	IsExternal bool

	// If not empty, these should override the default values
	JSXFactory  []string // Default if empty: "React.createElement"
	JSXFragment []string // Default if empty: "React.Fragment"

	// If true, any ES6 imports to this file can be considered to have no side
	// effects. This means they should be removed if unused.
	IgnoreIfUnused bool

	// If true, the class field transform should use Object.defineProperty().
	StrictClassFields bool

	// If true, unused imports are retained in TypeScript code. This matches the
	// behavior of the "importsNotUsedAsValues" field in "tsconfig.json" when the
	// value is not "remove".
	PreserveUnusedImportsTS bool

	// This is true if the file is inside a "node_modules" directory
	SuppressWarningsAboutWeirdCode bool
}

type Resolver

type Resolver interface {
	Resolve(sourceDir string, importPath string, kind ast.ImportKind) *ResolveResult
	ResolveAbs(absPath string) *ResolveResult
	PrettyPath(path logger.Path) string
}

func NewResolver

func NewResolver(fs fs.FS, log logger.Log, options config.Options) Resolver

Jump to

Keyboard shortcuts

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