This document records what AFFON currently supports in module loading and external package support.
AFFON reserves the affon:* namespace for runtime-provided modules.
affon:*specifiers refer to built-in modules shipped by the runtime.- Public built-ins include modules such as
affon:compute,affon:nn,affon:ops,affon:optim,affon:dataset, andaffon:checkpoint. - External packages should not use the
affon:*namespace.
AFFON supports external packages as ESM modules.
- normal ESM
importsyntax - bare package imports resolved through a
node_modules-compatible lookup model - relative imports and package-to-package imports within the supported subset
AFFON does not currently promise general Node compatibility.
AFFON currently resolves module paths like this:
affon:*specifiers resolve to built-in runtime modules- relative specifiers such as
./xand../xresolve from the importing file - bare package specifiers resolve through a
node_modules-compatible lookup
For a bare package import, AFFON starts from the importing file's directory.
It then checks directories in this order:
<importer dir>/node_modules/<package><parent dir>/node_modules/<package>- the next parent directory's
node_modules/<package> - continue upward until the filesystem root
The first match found in that upward walk is used.
This means nested dependencies follow the installed directory layout.
Example:
app/
node_modules/
a/
index.ts
node_modules/
c/
b/
index.ts
node_modules/
c/If a/index.ts imports c, AFFON resolves a/node_modules/c.
If b/index.ts imports c, AFFON resolves b/node_modules/c.
So different packages can resolve different installed copies of the same dependency, depending on where the import comes from.
A top-level package copy is used only when the upward walk does not find a closer nested copy first.
For package entry resolution, AFFON currently honors this subset:
exports["."].importexports["."]- top-level string
exports mainas fallback
CommonJS packages are not supported:
type: "commonjs"is rejected
| Case | Status |
|---|---|
package.json exports["."].import -> .ts entry |
supported |
package.json main -> .ts entry |
supported |
| nested relative imports inside a package | supported |
package importing built-in affon:* modules |
supported |
package-to-package bare imports inside node_modules |
supported |
subpath imports like pkg/subpath when the package layout resolves directly |
supported |
exports condition object with import present alongside other keys |
supported |
| isolated module-private bindings do not leak into importer scope | supported |
named import aliasing (import { x as y }) |
supported |
default exports (export default ...) with default import |
supported |
namespace imports (import * as ns from ...) |
supported |
combined default + named import syntax (import x, { y } from ...) |
supported |
selective re-exports (export { x as y } from ...) |
supported |
star re-exports (export * from ...) |
supported |
| direct unsupported CommonJS rejection | supported |
require(...) |
out of scope |
| Node built-in module compatibility | out of scope |
| Node native addon compatibility | out of scope |
| full spec-level ESM semantics | not implemented |
| live bindings | not implemented |
| full cyclic-module semantics | not implemented |
| full conditional-exports engine | not implemented |
exports maps where subpath resolution must be enforced rather than falling through to direct files |
not verified |
more complex conditional exports selection logic |
not verified |
default + namespace import syntax (import x, * as ns from ...) |
not implemented |