0

I am using babel to transpile ES2015 code to ES5 & RequireJS.

But when I use the following syntax:

const o = { foo: 'foo' };
export default o;

The transpiled result is an object with a default property on it.

ie. it is currently transpiled to something like:

define(function() {
  return {
     default: { 
       foo: 'foo' 
     }
  };
});

What I want is the object literal itself (containing the foo property) to be returned directly.

ie. I want something like:

define(function() {
  return {
     foo: 'foo' 
  };
});

Can I achieve this?

Ben Aston
  • 53,718
  • 65
  • 205
  • 331

1 Answers1

2

If you don't include default it will work as expected.

export const o = { foo: 'foo' };
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
bennyboy
  • 21
  • 1