babel-plugin-add-module-exports icon indicating copy to clipboard operation
babel-plugin-add-module-exports copied to clipboard

Trouble with multiples exports

Open christophedebatz opened this issue 4 years ago • 0 comments

Hi,

I'm facing an issue with this plugin.

So in file a.js i've this code:

export default class Foo { };
export const bar = { buzz: 3 };

When I look at babel's plugin output, it is:

exports.default = Foo;
module.exports = exports.default;

So, in another file, I can easily call my class Foo by an import foo from './a' But, I cannot call my second export bar, so when I type import { bar } from './a' and then console.log(bar.buzz) it throw an error Cannot read property 'buzz' of undefined.

The only "solution" I have is to add manually this:

module.exports.bar = exports.bar;

Obvioulsy, it's not a solution for me :-)

Any idea about this problem concerning the other export than the default one? Thanks,

christophedebatz avatar Apr 15 '20 14:04 christophedebatz