Skip to main content

Module packages

Module packages 

Source
Expand description

Packaging slice 2a (#2223): loading a project’s path dependencies into one compile.

apply_graph runs once, right after parsing, on both the build’s and the editor’s pipeline. It resolves the project’s package graph ([bynk_project::resolve_graph]), then rewrites the parsed files so every later phase sees one flat set of units, as it always has:

  • each dependency file is tagged with its package, and its unit gets the canonical name source can’t spell ([bynk_project::PackageId::canonical], decision C) — currency in acme/money becomes $acme_money.currency;
  • every uses/consumes target is resolved against its own file’s package: money.currency, where money is one of that package’s aliases, becomes the dependency’s canonical name, and a dependency’s reference to its own unit becomes its own canonical name;
  • a whole-unit consumes of a dependency unit keeps the spelling source wrote as its alias, so money.fx.Rates still names the capability;
  • only exported units cross a package boundary (decision D), only the units a consumer actually reaches are kept (P-5), and a dependency’s contexts and suites are never compiled (ADR 0542). A reached dependency adapter’s npm requires fold into the build with the project’s own (#2255).

The root project’s own units and the first-party units keep their names, so a project without dependencies compiles byte-identically.

Constants§

ALIAS_SHADOWS_UNIT
An alias is also the first segment of one of the project’s own units.
DEV_DEPENDENCY_IN_SOURCE
#2240: a non-suite unit reaches a [dev-dependencies] alias.
UNAPPROVED_REQUIREMENT
#2296: a reached adapter of a fetched package requires an npm package the project hasn’t approved in bynk.lock.
UNIT_NOT_EXPORTED
A consumer reaches a unit its dependency doesn’t export.
UNKNOWN_UNIT
A consumer reaches a unit its dependency doesn’t declare.
UNSUPPORTED_IN_DEPENDENCY
A dependency declares an asset or an embed, which needs a per-package namespace not yet designed.

Functions§

apply_graph
Resolve the package graph of the project at project_root and fold the dependencies’ files in parsed into the compile. A project with no dependencies is untouched.