Skip to content

export default x live binding scenarios #2000

@guybedford

Description

@guybedford

Currently we output export default x when we have default exports instead of export { x as default }.

For example - https://rollupjs.org/repl?version=0.56.0&shareable=JTdCJTIybW9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTJDJTIyY29kZSUyMiUzQSUyMnZhciUyMHglMjAlM0QlMjAxMCUzQiU1Q24lNUNuZXhwb3J0JTIwZnVuY3Rpb24lMjB1cGRhdGUlMjAoKSUyMCU3QiU1Q24lNUN0eCUyMCUzRCUyMDExJTNCJTVDbiU3RCU1Q24lNUNuZXhwb3J0JTIwJTdCJTIweCUyMGFzJTIwZGVmYXVsdCUyMCU3RCUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlMjJmb3JtYXQlMjIlM0ElMjJlcyUyMiUyQyUyMm5hbWUlMjIlM0ElMjJteUJ1bmRsZSUyMiUyQyUyMmdsb2JhbHMlMjIlM0ElN0IlN0QlMkMlMjJhbWQlMjIlM0ElN0IlMjJpZCUyMiUzQSUyMiUyMiU3RCU3RCUyQyUyMmV4YW1wbGUlMjIlM0FudWxsJTdE

The issue is that export default x is no longer a live binding, so it would actually be better to have export { x as default } to ensure the live binding!

This case came up considering live binding across chunking interfaces which all works out, except for default exports in this way.

Of course in scenarios where the default is a temporary variable created by Rollup, we know we can use export default as there is no live binding update in play.

For example with - https://rollupjs.org/repl?version=0.56.0&shareable=JTdCJTIybW9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTJDJTIyY29kZSUyMiUzQSUyMnZhciUyMHglMjAlM0QlMjAxMCUzQiU1Q24lNUNuZXhwb3J0JTIwZnVuY3Rpb24lMjB1cGRhdGUlMjAoKSUyMCU3QiU1Q24lNUN0eCUyMCUzRCUyMDExJTNCJTVDbiU3RCU1Q24lNUNuZXhwb3J0JTIwZGVmYXVsdCUyMHglM0IlMjIlN0QlNUQlMkMlMjJvcHRpb25zJTIyJTNBJTdCJTIyZm9ybWF0JTIyJTNBJTIyZXMlMjIlMkMlMjJuYW1lJTIyJTNBJTIybXlCdW5kbGUlMjIlMkMlMjJnbG9iYWxzJTIyJTNBJTdCJTdEJTJDJTIyYW1kJTIyJTNBJTdCJTIyaWQlMjIlM0ElMjIlMjIlN0QlN0QlMkMlMjJleGFtcGxlJTIyJTNBbnVsbCU3RA==

Perhaps we should work on distinguishing these cases and outputting appropriately.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions