-
Notifications
You must be signed in to change notification settings - Fork 35
top-level await not possible #1178
Comments
Unfortunately, this is currently not possible as esbuild does not have support for transpiling top level awaits, so it cannot be used in commonjs modules, which zip-it-and-ship-it produces. We are still experimenting with ES modules and how we best want to integrate this into the whole flow. I will use your request for TLA in our discussions. |
It really just shouldn't though. It really shouldn't have ever relied on CJS. 2019 was already too late to be making new things with CJS. Would be nice to get this fixed. |
Unfortunately we didn't have another option back then, because the underlying serverless provider (AWS Lambda) hasn't added support for ESM until January 2022. This is definitely on our radar, though, and we're actively working on ways to fix this. |
😢 That is surprising they were so late. Also didn't realize Node was so far behind the browsers implementing this. |
News on this? |
I'm hitting this error with an Astro build using Netlify. The weird thing is that my files are
The error seems nonsensical giving the extension on the file... |
@james2doyle it was mentioned above, but all the Js/TS files are transpiled to cjs. When this product was being made, AWS did not have any support for ESM. It does now, but it's far more recent than you'd expect. Your filenames don't matter in that regard, just like how your functions can be TS, but they still become cjs. |
+1 |
I have a codebase that uses top-level await in a JS module. ESBuild seems to be forbidding me from using it due to the “cjs” output format.
Netlify site name: leafy-salamander-acbb48
Failing deploy: Netlify App
Source code: netlify-node16/index.js at master · acarl005/netlify-node16 · GitHub
Error:
A “fallback” function is used after the build fails, and the deploy is considered “successful”. However, the fallback function ends up crashing.
The text was updated successfully, but these errors were encountered: