Skip to content

fix: handle dynamic imports with module aliases #7452

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

Merged
merged 1 commit into from
May 12, 2025

Conversation

cristianoc
Copy link
Collaborator

Fixes #7403

When a module containing an alias (e.g. module VS = VariantSpreads) is dynamically imported, the compiler now correctly extracts the original module identifier from the Llet expression.

Fixes #7403

When a module containing an alias (e.g. `module VS = VariantSpreads`) is
dynamically imported, the compiler now correctly extracts the original
module identifier from the Llet expression.
@cristianoc cristianoc force-pushed the dynamic-import-module-with-alias branch from cc6459e to cf92334 Compare May 9, 2025 12:10
@@ -442,6 +442,22 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) :
in
Lam.function_ ~attr ~arity:(List.length params) ~params
~body:(convert_aux body)
| Llet (_, _, _, Lprim (Pgetglobal id, args, _), _body) when dynamic_import
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mununki is this the correct way to handle the case?

@cristianoc cristianoc requested review from mununki, cknitt and zth May 9, 2025 12:11
Copy link

pkg-pr-new bot commented May 12, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7452

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7452

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7452

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7452

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7452

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7452

commit: cf92334

@cristianoc cristianoc merged commit a538eb0 into master May 12, 2025
22 checks passed
@cristianoc cristianoc deleted the dynamic-import-module-with-alias branch May 12, 2025 11:14
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.

Dynamic module import errors
2 participants