Documentation
¶
Overview ¶
Copyright © 2026 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2026 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2026 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Package resolve provides interfaces and utilities for import map resolution.
Copyright © 2026 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2026 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- func FindWorkspaceRoot(fs fs.FileSystem, startDir string) string
- func SplitPackageName(pkg string) (name, scope string)
- func ToWebPath(rootDir, fullPath string) string
- type DependencyGraph
- func (g *DependencyGraph) AddDependency(pkg, dep string)
- func (g *DependencyGraph) AddWorkspacePackage(name string)
- func (g *DependencyGraph) Clone() *DependencyGraph
- func (g *DependencyGraph) Dependents(pkg string) []string
- func (g *DependencyGraph) IsWorkspacePackage(name string) bool
- func (g *DependencyGraph) PackagePath(pkg string) string
- func (g *DependencyGraph) RemovePackage(pkg string) []string
- func (g *DependencyGraph) ScopeKey(pkg string) string
- func (g *DependencyGraph) SetPackagePath(pkg, path string)
- func (g *DependencyGraph) SetScopeKey(pkg, scopeKey string)
- func (g *DependencyGraph) TransitiveDependents(pkg string) []string
- type IncrementalResult
- type IncrementalUpdate
- type Logger
- type Resolver
- type Template
- type WorkspacePackage
Constants ¶
const DefaultLocalTemplate = "/node_modules/{package}/{path}"
DefaultLocalTemplate is the default template for local resolution.
Variables ¶
This section is empty.
Functions ¶
func FindWorkspaceRoot ¶
func FindWorkspaceRoot(fs fs.FileSystem, startDir string) string
FindWorkspaceRoot walks up the directory tree to find the workspace root. Returns the directory containing node_modules, workspace configuration, or .git.
func SplitPackageName ¶
SplitPackageName splits a package name into name and scope. For "@scope/name" returns ("name", "scope"). For "name" returns ("name", "").
Types ¶
type DependencyGraph ¶ added in v0.0.2
type DependencyGraph struct {
// contains filtered or unexported fields
}
DependencyGraph tracks package dependencies for incremental updates. Built during resolution and cached for efficient dependent discovery.
func NewDependencyGraph ¶ added in v0.0.2
func NewDependencyGraph() *DependencyGraph
NewDependencyGraph creates a new empty dependency graph.
func (*DependencyGraph) AddDependency ¶ added in v0.0.2
func (g *DependencyGraph) AddDependency(pkg, dep string)
AddDependency records that pkg depends on dep. Updates both dependsOn and dependents maps.
func (*DependencyGraph) AddWorkspacePackage ¶ added in v0.0.2
func (g *DependencyGraph) AddWorkspacePackage(name string)
AddWorkspacePackage marks a package as a workspace package.
func (*DependencyGraph) Clone ¶ added in v0.0.2
func (g *DependencyGraph) Clone() *DependencyGraph
Clone creates a deep copy of the dependency graph.
func (*DependencyGraph) Dependents ¶ added in v0.0.2
func (g *DependencyGraph) Dependents(pkg string) []string
Dependents returns all packages that directly depend on pkg.
func (*DependencyGraph) IsWorkspacePackage ¶ added in v0.0.2
func (g *DependencyGraph) IsWorkspacePackage(name string) bool
IsWorkspacePackage returns true if the package is a workspace package.
func (*DependencyGraph) PackagePath ¶ added in v0.0.2
func (g *DependencyGraph) PackagePath(pkg string) string
PackagePath returns the filesystem path for a package, or empty string if not found.
func (*DependencyGraph) RemovePackage ¶ added in v0.0.2
func (g *DependencyGraph) RemovePackage(pkg string) []string
RemovePackage removes a package and all its edges from the graph. Returns the packages that were dependents of the removed package.
func (*DependencyGraph) ScopeKey ¶ added in v0.0.2
func (g *DependencyGraph) ScopeKey(pkg string) string
ScopeKey returns the scope key for a package, or empty string if not found.
func (*DependencyGraph) SetPackagePath ¶ added in v0.0.2
func (g *DependencyGraph) SetPackagePath(pkg, path string)
SetPackagePath records the filesystem path for a package.
func (*DependencyGraph) SetScopeKey ¶ added in v0.0.2
func (g *DependencyGraph) SetScopeKey(pkg, scopeKey string)
SetScopeKey records the import map scope key for a package.
func (*DependencyGraph) TransitiveDependents ¶ added in v0.0.2
func (g *DependencyGraph) TransitiveDependents(pkg string) []string
TransitiveDependents returns all packages that directly or indirectly depend on pkg. Uses breadth-first traversal to find all dependents.
type IncrementalResult ¶ added in v0.0.2
type IncrementalResult struct {
// ImportMap is the resolved import map.
ImportMap *importmap.ImportMap
// DependencyGraph tracks package dependencies for future incremental updates.
DependencyGraph *DependencyGraph
}
IncrementalResult contains both the new import map and dependency graph.
type IncrementalUpdate ¶ added in v0.0.2
type IncrementalUpdate struct {
// ChangedPackages lists packages whose package.json files changed.
// Can include both workspace packages and node_modules packages.
// Use the package name (e.g., "@myorg/core" or "lit").
ChangedPackages []string
// PreviousMap is the import map to update incrementally.
// If nil, a full resolution is performed.
PreviousMap *importmap.ImportMap
// PreviousGraph is the dependency graph from the previous resolution.
// If nil, dependents cannot be computed and a full resolution is used.
PreviousGraph *DependencyGraph
}
IncrementalUpdate describes which packages changed for incremental resolution.
type Resolver ¶
type Resolver interface {
// Resolve generates an ImportMap for a project rooted at the given directory.
Resolve(rootDir string) (*importmap.ImportMap, error)
}
Resolver generates import map entries for packages.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template represents a URL template with variable placeholders. Supported variables:
- {package} - Full package name (e.g., "@scope/name" or "name")
- {name} - Package name without scope
- {scope} - Scope without @ prefix (empty for unscoped)
- {version} - Resolved version (for CDN resolution)
- {path} - Relative path within the package
func ParseTemplate ¶
ParseTemplate parses a URL template pattern.
func (*Template) HasVersion ¶
HasVersion returns true if the template contains a {version} variable. Templates with version variables require lockfile resolution (CDN mode).
type WorkspacePackage ¶
type WorkspacePackage struct {
Name string // Package name from package.json
Path string // Absolute path to package directory
}
WorkspacePackage represents a package in a monorepo workspace.
func DiscoverWorkspacePackages ¶ added in v0.0.2
func DiscoverWorkspacePackages(fsys fs.FileSystem, rootDir string) ([]WorkspacePackage, error)
DiscoverWorkspacePackages finds all workspace packages based on the workspaces field in the root package.json. Returns nil if no workspaces are defined.