express-enrouten
express-enrouten copied to clipboard
Allow other require extensions
I have a routes.coffee
and routes.json
file I'm using in my project and it is breaking. However using routes.js
instead of coffee works.
What happens is that when it tries to require the coffee file, it loads the json file first, which cannot export a function so the assertion fails. I created a fix here which first looks at .js
and then tries all other require extensions other than json
.
Hey @scttdavs,
Sorry for the delay—I've been out of town for a couple of days. I'm catching up on a few things but I just wanted to acknowledge your PR. Thanks for submitting—I'll get to it shortly. :grinning:
thanks! I added a test to make it a little more clear. Also confirmed it failed before and fixed afterward.
any update on this?
Just a reminder that require.extensions is deprecated and breaks jest compatibility. I'd like to submit a PR to fix that, I think it could also fix your issue by providing an option to express-enrouten which specify allowed extensions. @jasisk what are your thoughts ?
I agree the extensions should be passed as an option.
Otherwise looks good.
@scttdavs thoughts on changing the implementation to allow extensions to passed as an option instead of using require?