js

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Extensions = []string{
	"js", "ts", "tsx", "jsx", "d.ts", "mjs", "cjs",
}
View Source
var NewWorkspaces = utils.Cached1In1OutErr(func(searchPath string) (*Workspaces, error) {
	searchPath, err := filepath.Abs(searchPath)
	if err != nil {
		return nil, err
	}
	rootPackageJson, err := searchFirstPackageJsonWithWorkspaces(searchPath)
	if err != nil {
		return nil, err
	}
	if rootPackageJson == nil {
		return nil, nil
	}
	dirsWithAPackageJson, err := allDirsWithAPackageJson(rootPackageJson.absPath)
	workspacesMap := map[string]*packageJson{}

	for _, dir := range dirsWithAPackageJson {
		for _, ws := range rootPackageJson.workspaces() {
			rel, _ := filepath.Rel(rootPackageJson.absPath, dir)
			match, err := utils.GlobstarMatch(ws, rel)
			if err != nil {
				return nil, err
			}
			if match {
				pkgJson, err := readPackageJson(dir)
				if err != nil {
					return nil, err
				}
				workspacesMap[pkgJson.Name] = pkgJson
			}
		}
	}
	return &Workspaces{ws: workspacesMap}, nil
})

Functions

func MakeJsLanguage

func MakeJsLanguage(cfg *Config) (language.Language, error)

Types

type CompilerOptions

type CompilerOptions struct {
	BaseUrl string              `json:"baseUrl,omitempty"`
	Paths   map[string][]string `json:"paths,omitempty"`
}

type Config added in v0.17.4

type Config struct {
	TsConfigPaths bool `yaml:"tsConfigPaths"`
	Workspaces    bool `yaml:"workspaces"`
}

type ExportsCacheKey

type ExportsCacheKey string

type Language

type Language struct {
	Cfg *Config
}

func (*Language) ParseExports

func (l *Language) ParseExports(file *language.FileInfo) (*language.ExportsResult, error)

func (*Language) ParseFile

func (l *Language) ParseFile(id string) (*language.FileInfo, error)

func (*Language) ParseImports

func (l *Language) ParseImports(file *language.FileInfo) (*language.ImportsResult, error)

func (*Language) ResolvePath

func (l *Language) ResolvePath(unresolved string, dir string) (string, error)

ResolvePath resolves an unresolved import based on the dir where the import was executed.

type TsConfig

type TsConfig struct {
	CompilerOptions CompilerOptions `json:"compilerOptions,omitempty"`
	// contains filtered or unexported fields
}

func ParseTsConfig

func ParseTsConfig(filePath string) (TsConfig, error)

func (*TsConfig) ResolveFromBaseUrl added in v0.17.4

func (t *TsConfig) ResolveFromBaseUrl(unresolved string) string

func (*TsConfig) ResolveFromPaths added in v0.17.4

func (t *TsConfig) ResolveFromPaths(unresolved string) (string, error)

type Workspaces added in v0.17.4

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

func (*Workspaces) ResolveFromWorkspaces added in v0.17.4

func (w *Workspaces) ResolveFromWorkspaces(unresolved string) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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