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

Support for top-level await in ESModule #118

Open
DominicRoyStang opened this issue Dec 3, 2024 · 4 comments
Open

Support for top-level await in ESModule #118

DominicRoyStang opened this issue Dec 3, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@DominicRoyStang
Copy link

When the kysely.config.ts file contains top-level await or imports a file that has top-level await, and the package.json type field is set to module, running kysely migrate:make <migration name> errors-out with the following message

SyntaxError: await is only valid in async functions and the top level bodies of modules

In my case, this top-level await is used to fetch the database password from a secret manager.

Repro repository: https://github.com/DominicRoyStang/kysely-ctl-async-bug

@igalklebanov igalklebanov added the bug Something isn't working label Dec 4, 2024
@igalklebanov
Copy link
Member

Hey 👋

Thanks for raising this and providing a reproduction.

@Zn4rK
Copy link

Zn4rK commented Dec 16, 2024

It looks like this would be solved with a new version of c12:
https://github.com/unjs/c12/blob/7c425ef16a3f87f468235beddbd0223b2080eba5/package.json#L44

unjs/jiti#72 (comment)

Specifying a newer version of c12 in package.json confirms this:

"resolutions": {
    "c12": "^2.0.1"
  },

@igalklebanov
Copy link
Member

Try this preview build:

npm i https://pkg.pr.new/kysely-org/kysely-ctl@07e409c

@noudadrichem
Copy link

Same. The new build works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants