Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle default exports #702

Closed
wants to merge 3 commits into from
Closed

Handle default exports #702

wants to merge 3 commits into from

Conversation

jchavarri
Copy link
Member

Fixes #697.

There is no good reason to export both $$default (as default is reserved word) and default, this leads to all sorts of issues with JS tooling.

The PR removes the former from the named outputs, allowing Melange users to export just the default value.

It is a breaking change, so maybe can be included in v2?

See both outputs in rollup repl, with both exports (notice the warning) and just the default.

For reference, this is the PR when the default handling was introduced, unfortunately there's not a lot of context or information about it: rescript-lang/rescript-compiler#2002.

@jchavarri
Copy link
Member Author

jchavarri commented Aug 25, 2023

Hm thinking more about it, the previous change would break any module that was defining a value with name default, which is probably not what we want.

In 6304e19, I changed the id that allows to identify default export to __es6__default_export, so there are no conflicts between both semantics. Happy to use different name or approach if this one could be problematic.

@anmonteiro
Copy link
Member

I'm not so sure about this. It's quite the cognitive overhead to have to write let __es6__default_export = ....

@jchavarri
Copy link
Member Author

we discussed we'll follow a different approach to fix this.

@jchavarri jchavarri closed this Aug 31, 2023
@jchavarri jchavarri deleted the handle-default-exports branch August 31, 2023 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entry module is using named and default exports together
2 participants