A module is source that the host supplies under a name. import makes that
name available; export chooses declarations that other modules may use. The
language never reads local files, fetches URLs, or installs packages while
linking, so the program’s source inputs are explicit and diagnostics can retain
them.
Import one public function
Run this fixture. Its main.kj imports counters; select counters.kj in
Files to inspect the supplied module. Its output is 2 followed by 5.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
import counters; does not copy names into the entry module’s unqualified
namespace: call an exported function as counters.name(...). Types, traits,
and top-level bindings can also be exported. Imported constructors and types
remain qualified, such as shapes.Ball { radius: 0.3 }. Put mutable imported
state behind an exported function so its defining module owns the update.
The entry module is main; builtin is the automatic standard module. Both
names are reserved. An import of an absent source or access to a private name
produces a diagnostic.
Link in a stable order
Dependencies initialize before their importers, and a module imported more than once is loaded once. Top-level statements initialize runtime state; functions and types declare the names available to that state. Systems in imported modules also run before importer systems. Import cycles are rejected.
Edit exercise
In counters.kj, change self.value = self.value + by to
self.value = self.value + by + 1, compile, and expect the main fixture’s
second output to change from 5 to 6. Remove export new_counter;
and compile again: the main module should receive a diagnostic for
accessing a non-public name.
Module names are part of source identity. Package discovery, version resolution, filesystem search paths, aliases, selective imports, and live module replacement are not implemented. The language reference defines linking and initialization; see language design for future directions.
When embedding from Rust, pass the entry source and named module map to
compile. The
SDK development guide covers the
native iteration workflow.