-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Description
- Version: v10.1.0
- Platform: Linux (Arch)
- Subsystem: util
Please consider supporting util.inspect.custom as a public/global symbol either by:
- changing
util.inspect.customfrom a private symbol (e.g.Symbol('util.inspect.custom')) to a public symbol (e.g.Symbol.for('util.inspect.custom'))
or:
- accepting a public symbol as an alternative to the private symbol, just as
"inspect"is currently accepted as a (deprecated) fallback for the symbol
Changing it from a string to a symbol was a great idea 🎉 and it's a perfect use case for a symbol, but, as mentioned here, making it private makes it painful to write code that both a) provides an inspect hook if it's loaded in node and b) works seamlessly in the browser if it's not.
A workaround has been implemented as an NPM module, inspect-custom-symbol (cc @mafintosh), which uses the browser field in its package.json to provide a substitute symbol without pulling in the util library in bundlers such as Browserify and Webpack. It's much better than trying to work around this with a tower of late-bound typeof util.inspect.custom checks, but it doesn't fix the underlying issue and it's not ideal:
- it doesn't work in all situations/environments
- it requires an extra dependency
- most people with this dilemma won't be aware of it