Re: Modifying ES6 module exports

2015-12-24 Thread Isiah Meadows
Actually, Babel defers circular dependencies to the underlying module resolver, so most likely Node/Browserify/etc. is where you're getting that, as that's actually intentional, documented behavior in Node. On Wed, Dec 23, 2015, 20:24 /#!/JoePea wrote: > Cool, thanks guys. Indeed that appears to

Re: Modifying ES6 module exports

2015-12-23 Thread /#!/JoePea
Cool, thanks guys. Indeed that appears to have been my problem. On Tue, Dec 22, 2015 at 10:59 PM, Logan Smyth wrote: > The `{}` shouldn't be from Babel, it has handled all circular dependency > cases as far as I'm aware. I'm curious to know what the end cause of this > issue is, but this isn't re

Re: Modifying ES6 module exports

2015-12-22 Thread Logan Smyth
The `{}` shouldn't be from Babel, it has handled all circular dependency cases as far as I'm aware. I'm curious to know what the end cause of this issue is, but this isn't really the right discussion forum for it. Joe, if you do end up making a simplified example that can be tested, I'd be happy to

Re: Modifying ES6 module exports

2015-12-22 Thread Caridy Patino
circular dependencies will work nicely with declarations, not so much with expressions because the code has to be evaluated to set those bindings. This, of course, is not a problem if you're not invoking some initialization when evaluating the body of the module. all in all, that's what you're

Re: Modifying ES6 module exports

2015-12-22 Thread Ryan Dunckel
Related: http://www.2ality.com/2015/07/es6-module-exports.html?m=1 On Tue, Dec 22, 2015 at 4:02 AM /#!/JoePea wrote: > In my case I was using Webpack+babel-loader. I guess that makes sense, > about the run-time dependencies. After solving the problem by wrapping > the module logic for A and B in

Re: Modifying ES6 module exports

2015-12-22 Thread /#!/JoePea
In my case I was using Webpack+babel-loader. I guess that makes sense, about the run-time dependencies. After solving the problem by wrapping the module logic for A and B in functions then calling those functions in main.js. I then encountered another problem: package C imports the default from pac

Re: Modifying ES6 module exports

2015-12-21 Thread Logan Smyth
To start, an object is definitely not what I'd expect. The core thing to remember with ES6 modules is that while imports are live bindings, you still need to write your code in such a way that it has no run-time circular dependencies. In your specific examples, you are importing `A` first, which w

Modifying ES6 module exports

