Static Module Resolution

Kevin Smith khs4473 at gmail.com
Sun Jul 1 18:37:25 PDT 2012


>
> What is needed is more of an export adapter than watering down of import
> side syntax. In the Node world it is quite common to find files that server
> nothing more than the role of some kind of adapter, that simply includes a
> bunch of stuff and exports it directly with no modification except names.
> There's no reason the same concept doesn't hold for requiring stuff on the
> one end and exporting it using es6 modules out the other end.


Good - something like this, then?

    // adapter.js
    export var legacy1 = require("./legacy1"),
      legacy2 = require("./legacy2"),
      legacy3 = require("./legacy3");

    // program.js
    import { legacy1, legacy2, legacy3 } from "adapter.js";

Generally then, using this strategy we'd only be able to "import" directly
from ES6 modules.  For pre-ES6 modules, we'd have to use require.

Is that right?

- Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120701/aa3c2731/attachment.html>


More information about the es-discuss mailing list