vihanb / babel-plugin-wildcard

Wildcard imports import a directories JS files
MIT License
186 stars 27 forks source link

Handle Proper Recursive Imports with `index.js` #12

Open RayBenefield opened 6 years ago

RayBenefield commented 6 years ago

PR #11 introduced Recursive Imports, but do not properly require index.js with special behavior. Ideally when a directory with both index.js and sibling files is imported, the index.js file is set to the base alias and is then extend with properties that match the sibling file names.

For example:

|- index.js
|- dir
    |- a.js
    |- c.js
    |- nested
        |- index.js
        |- b.js

The following should be possible:

import * as Items from './dir';

console.log(Items.Nested()); // Whatever is in './nested/index.js'
console.log(Items.Nested.B()); // Whatever is in './nested/b.js'