aseemk / requireDir

Node.js helper to require() directories.
MIT License
484 stars 59 forks source link

require.extensions deprecated usage #59

Closed mt-richard-garnier closed 5 years ago

mt-richard-garnier commented 5 years ago

Thanks for the module, it is simple to use and very useful.

The code internally uses require.extensions but it is actually deprecated and has been for quite a while. In my case, this behavior conflicts with jest, that replaces require.extensions by an empty object.

Instead of having to use require.extensions, it would be nice to be able to pass an object (an array?) in the options to describe the extensions we would like to require. It would have two benefits, first partially remove the usage of a deprecated feature, and second allow to easily ignore files based on their extensions.

Its not hard, but if you're open for it, I can work on a PR.

yocontra commented 5 years ago

@mt-richard-garnier I'm open to it - a PR adding an optional extensions option that would be used instead of require.extensions when provided sounds fine.

BTW - require.extensions may be deprecated but I highly doubt it will ever be removed, as too many things rely on it and nothing better was ever introduced to replace it. Most modules (like babel-register, for example) are using pirates which does this: https://github.com/ariporad/pirates/blob/master/src/index.js#L43

richardgarnier commented 5 years ago

Thanks I made a PR for this, you can find it here.

yocontra commented 5 years ago

Published as 1.2.0 - thanks!

richardgarnier commented 5 years ago

Thanks for your time !