How to get around the `.default` property?

Do you want to request a feature or report a bug?

Bug? Or maybe a feature?

What is the current behavior?

I have an AMD define() module that is like

define({
    Foo: './Foo',
}, function(Foo) {
    var Foo = Foo.default;
});

where ./Foo was written as an ES6 module, so I have to use var Foo = Foo.default; which isn’t as intuitive as just Foo. In other words, I have to go and modify all old code to add the var Foo = Foo.default.

However, ./Foo only exports a default export, and was basically converted from define() to ES6. It was previously simply returning Foo.

Is there a way to make this less annoying, so that only Foo is require and not having to access .defaults?

What is the desired behavior?

I don’t want to have to access .default for originally define code that was converted to ES6 with default export.

If this is a feature request, what is motivation or use case for changing the behavior?

It would make things less of a hassle.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

Webpack 2.

Author: Fantashit

1 thought on “How to get around the `.default` property?

  1. I don’t think this will be changed. That’s how ESM works.

    Just write all your modules as ES2015 module.

    /wontfix

Comments are closed.