Closed alansouzati closed 5 years ago
This PR is intended to fix #24.
@phated Any idea why the test suite is failing for babel.js
?
It was actually my fault. The supportsExtension check should iterate over exts
. If we don't find on the first one, move forward. In the babel case:
1 - .babel.js
is not supported by default
2 - Then we move the to next extesion: .js
, which is supported
3 - Result? It tries to interpret the file as raw js, when in fact it is babel.
Since you are asking for multiple match groups, you are also implying that there is an upper limit to the number of possible extensions any one file can have. I presume that with at most three extensions the system should work fine, e.g.
const EXTRE = /(?:(?:\.[^.]+)?((?:\.[^.]+)?(\.[^.]+)))$/;
yields
> EXTRE.exec('testing.tmp.babel.js');
[ '.tmp.babel.js',
'.babel.js',
'.js',
index: 7,
input: 'testing.tmp.babel.js' ]
> EXTRE.exec('testing.babel.js')
[ '.babel.js',
'.js',
'.js',
index: 7,
input: 'testing.babel.js' ]
> EXTRE.exec('testing.js')
[ '.js',
'.js',
'.js',
index: 7,
input: 'testing.js' ]
Just grab everything from the first dot, split on dot, and do this:
['.one', '.two', '.three'].map(function (item, idx, arr) {
return arr.slice(idx).join('');
});
...that will give you ['.one.two.three', '.two.three', '.three']
Yeah, agreed. I believe this is the simplest solution. I will work on that.
On Fri, Jun 5, 2015 at 11:47 AM, Tyler Kellen notifications@github.com wrote:
Just grab everything from the last dot, split on dot, and do this:
['.one', '.two', '.three'].map(function (item, idx, arr) { return arr.slice(idx).join(''); });
...that will give you ['.one.two.three', '.two.three', '.three']
— Reply to this email directly or view it on GitHub https://github.com/tkellen/js-rechoir/pull/26#issuecomment-109395384.
Alan Souza Software Engineer Contact: +1 (408) 421 - 6341
@alansouzati Is this ready for review?
Sorry, let me just fix the typo in extension
and it should be ready for review.
Also, can you add to the test a path that includes a directory with a dot in it?
Sure @phated !
@alansouzati any chance you can tackle the remaining issue? I'd like to close some of the issues open related to this.
I'm uncertain how to tackle the remaining issue.. any suggestions?
@alansouzati maybe that check can go away and we can check if the module that matches the extension is already in the require.cache
- @tkellen thoughts? Someone opened this as a bug on gulp, so I'd like to get it wrapped up
@tkellen any chance of fixing this? I'm looking into using this module for karma config loading where I have files like karma.conf.babel.js
or karma.conf.coffee
or karma.config.js
and this is a blocker for me.
Superseded by #37
Hi, as agreed, I'm creating the PR again to add multi extension support!