I would like to have top level await in my typescript nodejs project.
My tsconfig used to look like this:
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"lib": [
"dom",
"es6",
"es2017",
"esnext.asynciterable"
],
"skipLibCheck": true,
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
#### other stuff which I think is not relevant removed ####
And I now switched it to
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": [
"dom",
"es6",
"es2017",
"esnext.asynciterable"
],
"skipLibCheck": true,
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
#### other stuff which I think is not relevant removed ####
I have also added "type": "module" to my package.json. Indeed I now have the ability to do top level awaits however
The way it is with commonjs is so elegant - can I have the same behaviour with esnext or keep it some other way while gaining top-level await?