It seems that requiring a sibling index.js file in a folder with the require('.') notation stopped working since #253
I usually have the following structure for components:
|-- components
| -- Button
| -- index.js
| -- spec.js
and I'd require the file on spec.js with:
const Button = require('.');
This stopped working on 3.1.0 and I need to require('./index.js') which is a bit cumbersome and also in nodejs it's standard to resolve require('.') to the sibling index.js file.
This is an example breaking test, which passes before 7dc2da6
describe('when requiring a sibling index.js', () => {
const siblingAliasTransformOpts = {
babelrc: false,
plugins: [
[plugin, {
root: ['./src'],
}],
],
};
it('should resolve an index.js on a folder name', () => {
testWithImport(
'.',
'.',
siblingAliasTransformOpts,
);
});
});
● module-resolver › when requiring a sibling index.js › should resolve an index.js on a folder name
expect(received).toBe(expected) // Object.is equality
Expected value to be:
"import something from \".\";"
Received:
"import something from \"./src\";"
10 | const result = transform(code, transformerOpts);
11 |
> 12 | expect(result.code).toBe(`import something from "${output}";`);
13 | }
14 |
15 | describe('exports', () => {
I'm happy to help with a PR or to complement with more details. Thanks!
It seems that requiring a sibling
index.jsfile in a folder with therequire('.')notation stopped working since #253I usually have the following structure for components:
and I'd require the file on
spec.jswith:This stopped working on 3.1.0 and I need to
require('./index.js')which is a bit cumbersome and also in nodejs it's standard to resolverequire('.')to the sibling index.js file.This is an example breaking test, which passes before 7dc2da6
I'm happy to help with a PR or to complement with more details. Thanks!