Feed back and proposal for modules: allow importing ES5 files
Alex Russell
alex at dojotoolkit.org
Mon Sep 24 08:30:13 PDT 2012
I think module loaders would, indeed help, although as you point out,
you're gonna need some sort of transformation step and we don't provide an
AST to work against. You might need something like Traceur's front-end or
esprima to get started on a reliable transform pass. But yeah, doable.
On Mon, Sep 24, 2012 at 4:08 PM, Claus Reinke <claus.reinke at talk21.com>wrote:
>
> Right. What I'm suggesting isn't that you'll be able to prevent the global
>> from being augmented, rather that if your goal is to take an *already well
>> behaved* library and wrap it with modules, that's possible.
>>
>
> Aren't Module Loader Translation hooks meant to help with this?
>
> http://wiki.ecmascript.org/**doku.php?id=harmony:module_**
> loaders#translation_semantics<http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders#translation_semantics>
>
> Naïve idea: fetch the code, then add exports before evaluating the
> code as a local module scope.
>
> Though this would require parameterizing the Loader with some
> configuration data (export $ from jquery, export {f,g,x} from
> anotherES5utils, ..). Which seems to call for interaction between
> fetch and translate hooks, and possibly even between import
> declarations and loader hooks (how does the loader hook get
> to know which exports to add to an ES5 script, for a given import
> declaration?).
>
> RequireJS has some experience with wrapping non-modules
> via configuration options.
>
> https://github.com/jrburke/**requirejs/wiki/Upgrading-to-**
> RequireJS-2.0#wiki-shim<https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0#wiki-shim>
>
> Without a prototype implementation of modules as an executable
> spec, it will be difficult to find such edge cases and check how well
> they are covered in the existing semi-formal spec.
>
> Claus
>
>
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120924/00059fbd/attachment.html>
More information about the es-discuss
mailing list