Releases: bennypowers/mappa
v0.0.7
What's Changed
- fix: preserve trailing slashes in nested dep URLs by @bennypowers in #43
Full Changelog: v0.0.6...v0.0.7
v0.0.6
What's Changed
- fix: emit trailing-slash entries for wildcard exports with target suffixes by @bennypowers in #41
Full Changelog: v0.0.5...v0.0.6
v0.0.5
New Features
Workspace subdirectory resolution
Two new resolver options make it easier to generate import maps when serving a
workspace subdirectory package.
WithPathBase(dir)
Rebases workspace package paths relative to the given directory instead of the
workspace root. Paths under node_modules/ are unaffected.
resolver := local.New(fs, logger).WithPathBase("/repo/examples/kitchen-sink")
result, _ := resolver.Resolve("/repo")
// "@examples/kitchen-sink/" -> "/" (rebased)
// "lit" -> "/node_modules/lit/index.js" (unchanged)CLI: mappa generate --path-base ./examples/kitchen-sink
JS: resolve(rootDir, { pathBase: "examples/kitchen-sink" })
WithPackageDeps(dir)
Limits dependency collection to only the dependencies listed in the
package.json at the given directory. Without this, workspace resolution
collects dependencies from every workspace package, which may produce warnings
for irrelevant packages.
resolver := local.New(fs, logger).WithPackageDeps("/repo/packages/core")
result, _ := resolver.Resolve("/repo")
// Only core's dependencies are resolved; other workspace packages'
// dependencies (e.g., lodash from a sibling tools package) are skipped.CLI: mappa generate --package-deps ./packages/core
JS: resolve(rootDir, { packageDeps: "packages/core" })
Both options accept relative paths, which are resolved relative to the
resolution root directory.
Bug Fixes
- Fix a race condition in
ResolveIncrementalwhere concurrent goroutines
could write to the import map without mutex protection when re-adding
workspace packages.
What's Changed
- feat: support workspace subdirectory resolution with WithPathBase and WithPackageDeps by @bennypowers in #39
Full Changelog: v0.0.4...v0.0.5
v0.0.4
Features
- npm package distribution: Published
@pwrs/mappanpm package with both CLI and JavaScript API, enabling usage as a dependency and command-line tool (#33) - Import map validation: Added
validatecommand for linting import map JSON files (#29) - Package filtering: Added
--excludeflag togeneratecommand for filtering packages from the output (#31) - HTML injection: Added
injectcommand to automatically insert importmap into HTML documents (#25) - Browser support: Added WASM/browser bundle for client-side usage (#26)
Fixes
- CDN resolver: Excluded packages from CDN resolution including transitive dependencies (#36)
- CDN performance: Bounded goroutine fan-out and added per-request timeout to prevent resource exhaustion (#37)
- Trace output: Fixed output of imports and scopes in single and batch modes (#21)
- Dependency handling: Fixed handling of transitive dependencies in trace (#23)
- Spec compliance: Improved spec compliance and expanded test coverage (#28)
Documentation
- Added Gentoo installation documentation
Other
- Updated CI/CD workflows with go-release-workflows
What's Changed
- fix(trace): output imports and scopes in single and batch modes by @bennypowers in #21
- fix(trace): handle transitive dependencies by @bennypowers in #23
- feat(inject): add inject command to automatically add importmap to HTML by @bennypowers in #25
- feat: wasm/browser bundle by @bennypowers in #26
- feat(web): add npm package search to demo by @bennypowers in #27
- fix: spec compliance, test coverage, and scope optimization by @bennypowers in #28
- feat(validate): add validate command for import map linting by @bennypowers in #29
- feat(generate): add --exclude flag to filter packages by @bennypowers in #31
- feat: publish @pwrs/mappa npm package with CLI and JS API by @bennypowers in #33
- fix(cdn): exclude packages from CDN resolver including transitive deps by @bennypowers in #36
- fix(cdn): bound goroutine fan-out and add per-request timeout by @bennypowers in #37
Full Changelog: v0.0.3...v0.0.4
v0.0.3
This release transforms mappa trace into a powerful tool for generating minimal, usage-based import maps. Instead of including all exports from all dependencies, trace now outputs import maps containing only the specifiers actually used in your HTML files.
New Features
Trace outputs import maps (#15)
The trace command now outputs import maps by default, resolving traced bare specifiers to their paths:
# Before: output raw specifiers list
mappa trace index.html
# {"bare_specifiers": ["lit"], "packages": ["lit"], ...}
# After: output minimal import map
mappa trace index.html
# {"imports": {"lit": "/node_modules/lit/index.js"}}New flags:
--template- URL template for resolved paths (same asgenerate)--format json(default) - output import map JSON--format html- output<script type="importmap">tag--format specifiers- original behavior for debugging
Batch mode with NDJSON output (#16)
Trace many files efficiently in a single invocation:
# Multiple file arguments
mappa trace file1.html file2.html file3.html
# Glob pattern support (uses doublestar for ** matching)
mappa trace --glob "_site/**/*.html"
# Control parallelism (defaults to number of CPUs)
mappa trace --glob "_site/**/*.html" -j 8Batch mode outputs NDJSON (one JSON object per line):
{"file":"_site/index.html","imports":{"lit":"/node_modules/lit/index.js"}}
{"file":"_site/about.html","imports":{"lit":"/node_modules/lit/index.js"}}
Performance improvement: tracing 750 files drops from ~22s (750 process startups) to <1s (single process, reused parsers, parallel workers).
Version command
New version command with JSON output support:
mappa version
mappa version -f jsonBreaking Changes
mappa tracedefault output format changed from specifiers list to import map JSON- Use
--format specifiersto restore the previous behavior
What's Changed
- feat: version command by @bennypowers in #17
- fix(trace): output import maps by @bennypowers in #18
- feat(trace): batch mode by @bennypowers in #19
Full Changelog: v0.0.2...v0.0.3
v0.0.2
This release adds incremental import map regeneration, enabling efficient hot-reload in development servers. Instead of regenerating the entire import map on every file change, mappa can now recompute only the affected packages and their dependents.
New Features
Incremental Resolution (#14)
New methods for incremental import map updates:
ResolveWithGraph()- Full resolution that returns a dependency graph for future incremental updatesResolveIncremental()- Only re-resolves changed packages and their transitive dependents
resolver := local.New(fs, logger).WithPackageCache(cache)
// Initial resolution
result, _ := resolver.ResolveWithGraph("/project")
// When a package changes, only update affected entries
updated, _ := resolver.ResolveIncremental("/project", resolve.IncrementalUpdate{
ChangedPackages: []string{"lit"},
PreviousMap: result.ImportMap,
PreviousGraph: result.DependencyGraph,
})Auto-discover Workspace Packages (#13)
The resolver now automatically discovers workspace packages from the workspaces field in package.json. Supports both array and object formats. Explicit workspace configuration via WithWorkspacePackages() overrides auto-discovery.
Export Conditions (#11)
New --conditions CLI flag and WithConditions() builder method to specify export condition priority when resolving package.json exports.
mappa --conditions production,browser,import,defaultresolver := local.New(fs, nil).WithConditions([]string{"production", "browser", "import", "default"})Import Validation in Trace (#12)
The trace command now validates imports and reports issues:
- Imports from transitive dependencies (not declared in package.json)
- Imports from devDependencies in production code
- Missing dependencies
Output includes source file locations for each issue.
Package.json Caching (#7)
New packagejson.Cache interface and MemoryCache implementation for reusing parsed package.json data across resolution calls. Improves performance for monorepos and hot-reload scenarios.
cache := packagejson.NewMemoryCache()
resolver := local.New(fs, nil).WithPackageCache(cache)Improvements
Better Warnings (#9)
The resolver now warns when a package has no explicit exports and no main field, which means only subpath imports will work (bare specifier imports will fail).
What's Changed
- perf: cache package.json files by @bennypowers in #7
- feat: warn when a package has no main or default export by @bennypowers in #9
- chore: ci by @bennypowers in #10
- feat: support export conditions by @bennypowers in #11
- feat: warn when trace finds imports from transitive dependencies by @bennypowers in #12
- feat: auto-discover workspace packages by @bennypowers in #13
- feat: incremental updates by @bennypowers in #14
New Contributors
- @bennypowers made their first contribution in #7
Full Changelog: v0.0.1...v0.0.2
v0.0.1
Initial release of mappa, a high-performance import map generator for ES modules.
Overview
Mappa generates import maps from package.json dependencies, enabling browsers to resolve bare module specifiers like import { html } from 'lit' to actual URLs. Written in Go for speed, mappa generates import maps ~72x faster than comparable JavaScript-based tools.
Features
- Local resolution - Generate import maps pointing to
node_modulespaths - Custom URL templates - Use dynamic templates with
{package},{path},{name}, and{scope}variables for flexible asset paths - Exports field support - Full support for package.json
exportsincluding subpath and wildcard patterns - Automatic scopes - Generates scopes for transitive dependencies to handle version conflicts
- Input map merging - Combine generated maps with manual overrides
- Parallel resolution - Fast dependency resolution using bounded concurrency
- HTML output - Output maps as
<script type="importmap">tags for direct injection - Module tracing - Trace HTML files to discover module imports using tree-sitter parsing
Installation
go install bennypowers.dev/mappa@v0.0.1Quick Start
# Generate import map from package.json
mappa generate
# Custom asset path template
mappa generate --template "/assets/packages/{package}/{path}"
# Output as HTML script tag
mappa generate --format html
# Trace imports from HTML files
mappa trace index.htmlPerformance
| Tool | Time |
|---|---|
| mappa | 3.2ms ± 0.2ms |
| @jspm/generator | 230ms ± 6ms |
See docs/benchmarks for detailed methodology and results.
Documentation
Full usage guide, CLI reference, and integration examples are available in the README.
License
GPLv3
Full Changelog: https://github.com/bennypowers/mappa/commits/v0.0.1