vihanb / babel-plugin-wildcard

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

Can't import multiple files with same names that have different extensions #38

Open sea841107 opened 4 years ago

sea841107 commented 4 years ago

if I have three files:

|- dir
  |- A.json
  |- A.atlas
  |- A.png

then I do this:

import * as Items from './dir';
console.log(Items)

It will only show:

A:.../dir/A.atlas

It can't import all three files. So I think maybe we can add an option to let the variables include their extensions. Something like this:

A_json:.../dir/A.json
A_atlas:.../dir/A.atlas
A_png:.../dir/A.png

I know there's a way to do this in index.js:

if(_path3.default.extname(file) !== '') {
  fancyName = fancyName + '_' + _path3.default.extname(file).substring(1);
}

But I would appreciate it if I could choose to switch it.