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

Prevent export of $$default #4906

Closed
ryyppy opened this issue Jan 12, 2021 · 5 comments · Fixed by #6328
Closed

Prevent export of $$default #4906

ryyppy opened this issue Jan 12, 2021 · 5 comments · Fixed by #6328

Comments

@ryyppy
Copy link
Member

ryyppy commented Jan 12, 2021

No matter if I am using an interface file or not, this code:

let default = ""

will emit following js:

exports.$$default = $$default;
exports.default = $$default;

Is there a way to prevent $$default to be exported? This messes with tools like Storybook, which iterates over the exports of a component.

I assume this is required to be able to use values across ReScript modules?

@giraud
Copy link

giraud commented Jan 12, 2021

I had the same problem https://forum.rescript-lang.org/t/default-export-and-storybook-csf/527, used a workaround

@bobzhang
Copy link
Member

the compiler in general handles exports in a uniform way, so we got exports.[xx] = [xx].
$$default is used since var default = "" is a syntax error

@ryyppy
Copy link
Member Author

ryyppy commented Jan 13, 2021

it's just weird that it creates an additional export, even though it already exports a clean default already.

Would be nice if those additional $$ exports wouldn't happen in case there is a clean export, but I can see how this might make things more complicated.

@stale
Copy link

stale bot commented May 3, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Old issues that went stale label May 3, 2023
@stale stale bot closed this as completed May 20, 2023
@ryyppy ryyppy reopened this Jul 16, 2023
@stale stale bot removed the stale Old issues that went stale label Jul 16, 2023
@zth
Copy link
Collaborator

zth commented Jul 16, 2023

@ryyppy here's a #6328 simple test of not emitting the $$default export. At a first glance I think it looks innocent enough, but we need to investigate a bit further.

I'd expect this to be fine, because you're never actually defining $$default in ReScript anyway, so you shouldn't expect it to be exported.

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

Successfully merging a pull request may close this issue.

4 participants