The current spec being worked on to resolve this problem is at http://whatwg.github.io/loader. It's still under construction, but it's being written with browser and Node interop in mind.
> From: John Barton <[email protected]> > To: Glen Huang <[email protected]> > Cc: monolithed <[email protected]>, es-discuss <[email protected]> > Date: Thu, 5 Feb 2015 07:53:47 -0800 > Subject: Re: include 'foo/index.js' or include 'foo'? > The following solution has worked very well for us: > > import './foo/index.js'; > means resolve './foo/index.js' relative to the importing file. > > All of the rest mean look up 'foo' in the developer's mapping of names, replacing 'foo' with a path that is then used to resolve the import. > > To be sure 'foo' 'foo/index' and 'foo/' would likely fail after lookup since they don't name files. > > (This kind of thing cannot be "up to the host". If TC39 passes on deciding, then developers will). > > jjb > > On Thu, Feb 5, 2015 at 5:01 AM, Glen Huang <[email protected]> wrote: >> >> I believe this is out the scope of ecmascript. It’s up to the host to determine how the paths are resolved. >> >> See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-hostnormalizemodulename >> >>> On Feb 5, 2015, at 8:51 PM, monolithed <[email protected]> wrote: >>> >>> I could not find an answer in the specification regarding the following cases: >>> >>> import './foo/index.js' >>> import 'foo/index.js' >>> import 'foo/index' >>> import 'foo' >>> import 'foo/' >>> >>> >>> Is there a difference? >>> >>> Node.js lets create an 'index.js' file, which indicates the main include file for a directory. >>> So if you call require('./foo'), both a 'foo.js' file as well as an 'foo/index.js' file will be considered, this goes for non-relative includes as well. >>> >>> _______________________________________________ >>> es-discuss mailing list >>> [email protected] >>> https://mail.mozilla.org/listinfo/es-discuss >> >> >> >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> > > > > ---------- Forwarded message ---------- > From: Andy Earnshaw <[email protected]> > To: Frankie Bagnardi <[email protected]> > Cc: es-discuss <[email protected]> > Date: Thu, 5 Feb 2015 18:06:49 +0000 > Subject: Re: Should `use strict` be a valid strict pragma? > > > On 5 Feb 2015 15:06, "Frankie Bagnardi" <[email protected]> wrote: > > > > I think any issues with that are imagined. Languages have rules, and of the people who both know what 'use strict' does and are using es6 syntax, they're very unlikely to make the mistake. > > Sure, it's theoretical at this point but not unimaginable. Eventually everyone will be using "es6 syntax", and there are plenty of blogs and books around that explain the benefits of strict mode. > > > I don't see people using template literals for arbitrary strings... it could happen but it probably won't. > > Not everyone, but I think it's likely that some will. If you want to add a variable ref to a static string, for instance, it's simpler if you don't have to change the delimiters to back ticks. We can probably only speculate right now. > > > Mathias makes a good point also, it's not strings that equal the string 'use strict', it's exactly two possible arrangements of characters. > > And that's obvious to us, but won't be to everyone. I'm on my phone right now so it's hard to check, but I think you'll find more sources explaining the directive is a string literal than you would an arrangement of characters. > > My immediate reaction was that it wasn't worth it, but I kinda think that if it is easy enough to implement then any risk would be avoided by doing so. > > > > ---------- Forwarded message ---------- > From: Steve Fink <[email protected]> > To: [email protected] > Cc: > Date: Thu, 05 Feb 2015 11:20:12 -0800 > Subject: Re: Should `use strict` be a valid strict pragma? > On 02/05/2015 05:12 AM, Andy Earnshaw wrote: >> >> I think you're missing the point Leon is trying to make. He's saying that, in ES 6 we have a new way to write strings. In some ways, these more powerful strings may condition some people to use ` as their main string delimiter. An unsuspecting person may liken this to PHP's double quotes vs single quotes, thinking that the only difference is that you can use `${variable}` in strings that are delimited with backticks, but other than that everything is the same. When they write this in their code: >> >> ``` >> `use strict`; >> ``` >> >> They may introduce bugs by writing non-strict code that doesn't throw when it should. Adding it to the spec wouldn't be difficult and it would avoid any potential confusion or difficult-to-debug issues. It's definitely easier than educating people, IMO. > > > 'use strict' and "use strict" are magic tokens and should stay that way, not propagate to other ways of writing literal strings. Literal strings are different things, which happen to share the same syntax for backwards-compatibility reasons. > > If people switch to backticks for all their literal strings, so much the better -- then single and double quotes will only be used for directives, and there will be less confusion. (I don't actually believe that. At the very least, I don't expect JSON to allow backticks anytime soon. Nor do I think that using backticks indiscriminately is good practice.) > > > > > ---------- Forwarded message ---------- > From: Axel Rauschmayer <[email protected]> > To: Steve Fink <[email protected]> > Cc: es-discuss list <[email protected]> > Date: Thu, 5 Feb 2015 20:24:24 +0100 > Subject: Re: Should `use strict` be a valid strict pragma? > Also: given that modules are implicitly strict, you will hardly ever use the strict directive in ES6. > >> On 05 Feb 2015, at 20:20, Steve Fink <[email protected]> wrote: >> >> On 02/05/2015 05:12 AM, Andy Earnshaw wrote: >>> >>> I think you're missing the point Leon is trying to make. He's saying that, in ES 6 we have a new way to write strings. In some ways, these more powerful strings may condition some people to use ` as their main string delimiter. An unsuspecting person may liken this to PHP's double quotes vs single quotes, thinking that the only difference is that you can use `${variable}` in strings that are delimited with backticks, but other than that everything is the same. When they write this in their code: >>> >>> ``` >>> `use strict`; >>> ``` >>> >>> They may introduce bugs by writing non-strict code that doesn't throw when it should. Adding it to the spec wouldn't be difficult and it would avoid any potential confusion or difficult-to-debug issues. It's definitely easier than educating people, IMO. >> >> >> 'use strict' and "use strict" are magic tokens and should stay that way, not propagate to other ways of writing literal strings. Literal strings are different things, which happen to share the same syntax for backwards-compatibility reasons. >> >> If people switch to backticks for all their literal strings, so much the better -- then single and double quotes will only be used for directives, and there will be less confusion. (I don't actually believe that. At the very least, I don't expect JSON to allow backticks anytime soon. Nor do I think that using backticks indiscriminately is good practice.) > > > -- > Dr. Axel Rauschmayer > [email protected] > rauschma.de > > > > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

