requireify icon indicating copy to clipboard operation
requireify copied to clipboard

ES6 export default not supported

Open richard-flosi opened this issue 9 years ago • 2 comments

Hi, we are using ES6 Modules and I'm noticing that requireify is unable to require() modules that use export default. Any thoughts on how to fix this or if there is a work around?

richard-flosi avatar Jan 13 '16 18:01 richard-flosi

Thanks for the issue @richard-flosi!

I need to think about it a little bit. What transform are you using to bundle ES2015 modules? Also, what is requireify bringing into the console when using this transform? Are you getting an object that's structured like

{
 default: {OBJ YOU REALLY WANT}
}

?

johnkpaul avatar Jan 13 '16 20:01 johnkpaul

Hi @johnkpaul I get back undefined. I would expect to get back the default object without it under a default key. I'm using .transform(requireify, {global: true}) as my transform.

e.g.

# foo.js
export default {
  foo: 'bar',
};

For exports like the following it works as expected:

const foo = {foo: 'bar'};
exports {
  foo,
};

richard-flosi avatar Jan 13 '16 22:01 richard-flosi