emmanueltouzery / prelude-ts

Functional programming, immutable collections and FP constructs for typescript and javascript
ISC License
377 stars 21 forks source link

Vite util.inspect #52

Closed wuzzeb closed 3 years ago

wuzzeb commented 3 years ago

Hi, I recently switched to vite for building but get an error "util.inspect is not defined" from Value.ts when opening in the browser. I briefly tried looking why say webpack polyfills util.inspect but vite does not. But then on the node documentation for util.inspect https://nodejs.org/api/util.html#util_util_inspect_custom it mentions that the symbol is also available at Symbol.for("nodejs.util.inspect.custom").

So rather than try and deal with polyfills, I just switched prelude-ts to use Symbol.for which in the browser will just create a new symbol while on node will find the correct symbol.

I'll admit I just made the change directly in node_modules just to get by since I am just evaluating switching to vite. I can create a real pull request if you like.

emmanueltouzery commented 3 years ago

it seems your solution is probably really the right one. Did you check whether with your fix the display in the node repl works OK? If you have time to make a PR, it would be great, otherwise I'll try to do this & re-release ASAP.

emmanueltouzery commented 3 years ago

I published 1.0.3 on npm with your changes, maybe the release takes some time to become visible but presumably it's a matter of hours. Thank you again!