Skip to content

Export * and export default #328

Closed
Closed

Description

I get the error Multiple default exports when trying to export everything from another file including the default export e.g.

export * from './foo';
export { default as default } from './foo';

It looks like that this case should throw an error (as shown by this test case) however babel compiles the code export * from './foo'; to:

Object.keys(_foo).forEach(function (key) {
  if (key === "default") return;
  Object.defineProperty(exports, key, {
    enumerable: true,
    get: function get() {
      return _foo[key];
    }
  });
});

Reference

so the second export is necessary to ensure the default export also gets exported.

Any suggestions? I'm not sure whether it's actually babel which is at fault here or if the assumption in this plugin is wrong. Happy to contribute a PR if a solution is agreed on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions