8000 Mixed default and named exports · Issue #306 · developit/microbundle · GitHub
[go: up one dir, main page]

Skip to content
Mixed default and named exports #306
Closed
@pascalduez

Description

@pascalduez

Hi,

I have a hard time figuring out a solution for having both a default and named export in a package. (Yes, that sounds like a bad idea, but if we could prevent a breaking change...). It's using TypeScript.

// package index.ts
function foo() {}
export { foo };
export default foo;

Get compiled into:

function e() {}
;(exports.foo = e), (exports.default = e)

Then trying to import the package in a Babel environment:

// consumer index.js
import foo from 'foo';
foo();
$ babel-node index.js --presets @babel/env
(0, foo.default)();     
TypeError: (0 , foo.default) is not a function 

So it basically lacks the interop thing:

Object.defineProperty(exports, "__esModule", {
  value: true
});

;(exports.foo = e), (exports.default = e)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0