You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our Vite plugin, during development instead of normally importing modules, we use workerd's unsafe eval to evaluate and run their code.
This is so that we can integrate with the Vite Environment API and correctly integrate with Vite's dev modules handling (Vite doesn't work with real ESModules and has it's own custom modules structure, with that they can have more control over them, allow modules invalidations, etc...)
The issue here is that there might be differences between the evaluation of anonymous functions and actual ESModules importing, in particular we know that I/O operations can't be performed on the top level of a dynamically imported modules inside workerd.
This is problematic because this means that we end up with diverging behaviors during dev and production.
I am opening this issue to see if we could have some sort of API or any way to get unsafe eval to actually run code in the same manner as code run in imported modules, allowing us to cleanly reproduce the production during development as well.
PS: We had some further discussion about this and preventing I/O operations in unstafe evaled code could actually not even work for us as we do rely on some global state anyways 😕 (for context: flarelabs-net/vite-plugin-cloudflare#83 (comment))
So this might actually not be a valid/valuable idea at all 😕
In our Vite plugin, during development instead of normally importing modules, we use workerd's unsafe eval to evaluate and run their code.
This is so that we can integrate with the Vite Environment API and correctly integrate with Vite's dev modules handling (Vite doesn't work with real ESModules and has it's own custom modules structure, with that they can have more control over them, allow modules invalidations, etc...)
The issue here is that there might be differences between the evaluation of anonymous functions and actual ESModules importing, in particular we know that I/O operations can't be performed on the top level of a dynamically imported modules inside workerd.
This is problematic because this means that we end up with diverging behaviors during dev and production.
I am opening this issue to see if we could have some sort of API or any way to get unsafe eval to actually run code in the same manner as code run in imported modules, allowing us to cleanly reproduce the production during development as well.
For more context: flarelabs-net/vite-plugin-cloudflare#83 (comment)
The text was updated successfully, but these errors were encountered: