Help us shape the future of Go! Take the 2026 Go Developer Survey

javascript

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTestFile

func IsTestFile(filePath string) bool

IsTestFile reports whether the given JavaScript/JSX/MJS/CJS path is a test file.

func ResolveJavaScriptImportPath

func ResolveJavaScriptImportPath(sourceFile, importPath string, suppliedFiles map[string]bool) []string

ResolveJavaScriptImportPath resolves a JavaScript import path to possible file paths

func ResolveJavaScriptProjectImports

func ResolveJavaScriptProjectImports(
	absPath string,
	filePath string,
	ext string,
	suppliedFiles map[string]bool,
	contentReader vcs.ContentReader,
) ([]string, error)

Types

type ExternalImport

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

ExternalImport represents an external npm package import

func (ExternalImport) IsTypeOnly

func (e ExternalImport) IsTypeOnly() bool

func (ExternalImport) Path

func (e ExternalImport) Path() string

type InternalImport

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

InternalImport represents an internal project file import (./, ../)

func (InternalImport) IsTypeOnly

func (i InternalImport) IsTypeOnly() bool

func (InternalImport) Path

func (i InternalImport) Path() string

type JavaScriptImport

type JavaScriptImport interface {
	Path() string
	IsTypeOnly() bool
}

JavaScriptImport represents an import in a JavaScript/JSX file (type-only imports are always false for standard JavaScript).

func JavaScriptImports

func JavaScriptImports(filePath string) ([]JavaScriptImport, error)

JavaScriptImports parses a JavaScript/JSX file and returns its imports

func ParseJavaScriptImports

func ParseJavaScriptImports(sourceCode []byte, isJSX bool) ([]JavaScriptImport, error)

ParseJavaScriptImports parses JavaScript source code and extracts imports

type NodeBuiltinImport

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

NodeBuiltinImport represents a Node.js built-in module import (fs, path, http, node:fs)

func (NodeBuiltinImport) IsTypeOnly

func (n NodeBuiltinImport) IsTypeOnly() bool

func (NodeBuiltinImport) Path

func (n NodeBuiltinImport) Path() string

type Provider added in v0.27.0

type Provider struct{}

func (Provider) Extensions added in v0.27.0

func (Provider) Extensions() []string

func (Provider) IsTestFile added in v0.27.0

func (Provider) IsTestFile(filePath string, _ vcs.ContentReader) bool

func (Provider) Maturity added in v0.27.0

func (Provider) Maturity() moduleapi.MaturityLevel

func (Provider) Name added in v0.27.0

func (Provider) Name() string

func (Provider) NewResolver added in v0.27.0

func (Provider) NewResolver(ctx *moduleapi.Context, contentReader vcs.ContentReader) moduleapi.Resolver

Jump to

Keyboard shortcuts

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