In the future using top-level await might be cause a backwards compatibility break in Node
23-Oct-2024 183
This is called a dynamic import and it’s extra annoying, because you can’t just put this at the top of your file. It returns a Promise, so you can only import these modules ‘asynchronously’ or in functions. The reason is that you can only await inside functions in CommonJS files. So this syntax prevents importing a “module” and immediately using it. To use a module in CommonJS, you’ll need some kind of initialization logic.
.
In the future using top-level await might be cause a backwards compatibility break in Node #js #javascript #future #using #top-level #await #might #cause #backwards #compatibility #break https://javascript.ba/link/in-the-future-using-top-level-await-might-be-cause-a-backwards-compatibility-break-in-node