include 'foo/index.js' or include 'foo'?
import './foo/index.js';
import 'foo/index.js';
import 'foo/index';
import 'foo';
import 'foo/‘;
```js import './foo/index.js'; import 'foo/index.js'; import 'foo/index'; import 'foo'; import 'foo/‘; ``` -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150205/33f94ed1/attachment.html>
I believe this is out the scope of ecmascript. It’s up to the host to determine how the paths are resolved.
See people.mozilla.org/~jorendorff/es6-draft.html#sec-hostnormalizemodulename, people.mozilla.org/~jorendorff/es6-draft.html#sec-hostnormalizemodulename
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 <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-hostnormalizemodulename> > On Feb 5, 2015, at 8:51 PM, monolithed <monolithed at gmail.com <mailto:monolithed at gmail.com>> 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 > es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150205/9c441a5c/attachment-0001.html>
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).
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 <curvedmark at gmail.com> 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 <monolithed at gmail.com> 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 > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150205/b2b1b0bd/attachment.html>
The current spec being worked on to resolve this problem is at whatwg.github.io/loader. It's still under construction, but it's being written with browser and Node interop in mind.
Doh... I really slipped on this one... On Feb 6, 2015 3:21 AM, "Isiah Meadows" <impinball at gmail.com> wrote: > > 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 <johnjbarton at google.com> > > To: Glen Huang <curvedmark at gmail.com> > > Cc: monolithed <monolithed at gmail.com>, es-discuss < es-discuss at mozilla.org> > > 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 <curvedmark at gmail.com> 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 <monolithed at gmail.com> 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 > >>> es-discuss at mozilla.org > >>> https://mail.mozilla.org/listinfo/es-discuss > >> > >> > >> > >> _______________________________________________ > >> es-discuss mailing list > >> es-discuss at mozilla.org > >> https://mail.mozilla.org/listinfo/es-discuss > >> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150206/8d70da64/attachment.html>
- I made a mistake sending the email initially.
- I was referencing the spec for the future module loader.
- I think you meant to hit "Reply All".
1. I made a mistake sending the email initially. 2. I was referencing the spec for the future module loader. 3. I think you meant to hit "Reply All". On Feb 6, 2015 10:27 AM, "John Barton" <johnjbarton at google.com> wrote: > ? > > On Fri, Feb 6, 2015 at 12:24 AM, Isiah Meadows <impinball at gmail.com> > wrote: > >> Doh... I really slipped on this one... >> >> On Feb 6, 2015 3:21 AM, "Isiah Meadows" <impinball at gmail.com> wrote: >> > >> > 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 <johnjbarton at google.com> >> > > To: Glen Huang <curvedmark at gmail.com> >> > > Cc: monolithed <monolithed at gmail.com>, es-discuss < >> es-discuss at mozilla.org> >> > > 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 <curvedmark at gmail.com> >> 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 <monolithed at gmail.com> >> 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 >> > >>> es-discuss at mozilla.org >> > >>> https://mail.mozilla.org/listinfo/es-discuss >> > >> >> > >> >> > >> >> > >> _______________________________________________ >> > >> es-discuss mailing list >> > >> es-discuss at mozilla.org >> > >> https://mail.mozilla.org/listinfo/es-discuss >> > >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150206/656c4073/attachment.html>
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.