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

feat: basic top-level await support #239

Merged
merged 5 commits into from
Jun 5, 2024
Merged

feat: basic top-level await support #239

merged 5 commits into from
Jun 5, 2024

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Jun 5, 2024

This PR supports basic top level await support via jiti.import() and jiti <path> CLI.

Implementation is fairly basic and adds support by wrapping the module into an async function instead of function that Node.js does.

In order to allow chained usage, since jiti transforms all imports to require internally, we replace = require( patterns to = await require in async contexts to make sure they are resolved. (this is more of a workaround but better than not having it!)

@pi0 pi0 marked this pull request as draft June 5, 2024 12:55
@pi0 pi0 marked this pull request as ready for review June 5, 2024 14:41
@pi0 pi0 merged commit ace9b72 into main Jun 5, 2024
5 checks passed
@pi0 pi0 deleted the feat/top-level branch June 5, 2024 14:41
@pi0 pi0 mentioned this pull request Jun 5, 2024
@aryaemami59
Copy link
Contributor

This is very exciting.

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.

2 participants