express-enrouten icon indicating copy to clipboard operation
express-enrouten copied to clipboard

Allow other require extensions

Open scttdavs opened this issue 8 years ago • 6 comments

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.

scttdavs avatar Apr 11 '16 18:04 scttdavs

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:

jasisk avatar Apr 13 '16 22:04 jasisk

thanks! I added a test to make it a little more clear. Also confirmed it failed before and fixed afterward.

scttdavs avatar Apr 13 '16 22:04 scttdavs

any update on this?

scttdavs avatar Apr 27 '16 15:04 scttdavs

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 ?

IcanDivideBy0 avatar Nov 04 '16 11:11 IcanDivideBy0

I agree the extensions should be passed as an option.

Otherwise looks good.

tlivings avatar Nov 04 '16 13:11 tlivings

@scttdavs thoughts on changing the implementation to allow extensions to passed as an option instead of using require?

gabrielcsapo avatar Jul 12 '17 22:07 gabrielcsapo