isaacs / node-primordials

https://isaacs.github.io/node-primordials/
11 stars 3 forks source link

Fails to import in browsers #5

Closed jcbhmr closed 1 year ago

jcbhmr commented 1 year ago

image

Try this in your devtools

let m1; m1 = await import("https://esm.sh/node-primordials")
let m2; m2 = await import("https://esm.run/node-primordials")
let m3; m3 = await import("https://unpkg.com/node-primordials")
isaacs commented 1 year ago

It's a hybrid module. If you're loading from an ESM env, you need to specify that you want the "module", not the "main". For example: https://unpkg.com/node-primordials?module

jcbhmr commented 1 year ago

Doesn't work.

image

It's probably down to the use of process without a if (typeof process !== "undefined") gate? 🤔

isaacs commented 1 year ago

What browser are you using? It loads fine in Safari.

isaacs commented 1 year ago

Ah, I see it. Just need a better fallback.