Remarks about module import

Peter Michaux petermichaux at gmail.com
Sat Aug 23 18:44:51 PDT 2008


On Sat, Aug 23, 2008 at 5:41 PM, Kris Kowal <kris.kowal at cixar.com> wrote:
> On Mon, Aug 18, 2008 at 1:44 PM,  <ihab.awad at gmail.com> wrote:
>> Hi folks,
>> The module system proposals, especially the one here --
>>  http://wiki.ecmascript.org/doku.php?id=proposals:modules
>
> Oh, a module party!  Sorry I'm late and thanks to Peter Michaux for
> alerting me that I was missing out.  Ihab, if you recall, I met you
> and "The Mikes" last December to talk about module systems.  I really
> like the direction of this thread and thought I'd put in a couple
> cents.  A lot of the things I want from a module system have already
> been mentioned, so some of this is just a reiteration of some of the
> great ideas that have been posed; some beg distinctions.

Can you provide concrete examples (something a few lines longer than a
hello world module) which shows both the module and importer code?

[snip]

> The module scope could also contain a "module" variable that refers to
> the current module, plus "moduleScope", and "builtins" as deemed fit.
> Also, the "moduleUrl", like "__FILE__" would be handy for
> introspection.

__DIR__ has been even more handy for me so one file can load another
one at a relative position in the file system.

[snip]

>   // in <http://my.com/site.html> where the moduleRoot is the same
> as the page URL by implication:
>   import "window"; // moduleScope.window = require("window");
>   import "http://jquery.com/jquery-2.6.js"; // moduleScope.jQuery =
> require(...);
>   import "./widget.js" as widget; // moduleScope.widget =
> require("http://my.com/widget.js");
>   from "./widget.js" import Widget; // moduleScope.widget =
> require('http://my.com/widget.js').Widget;

(< 72 chars/line usually avoids wrapping.)

[snip]

Peter


More information about the Es-discuss mailing list