2015-12-21 Thread /#!/JoePea
I'm curious, what should happen when module A imports the default from module B which imports the default from module A? Should the exported A object exist inside of module B? Here's two modules A and B (simplified from some real code that I have), which have a circular dependency: ```js // A.js

Re: module exports

2014-03-14 Thread C. Scott Ananian
On Fri, Mar 14, 2014 at 3:34 PM, John Barton wrote: > On Fri, Mar 14, 2014 at 11:42 AM, David Herman wrote: >> When you export from a module, you're exporting bindings, rather than >> values. This means you can refactor between >> >> module m from "foo"; >> ... >> m.bar >> >> and >> >

Re: module exports

2014-03-14 Thread Andrea Giammarchi
David I know the analogy was weak but since indeed you said there's nothing like that, I named the one that felt somehow close because of some implicit behavior. I am personally easy going on modules, I like node.js require and I think that behind an await like approach could work asynchronously t

Re: module exports

2014-03-14 Thread John Barton
xports > during initialization, you don't run into as many subtle > order-of-initialization issues as you do with AMD and Node, because > importing something syntactically early doesn't mean you accidentally > snapshot its pre-initialized state. > > (Also, keep in mind th

RE: module exports

2014-03-14 Thread Brian Terlson
David Herman wrote: > I think we're seeing the exact same phenomenon with `export default` -- the > modifiers make it look more like a declaration context. So I think we should > consider doing the same thing as we do for ExpressionStatement: I agree with the confusion (due in part because the

Re: module exports

2014-03-14 Thread Kevin Smith
> > > ExportDeclaration : > ... > export default FunctionDeclaration ; > export default ClassDeclaration ; > export default [lookahead !in { function, class }] > AssignmentExpression ; > I think this would allay most of my concerns. _

RE: module exports

2014-03-14 Thread Domenic Denicola
From: es-discuss on behalf of David Herman > So I think we should consider doing the same thing as we do for > ExpressionStatement: > ... > This actually results in no net change to the language syntax, but it allows > us to change the scoping rules so that function and class declarations sco

Re: module exports

2014-03-14 Thread David Herman
On Mar 14, 2014, at 10:50 AM, Russell Leggett wrote: > I completely agree with this. It looks like a modifier. This is a good point, and folks working on the Square transpiler noticed this, too. I think there's a more surgical fix, though (and I'm not entertaining major syntax redesign at this

Re: module exports

2014-03-14 Thread Kevin Smith
> > > Functions with return AssignmentExpression that include "=" and > without--are the ones without also confusing without the "necessary" visual > cue? > No, because they are preceded by keywords that also indicate an expression context, in this case "return" and "yield". __

Re: module exports

2014-03-14 Thread David Herman
On Mar 14, 2014, at 9:37 AM, Andrea Giammarchi wrote: > I like that more I read about this, more the `with` statement comes into my > mind ... There's nothing like this in JS today, so if you're only looking for precedent there, you're only going to be able to come up with weak analogies. The

Re: module exports

2014-03-14 Thread David Herman
importing something syntactically early doesn't mean you accidentally snapshot its pre-initialized state. (Also, keep in mind that the vast majority of module exports are set once and never changed, in which case this semantics *only* fixes bugs.) Dave ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: module exports

2014-03-14 Thread Russell Leggett
> > >> I don't understand this claim, any legal AssignmentExpression form is >> allowed. >> >> >>> I've said this before, but without the equals it looks too much like a >>> declaration: >>> >>> export default class C {} >>> var c = new C(); // No C defined, WTF? >>> >> >> Why is this surpr

Re: module exports

2014-03-14 Thread Rick Waldron
On Fri, Mar 14, 2014 at 12:24 PM, Kevin Smith wrote: > >> var f = function a() {}; >> >> a(); // nope. >> > > Sure, note the equals (which is my point). > > >> var D = class C {}; >> >> And no one would expect to be able to this: >> >> var c = new C(); >> >> > Same thing. Note the equals,

Re: module exports

2014-03-14 Thread Andrea Giammarchi
;> // module3.js >> module module1 from "./module1"; >> let { foo, changeFoo } = module1; >> >> // Destructuring uses assignment to copy over the current values >> // So calling changeFoo does not affect this binding for foo >> >> console.log(

Re: module exports

2014-03-14 Thread John Barton
s > // So calling changeFoo does not affect this binding for foo > > console.log(foo); // 5 > changeFoo(); > console.log(foo); // 5 > > > > > > From: John Barton > Sent: Friday, March 14, 2014 10:35 > To: Domenic Denicola > Cc: Mark Volkmann; Kevin Smith; es-di

Re: module exports

2014-03-14 Thread Kevin Smith
> > > var f = function a() {}; > > a(); // nope. > Sure, note the equals (which is my point). > var D = class C {}; > > And no one would expect to be able to this: > > var c = new C(); > > Same thing. Note the equals, which gives the reader the necessary visual cue that we are entering an

Re: module exports

2014-03-14 Thread John Barton
On Fri, Mar 14, 2014 at 9:15 AM, Rick Waldron wrote: > > > > On Fri, Mar 14, 2014 at 11:04 AM, Kevin Smith wrote: > >> >>> >>> Because it doesn't allow for the Assignment Expression form >>> (specifically, function expressions) that developers expect to be able to >>> write: >>> >>> export defau

Re: module exports

2014-03-14 Thread Rick Waldron
On Fri, Mar 14, 2014 at 11:04 AM, Kevin Smith wrote: > >> >> Because it doesn't allow for the Assignment Expression form >> (specifically, function expressions) that developers expect to be able to >> write: >> >> export default function() {} >> > > The alternative here is: > > function MyT

Re: module exports

2014-03-14 Thread C. Scott Ananian
Sigh. The example just better demonstrates how clunky the syntax is and how surprising the semantics can be. :( I hope one of the CommonJS or RequireJS folks write a good ES6 module loader so that I can continue to use reasonable syntax and ignore all of this. This really smells like Second Sys

Re: module exports

2014-03-14 Thread Kevin Smith
> > > > Because it doesn't allow for the Assignment Expression form (specifically, > function expressions) that developers expect to be able to write: > > export default function() {} > The alternative here is: function MyThing() {} export { MyThing as default }; Which is more clear, m

RE: module exports

2014-03-14 Thread Domenic Denicola
Indeed. If you have used Node.js extensively, I am sure you are familiar with this paradigm. From: es-discuss on behalf of Mark Volkmann Sent: Friday, March 14, 2014 10:50 To: Rick Waldron Cc: es-discuss@mozilla.org Subject: Re: module exports Is the common

Re: module exports

2014-03-14 Thread Mark Volkmann
ow in >>>> ES6 I can import specific things from a module or I can import everything a >>>> module exports. >>>> >>> >>> You can't really import all exported bindings. You can import the >>> module instance object itself: >>> >&

Re: module exports

2014-03-14 Thread Rick Waldron
On Fri, Mar 14, 2014 at 10:07 AM, Mark Volkmann wrote: > On Fri, Mar 14, 2014 at 8:54 AM, Kevin Smith wrote: > >> >>> I'm trying to understand how that compares to ES6 modules. I see how in >>> ES6 I can import specific things from a module or I can imp

RE: module exports

2014-03-14 Thread Domenic Denicola
nsole.log(foo); // 5 From: John Barton Sent: Friday, March 14, 2014 10:35 To: Domenic Denicola Cc: Mark Volkmann; Kevin Smith; es-discuss@mozilla.org Subject: Re: module exports   What is a 'mutable binding'? On Fri, Mar 14, 2014 at 7:30 AM, Domenic Denicola wrote: Importing

Re: module exports

2014-03-14 Thread John Barton
t syntax is used for > each case. > > -- > *From:* Mark Volkmann > *Sent:* Friday, March 14, 2014 10:19 > *To:* Kevin Smith > *Cc:* Domenic Denicola; es-discuss@mozilla.org > *Subject:* Re: module exports > > I understand it's hard to make changes aft

RE: module exports

2014-03-14 Thread Domenic Denicola
es-discuss@mozilla.org Subject: Re: module exports I understand it's hard to make changes after a certain point. It's too bad though that developers will have to remember that the way to import a few things from a module is: import {foo, bar} from 'somewhere'; but the way

Re: module exports

2014-03-14 Thread Mark Volkmann
I understand it's hard to make changes after a certain point. It's too bad though that developers will have to remember that the way to import a few things from a module is: import {foo, bar} from 'somewhere'; but the way to import the whole module is: module SomeModule from 'somewhere'; instea

Re: module exports

2014-03-14 Thread Kevin Smith
> > export { foo as default }; >> >> I fail to see why sugar over this form is necessary. >> > > I completely agree. Plus if this is taken away then the "import" keyword > can be used to get the whole module as in my example above. At that point > maybe there is no need for the "module" keyword

Re: module exports

2014-03-14 Thread Mark Volkmann
On Fri, Mar 14, 2014 at 8:54 AM, Kevin Smith wrote: > >> I'm trying to understand how that compares to ES6 modules. I see how in >> ES6 I can import specific things from a module or I can import everything a >> module exports. >> > > You can't really im

Re: module exports

2014-03-14 Thread Kevin Smith
> > > > I'm trying to understand how that compares to ES6 modules. I see how in > ES6 I can import specific things from a module or I can import everything a > module exports. > You can't really import all exported bindings. You can import the module instance ob

Re: module exports

2014-03-14 Thread Mark Volkmann
I have used Node.js extensively. In that environment, as I'm sure you know, a module exports one thing. It can be an object with lots of properties on it, a single function, or a single value. I suppose you could say that all Node has is a "default" export which is the one thing the

Re: module exports

2014-03-14 Thread Domenic Denicola
le, > export {name1, name2, ...}; > > Here's the part that confuses me most. It seems that importers have three > options. > 1) import specific things from a given module > 2) import everything that was exported from a given module > 3) import a subset of what a given mod

module exports

2014-03-14 Thread Mark Volkmann
of what a given module exports that it identified as the "default" (presumably the most commonly used things) To define the default subset of things to export from a module, export default = some-value or some-function; where some-value could be an object holding a collection of thing

Re: module exports

2011-07-11 Thread David Herman
No, a module determines its exports by itself, and no one can override that. Notice that you missed *two* export declarations, car.startCar *and* car.engine.start. If the engine module doesn't export start, then the outer car module cannot access it. Dave On Jul 10, 2011, at 11:19 PM, Kam Kasr

Re: module exports

2011-07-10 Thread Kam Kasravi
Yes, thanks, my mistake on the unexported startCar function declaration. My question is more about semantics, if the author of engine did not want to export start, the grammar allows anyone importing the engine module to override the original author's intent. On Jul 10, 2011, at 8:11 PM, David

Re: module exports

2011-07-10 Thread David Herman
> According to the module grammar, the following is valid: > > 691module car { > function startCar() {} > module engine { > function start() {} > } > export {start:startCar} from engine; > } > > > It seems like there would be issues with exporting module elements after the > module

module exports

2011-07-10 Thread Kam Kasravi
Hi Dave: According to the module grammar, the following is valid: 691module car { function startCar() {} module engine { function start() {} } export {start:startCar} from engine; } It seems like there would be issues with exporting module elements after the module has been defined. Also, wha