Skip to content

feat: (W-006) Module system with dependency graph and lazy loading#2017

Merged
bpamiri merged 3 commits intodevelopfrom
grove/W-006-wheels-4-0-module-system-and-package-for
Apr 4, 2026
Merged

feat: (W-006) Module system with dependency graph and lazy loading#2017
bpamiri merged 3 commits intodevelopfrom
grove/W-006-wheels-4-0-module-system-and-package-for

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 4, 2026

Summary

Implements the Wheels 4.0 module system with dependency declarations, compiled dependency graph, and lazy loading (Issue #1966).

What's included

  • Dependency declarations: requires, replaces, suggests fields in package.json manifests
  • Compiled dependency graph (ModuleGraph.cfc): Kahn's algorithm topological sort, cycle detection, version constraint validation via SemVer
  • Lazy loading: Opt-in via lazy: true in manifest — defers instantiation until first access
  • Replacement handling: Packages can declare replaces to substitute for another package
  • Error isolation: Broken packages are logged and skipped — the app continues normally

Key design decisions

  • package.json over box.json: Three packages already use it, and Wheels is moving toward engine-independence from CommandBox
  • Kahn's algorithm: Naturally detects cycles, deterministic ordering, O(V+E) complexity
  • Lazy loading constraints: Only applies to packages with mixins: "none" and no middleware (mixin collection requires eager CFC instantiation)

Deferred to follow-up tasks

  • CLI commands (wheels module:search, module:install, module:create) — requires CommandBox/LuCLI integration
  • Module registry — requires external infrastructure (API server, index format)

Files changed

  • vendor/wheels/ModuleGraph.cfc — New: dependency graph building, topological sort, cycle detection
  • vendor/wheels/PackageLoader.cfc — Refactored: manifest scan → graph resolution → ordered loading
  • vendor/wheels/SemVer.cfc — Extended: wildcard * constraint support
  • vendor/wheels/tests/specs/ModuleGraphSpec.cfc — New: 12 tests for graph resolution
  • vendor/wheels/tests/specs/PackageLoaderSpec.cfc — Extended: dependency ordering, replacement, lazy loading tests
  • vendor/wheels/tests/specs/semverSpec.cfc — Extended: wildcard * tests
  • Test fixtures in vendor/wheels/tests/_assets/packages/ (8 fixture packages)
  • docs/superpowers/specs/2026-04-03-module-system-design.md — Design spec

Test plan

  • Lucee 6 (H2): 2278 pass, 0 fail, 0 error
  • Adobe 2025 (SQLite): 2274 pass, 0 fail, 0 error
  • ModuleGraph unit tests: topological sort, cycle detection, replacement, version constraints
  • PackageLoader integration tests: dependency ordering, lazy loading, error isolation

Closes #1966

🤖 Generated with Claude Code

bpamiri and others added 3 commits April 3, 2026 20:00
Addresses reviewer feedback by documenting scope decisions for all 6
capabilities from Issue #1966, manifest schema extensions (requires,
replaces, suggests), dependency graph algorithm, and lazy loading
strategy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- ModuleGraph.cfc: dependency resolution with topological sort (Kahn's
  algorithm), cycle detection, replacement handling, and suggest ordering
- PackageLoader.cfc: refactored into manifest discovery -> graph
  resolution -> ordered loading pipeline. Adds lazy loading for packages
  with lazy:true and no mixins/middleware. New getters: getExcludedPackages(),
  getLoadOrder(), getPackage(), isPackageLoaded()
- SemVer.cfc: add wildcard "*" constraint support
- Manifest schema extended with requires, replaces, suggests fields

Addresses Issue #1966 capabilities: dependency declarations, compiled
dependency graph, and lazy loading.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- ModuleGraphSpec.cfc: tests for topological sort, cycle detection,
  replacement, missing dependencies, version constraints, suggests
- PackageLoaderSpec.cfc: extended with dependency ordering, replacement,
  cycle detection, missing requirements, lazy loading tests
- semverSpec.cfc: add wildcard "*" constraint tests
- New test fixtures: depA, depB (ordering), cycleA/cycleB (cycles),
  replacer (replacement), suggestpkg (soft deps), lazypkg, missingreq

Lucee 6: 2303 pass, 0 fail, 0 error

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added docs enhancement dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code labels Apr 4, 2026
@bpamiri bpamiri merged commit 20e410a into develop Apr 4, 2026
3 checks passed
@bpamiri bpamiri deleted the grove/W-006-wheels-4-0-module-system-and-package-for branch April 4, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file docs enhancement javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wheels 4.0: Module system and package format

1 participant