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

Dynamic import doesn't work with external that defines a function #6985

Closed
anmonteiro opened this issue Aug 28, 2024 · 3 comments · Fixed by #7060
Closed

Dynamic import doesn't work with external that defines a function #6985

anmonteiro opened this issue Aug 28, 2024 · 3 comments · Fixed by #7060

Comments

@anmonteiro
Copy link
Contributor

#6663 fixed an issue where @module("..") external .. would also emit a static import. But it looks like external + dynamic import isn't very well supported if the external is an arrow. Here's a playground link.

Wondering if that's on purpose or an oversight. Obviously you can extract the arrow to type f = string => unit or something along those lines, but that disables a few optimizations and you can't use attributes such as @unwrap and friends.

@anmonteiro
Copy link
Contributor Author

I guess this is what has been described as a limitation in #6664 (comment)

@mununki
Copy link
Member

mununki commented Aug 28, 2024

I guess this is what has been described as a limitation in #6664 (comment)

Thanks for refreshing my memory. You're right, it's something we didn't implement due to the limitations of our implementation at the time.

@rescript-lang rescript-lang deleted a comment Aug 28, 2024
@anmonteiro
Copy link
Contributor Author

@mununki to fix this, you can probably attach an attribute to the primitive translation here:

https://github.com/rescript-lang/rescript-compiler/blob/30b38a0aaab27ad4c99f34037b1cc4d61589da8e/jscomp/ml/translcore.ml#L504-L510

that you then use when compiling the lambda

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 a pull request may close this issue.

2 participants