Sky Module System ================= This document describes the Sky module system. Overview -------- The Sky module system is based on the ``import`` element. In its most basic form, you import a module as follows: ```html ``` As these ``import`` elements are inserted into a module's element tree, the module's list of outstanding dependencies grows. When an imported module completes, it is removed from the importing module's list of outstanding dependencies. Before compiling script or inserting an element that is not already registered, the parser waits until the list of outstanding dependencies is empty. After the parser has finished parsing, the module waits until its list of outstanding dependencies is empty before marking itself complete. The ``as`` attribute on the ``import`` element binds a name to the imported module: ```html ``` Each module implicitly imports the [Built-In Elements Module](builtins.md). When a module imports another, and the ``import`` element has no ``as`` attribute, then any elements registered in that module whose tag names do not begin with an underscore must be registered on the importing module. (If multiple elements are registered with the same name, that name gets marked as dead for that module and all the registrations for that name are discarded.) TODO(ianh): decide if elements imported with "as" should be imported but with the "as" name prefixed, as in ```` Module API ---------- Each module consists of one or more libraries. The first library in a module is the *element tree library*, which consists of the following code for a Sky module: ```dart import 'dart:sky'; final Module module = new Module(); ``` ...and the following code for a Sky application: ```dart import 'dart:sky'; final Module module = new Application(); ``` The ``