ES Modules: suggestions for improvement
vitteaymeric at gmail.com
Tue Jun 26 15:36:35 PDT 2012
Le 26/06/2012 20:54, Isaac Schlueter a écrit :
> The linked blog post is a very rough cut of where my thoughts are on
> the subject. Expect changes and cleanup. It does not represent a
> fully-baked (or even half-baked) idea, but more like a general
> I expect to clean it up and propose something at least half-baked to
> this list soon, incorporating some of the feedback that I've gotten
> from that blog post.
> If we can focus what we do on the things that are very
> essential to what we need, we can probably beat those odds :)
Regarding modules I don't know right now what would be the best in terms
Node.js's way is good, except the "transitive dependency issue"
mentioned in your post which in some cases indeed can cause problems.
I had some hard time to get used to this commonjs/node.js way of
separating modules which can not interact between each others, but now I
don't find it bad (even good).
What I find bad (1) is the need of VMs, let's take node.js's one, it's
calling c++ stuff, calling itself js's stuff, and at the end things are
coming back to js (with some imperfections like node.js's VM not binding
things correctly in some cases)
And what I find bad (2) is that the fact that a module could be a normal
web js code (ie not a module, the web is composed of js code, not
modules) seems to be minimized, and (3) why should we continue to load
cross-domain scripts via the <script ..> tag using onload to get the
result (normal browsers) or onreadystatechange (abnormal browser) and
then process it via global variables ? Using xhr for example (var
code=xhr_result(xxx);eval(code)), this breaks the same origin policy but
it's already broken by the capability of inserting scripts (then I am
not sure about your proposal "In Web Browsers" with <script..>).
And what I find bad (4) is the impossibility of wrapping things as I
describe here https://gist.github.com/2995641 (maybe impossible, but at
least it shows the idea, and the need) instead of being forced to
transform js code into modules and play with globals, bindings and clone
Email : avitte at jcore.fr
Web : www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com
More information about the es-discuss