unjs / unenv

🕊️ Convert javaScript code to be runtime agnostic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto-mocking proxy not compatible with Conversion to primitive value

chrisspiegl opened this issue · comments

Describe the feature

I am trying to use unenv to get something to work with the use of rollup and in another project with nuxt.js

I found that the auto mocking proxy runs into issues when the requesting library tries to convert something to a primitive value as in this example:

file:///Users/.../_worker.js:107963
    [http2$1.constants.HTTP2_HEADER_STATUS]: http2$1.constants.HTTP_STATUS_OK,
                       ^

TypeError: Cannot convert object to primitive value

I had the same issue with a library doing something like this:

const sys = os.platform()
if (sys && sys.length > 3) {}

In this case the auto mocking failed because the sys.length can't be provided as a primitive value.

Not sure this can be somehow enhanced but I thought I'd share my findings here.

Additional information

  • Would you be willing to help implement this feature?

Hi. This is because node:https is not implemented. Moving issue to #92