felixge / node-require-all

An easy way to require all files within a directory.
MIT License
300 stars 48 forks source link

Allow .ts files to be found in DEFAULT_FILTER option #65

Open MatthieuLepers opened 1 year ago

MatthieuLepers commented 1 year ago

Hello ! I'm making a discord bot using discord.js-commando and i migrate my bot to a typescript project

I figure out an issue with require-all@3.0.0 that is used by discord.js-commando@latest doesn't allow .ts files to be found by default

Maybe you should change the DEFAULT_FILTER regex from /^([^\.].*)\.js(on)?$/ to /^([^\.].*)\.(?:j|t)s(on)?$/

dougwilson commented 1 year ago

Since the Node.js require() cannot load .ts files by default, it is not in the default filter.

You can use the filter option to add lookup for custom loaders you have added to the Node.js runtime, however. Just use that regexp as the filter option in your ts app.

dougwilson commented 1 year ago

Actually, maybe it is possible to tell somehow what extensions can be loaded by Node.js, so if .ts is there we can load me default, otherwise not 🤔