-
Notifications
You must be signed in to change notification settings - Fork 613
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
NPM modules being preferred over Haste modules #18
Comments
I think Haste modules are always preferred, but it's possible it is a problem in |
So another few hours of debugging, and I found that resetting the cache fixes things. Posted a follow-up with my analysis of why various voodoo magic fixes worked: facebook/react-native#13765 (comment) No idea what led to a corrupted cache in the first place. I have my old "busted" cache, if you are interested still. The relevant merge bit, which explains why it was skipping the haste resolution and falling back on node module resolution:
And the
|
Ohhh! This is very useful, thank you. Unfortunately, I expect thing to get broken again. This is actually a legitimate problem, and it needs to generate an error more proeminently. The duplication of modules stored in the
|
Glad to hear it helped! FWIW, I believe this duplicate module Unfortunately, judging from the bug that led me here, I'm not sure anyone on the RN side is aware of this duplicate module issue yet. |
Last time I looked into this for RN 0.45, I think I arrived at a similar conclusion. In RN, |
In my case, I believe Not sure if I was doing something wrong to achieve that end-result? In case it's relevant, I was building react-native myself, and then |
Could you perhaps have had multiple copies of |
That's what it looks like from the last JSON snippet you posted: "merge":{"g":{
"/fullpath/mobile/node_modules/react-native/node_modules/merge/package.json":1,
"/fullpath/mobile/node_modules/react-native/Libraries/vendor/core/merge.js":0
}} I think if we filter out |
Ahhhh really?! Thanks for double-checking my assumptions! I was speaking on what exists in my directory now...which I mistakenly assumed was what existed back when things were broken. :( Man, talk about a So perhaps my "fix" was to have removed (going to update my "fix instructions" comment facebook/react-native#13765 in the react-native issue to reflect this) |
I make a change to |
@jeanlauliac I think this PR might fix things (filters out nested node_modules). Could you take a look at it? jestjs/jest#3984 |
The jest-haste-map PR landed (thank you @jeanlauliac!) so sometime in the future when it gets published to npm we'll be able to use it in Metro (and indirectly, RN). Fingers crossed that the duplicate module collisions are gone forever unless there are actually duplicates within a package's own code. |
Do you think we should we release a new minor/rev version off the last major to fix the issues people have right now? |
@jeanlauliac That's a nice idea, why don't we try it if it's not too much trouble to publish jest-haste-map to npm? RN 0.46 uses a version of Metro that uses jest-haste-map ^20.0.1 so people should automatically be able to get minor & patch updates. (Perhaps we should first set the |
There is an |
I released |
jest-haste-map 20.0.5 appears to be working fine in several of our projects including a test suite. |
Looks like we're good to close. Feel free to reopen if you still observe problems! |
I've debugged facebook/react-native#13765 (comment) down to an issue where RN's
var merge = require('merge')
will importnode_modules/merge
, instead of the expectedreact-native/Libraries/vendor/core/merge.js
(which contains a@providesModule merge
directive).According to the dozens of users affected, it seems to be non-deterministic behavior that sometimes resolves itself with reinstallation, different versions of node, or recreation of the directory and node_modules directory. I'm not yet sure if this nondeterminisim is a bug in React-Native library code layout, or a bug in the RN packager (aka metro-bundler?) itself...but I'm leaning towards the latter, since it seems to violate my expectations for Haste module imports.
The text was updated successfully, but these errors were encountered: