javascript import from ‘/folder’ with index.js

Is this actually part of the specification?

No. How module identifiers ('./reducers' in your case) are resolved to the actual modules is left to the implementation of the module loader/bundler, it’s not specificed by ES6. And it doesn’t seem to be specified in CommonJs either.

This is just how node does it – when requiring a directory, it’s index.js file will be used. Bundlers like browserify or webpack followed this convention (for compat reasons).

Leave a Comment