-
Notifications
You must be signed in to change notification settings - Fork 48
ESM compatibility: Fix crash on missing global env vars #188
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.. doesn't solve the problem, but at least this makes it possible for anyone to solve it themselves.
We will need to figure out a separate proper solution that is backward-compatible.
@evanderkoogh: Exactly! How the public API needs to change is best left to you but until then using this we can work around the issue. As mentioned in the PR if backwards compatibility is a requirement a new optional last |
It seems actually that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'm not super familiar with ESM on Workers yet, but the change makes sense.
Would it be possible to get a release that includes this fix? Until this fix is released, I have to fork this library to use it in my worker project, but would love to use the real thing again :) |
@Cherry we should release a new version this week :) |
💯 I'll shoot you a message |
Fixes kv-asset-handler crashing when env vars are missing as is always the case with the new ESM module syntax which wraps those in an env object that is passed explicitly.
This partially fixes the problems reported in #174, for the other half of the solution just wrap
{ request }
and ts-ignore the typescript error to pass in the event object togetAssetFromKV
. I did not do this change to stay backwards compatible until this is addressed properly by the Cloudflare team.