fermyon / spin-js-sdk

https://developer.fermyon.com/spin/javascript-components
Apache License 2.0
54 stars 18 forks source link

`process` not defined #88

Closed radu-matei closed 2 months ago

radu-matei commented 1 year ago

I am trying to use an external package and the build fails with: Uncaught ReferenceError: 'process' is not defined

karthik2804 commented 1 year ago

Which package is this? @radu-matei

It would help us to identify which parts of the API, we would need to implement.

radu-matei commented 1 year ago

https://www.npmjs.com/package/@upstash/redis

karthik2804 commented 1 year ago

@radu-matei Was this error caused when importing the library outside the handleRequest function? if so it is because the process module is added to the global scope only when the function is called and set up with the values passed from spin. It should work if the library is imported inside the handleRequest function. I will look into if we can initialize it earlier so that this error does not happen when compiling with wizer.

Edit: Found the fix, will PR in the next couple of days.

karthik2804 commented 2 months ago

This should now be possible with the new SDK and the wasi-ext package.

endocrimes commented 2 months ago

FWIW I just ran into this on v2.2.0 when importing https://github.com/cloudevents/sdk-javascript after polyfilling http/https/events with browserify (but also when importing cloudevents in the request handler)