3

I've seen several ES6 code examples where a directory is being required, like this:

import * as things from '../some_directory'

Where some_directory is a directory, not a regular file. It appears that in this case some_directory/index.js ends up getting required.

Is this the case? Where is this documented?

Bergi
  • 513,640
  • 108
  • 821
  • 1,164
pjb3
  • 4,881
  • 2
  • 22
  • 40
  • 1
    Seems like this is related to NodeJS's [index.js](http://stackoverflow.com/questions/21063587/what-is-index-js-typically-used-for-in-node-js-projects) support. I don't think this would work in a browser – CodingIntrigue Sep 21 '15 at 11:21
  • 1
    This behavior is defined by whatever loader happens to be in use. –  Sep 21 '15 at 11:22
  • 3
    Actually some documentation is presented [here](https://nodejs.org/api/modules.html), part **Folders as Modules** – The Reason Sep 21 '15 at 11:43
  • 1
    related: [import modules from files in directory](http://stackoverflow.com/q/29722270/1048572) – Bergi Sep 21 '15 at 13:03

0 Answers0