speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

can not work when import a folder without "index" #215

Open clownvary opened 5 years ago

clownvary commented 5 years ago

I have a folder named const, and some files like below.

const/A.js

const TypeA = {
SINGLE: 'single_column'
};
export default TypeA;

const/B.js

const TypeB = {
MULTIPLE: 'multiple_column'
};
export default TypeB;

const/index.js

import TypeA from './A';
import TypeB from './B';
export default {
TypeA,
TypeB
};

My component file

import { TypeA } from './const'; 
...

I import TypeA just omit index path, it can work well . But it will throw an error TypeError: Cannot read property 'TypeA' of undefined after i use Rewire plugin, do this plugin can support es6 module import without index path? How can i do?