Allow server side Top Level Await #5203
Replies: 18 comments 8 replies
-
The error message seems quite self-explanatory: top level await are not available for node14. |
Beta Was this translation helpful? Give feedback.
-
Problem is largely here, remix build doesn't allow you to configure any other target. I'll reference the two files responsible. remix/packages/remix-dev/build.ts Lines 15 to 20 in 42fb183 remix/packages/remix-dev/compiler.ts Line 75 in b35e135 remix/packages/remix-dev/compiler.ts Line 105 in b35e135 I've thrown together a fork which bumps every reference to >= Node 14 to >= Node 14.8 and it seems to be working. The large problem is the actual ESBuild target used by Remix isn't configurable. |
Beta Was this translation helpful? Give feedback.
-
I'll admit this is a bit of a bandaid solution as it just bumps the Node requirement and the ESBuild target. Would it make more sense to expose the ESBuild options to the remix configuration file? We're going to keep having these problems otherwise as javascript syntax changes. |
Beta Was this translation helpful? Give feedback.
-
I'm failing to see the issue here @joshocalico: If you want to be able to use TLA in your project, then you need to make sure you run it on a compatible node version. What am I missing? Opening the esbuild configuration to user land is a different topic, I think there's an open discussion about it. |
Beta Was this translation helpful? Give feedback.
-
@machour I think it'd be a bit obvious from what I've posted and the code quoted. |
Beta Was this translation helpful? Give feedback.
-
Would be great to have more modern Node support from Remix. Any update @machour? |
Beta Was this translation helpful? Give feedback.
-
@jgentes someone from the Remix team will eventually pick this up, I'm just volunteering for triage. |
Beta Was this translation helpful? Give feedback.
-
I think this may have been addressed by #4034? |
Beta Was this translation helpful? Give feedback.
-
@mcansh is that the case? |
Beta Was this translation helpful? Give feedback.
-
not that i know of, esbuild's target is still |
Beta Was this translation helpful? Give feedback.
-
Converting this to a Proposal discussion, as per our Development Process. |
Beta Was this translation helpful? Give feedback.
-
We could benefit from targeting a more recent version of node as well. Hopefully this will be picked up quickly. |
Beta Was this translation helpful? Give feedback.
-
give the original posting an "up vote" and it will end up higher on our list when we go looking for new things to add to the roadmap :) |
Beta Was this translation helpful? Give feedback.
-
Upvoted as well. Not sure if there is a new work around or update since Feb, but this is preventing full use of remix using something like https://sst.dev. https://discord.com/channels/983865673656705025/1098809540075593758 I've tried a few things like setting https://remix.run/docs/en/1.15.0/file-conventions/remix-config#servermoduleformat, but still getting the top level await error:
|
Beta Was this translation helpful? Give feedback.
-
Do we still have this issue as we are using elasticsearch npm package in remix which internally uses undici package(which internally uses worker_threads.js (jspm core module ), I suppose which uses top level awaits). In short we are not able to deploy the app via docker as top level await error gets thrown. Kind of blocker for me. Is there a way I can fix this temporarily so that we can use this library? Is there any way to make remix use latest node engine (if I am getting it right) We are using remix with express server. I am very sorry, as this is my first post? (or is there any other place where this discussion is open) @joshocalico Do you have your solution uploaded anywhere so that I can take a look? Or am I missing something here? Please do point me to the right place if this is not the right forum for this discussion as we need to go live with the application. |
Beta Was this translation helpful? Give feedback.
-
This will be fixed once #7291 is merged |
Beta Was this translation helpful? Give feedback.
-
Closed by #7292 |
Beta Was this translation helpful? Give feedback.
-
I also got this error when upgrading to remix to use vite. |
Beta Was this translation helpful? Give feedback.
-
What version of Remix are you using?
Latest (1.7.1)
Steps to Reproduce
Use this export in any loader or server file.
Note: this doesn't apply to client side Javascript/Typescript as Remix rightfully respects the tsconfig / jsconfig.
Expected Behavior
It will evaluate the promise inside the module while it is being imported.
Actual Behavior
The app doesn't build.
Beta Was this translation helpful? Give feedback.
All reactions