vihanb / babel-plugin-wildcard

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

Regex import #7

Open reyalpsirc opened 7 years ago

reyalpsirc commented 7 years ago

Is it possible to use some regex way to import only specific files (and ignoring the ones that would not match the regex)?

vihanb commented 7 years ago

could you give an example of how this would work? I'm not sure exactly how this would optimally work. Would the regex be the whole import source? Would there be some section of a path that indicates a regex? I think the optimal solution to specific multi-file imports would be a seperate babel-plugin-glob to allow globs to select which files would be imported

reyalpsirc commented 7 years ago

I don't actually have an example of how the import would look like since I have no knowledge of babel itself.

But the main idea would be to avoid some filenames inside the folder since sometimes you want to auto-import new files added except some other files (like config ones or something like that) that are on the same folder.

The only thing at the top of my mind is if we could use require instead for these cases and do it like require('path/to/my/folder', /^(?!(config\.js)$).+$/)