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

Closed
DominicRoyStang opened this issue Dec 3, 2024 · 5 comments
Closed

Support for top-level await in ESModule #118

DominicRoyStang opened this issue Dec 3, 2024 · 5 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file esm ES Modules related jiti jiti related

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!

@igalklebanov
Copy link
Member

Should be resolved in https://github.com/kysely-org/kysely-ctl/releases/tag/v0.10.0.

@igalklebanov igalklebanov added dependencies Pull requests that update a dependency file esm ES Modules related jiti jiti related labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file esm ES Modules related jiti jiti related
Projects
None yet
Development

No branches or pull requests

4 participants