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

Remove Top Level Await #609

Open
j-mendez opened this issue Dec 6, 2023 · 1 comment
Open

Remove Top Level Await #609

j-mendez opened this issue Dec 6, 2023 · 1 comment

Comments

@j-mendez
Copy link

j-mendez commented Dec 6, 2023

Top level await makes the module incompatible with frameworks like astro.js and make it so that even using the module in an API route like nextjs.

Workaround for current top level imports.

let somethingExportable;

(async () => {
  /// logic to update somethingExportable
})()

export default somethingExportable;
@verhovsky
Copy link
Member

verhovsky commented Dec 6, 2023

To parse Bash code, curlconverter uses tree-sitter with tree-sitter-bash, which is a C library that is compiled into WASM for the browser. Loading these WASM files (there's two) has to be async for the network request or for WebAssembly.instantiate() I guess.

We could make all of curlconverter's toPython(), etc. functions async instead of using top-level async at the beginning to wait for the files to load but that would be a lot of work because on node.js there's no top-level async because tree-sitter's Node.js bindings aren't async since they don't need to load any files. So we would have to have two separate libraries on npm for curlconverter and curlconverter-web with different index.d.ts files with different signatures. It would also just be surprising, why would transforming a string into a string be async?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants