-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
circular reference cause inherits()
became empty object
#80
Comments
I don't see why - the inherits package has a "browser" field which bundlers should be handling automatically, and in node it would need to be "inherits" directly. |
@ljharb wow that's quick reply, we are using it in react native, neither node nor browser, there are potentially more js runtime out there... |
Sure, that's fine - metro should either be able to handle circular references or it should use the browser endpoint, since RN is much more browser-like than node-like. This is a node module, so it's up to transformation tools to handle using it in anything other than node (altho "browsers" are especially important). |
thx for the reply, 2 cents of my understanding:
this is a module that mimic a node module, not the node module itself.
just fyi, react native is far from the browser, it doesn't have dom api, it doesn't have the globals available in browser and there is no regulation and authorities that control what is available in react nataive. so unfortunately there is no golden rule or silver bullet in terms of which platform to use, package support is difficult to find, but RN is a growing community, i wish the maintainer of this lib do consider support of it in the future. |
ha, true enough :-) this is a node module intended for transparent replacement by a bundler for browser usage. Either way, supporting circular references are required to support CJS as well as ESM, so that seems like the underlying problem here for metro. |
the line below refs to
inherits()
frominherits
module, butinherits
module reference back toutil
module by checking the implementation onutil
module first, causing the firstrequire('inherits')
to returns empty object (default exports is empty object), if thenutil.inherits()
gets call immediately it will throw.problematic line in question:
https://github.com/browserify/node-util/blame/ef984721db7150f651800e051de4314c9517d42c/util.js#L592
the line needs to be updated to
require('inherits/inherits_browser')
The text was updated successfully, but these errors were encountered: