-
Notifications
You must be signed in to change notification settings - Fork 631
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
Metro 0.25+ is resolving package.json within react-native/.../__fixtures__ directory #139
Comments
Yup, this is related to changes I made recently!
So, what was happening before is that Metro was already resolving to the fixture version first. However, it would try to resolve the With the last version of Metro, for the sake of correctness, Metro immediately fails if a So I believe crashing early to prevent that is the best solution. The reason Metro resolves the fixture first, instead of the To mitigate the issue, could you try adding the fixtures folder to the blacklist? More specifically, there is a configuration function called module.exports = {
getBlacklistRE() {
return /.*\/__fixtures__\/.*/;
},
}; Going forward, I agree we need to find a reliable long-term solution for this problem. I'm considering whether we could disable Haste package resolution by default, or adding these fixtures to the default list of ignored folders. |
Thanks for the thoughtful reply, @jeanlauliac. I can understand the justification for throwing these errors today — in fact, it would be a very challenging regression to debug if old sources to The It's a bit upsetting that Haste resolution must be enabled in the first place (since RN is the only package in most non-FB RN projects that requires Haste resolution), but switching RN internals to use Node's resolutions algorithm would be too large a fish to fry. It also saddens me to work around this problem by adding more 'magic' to the system (i.e., adding a default blacklist regex that excludes directories based upon Jest's conventions). I feel like you're most likely to take this approach, though, so may I request that you add a config value like Finally, forgive me if this stream of consciousness isn't adequately clear. It's a very chatty day in our open floorplan office :( |
Agreed, we need to find a robust solution. One solution I'm thinking about might be to enable Haste only for very specific directories, and ignore a number of files by default. I'll look into that.
Yeah, I dislike Haste in general, as it makes everything global and hard to track. The ideal solution would be to not have Haste by default, but you're right switching RN to not use Haste is probably too much hassle for now.
Whatever is returned from |
Well, this exploded:
And many more. @jamesreggio it appears it's been mitigated already in facebook/react-native#17672, already in RN's master. But we'll keep tracking this and try to find a better solution long term. I'll also follow up on improving Metro's error messages. |
Ugh, yeah. Thanks for calling out the wrong answer here. The fact that Metro already has a builtin blacklist with knowledge of other Facebook-sponsored packages leads me to think that the right place for a hacky workaround is still on the Metro side. I like your idea of limiting Haste resolution to specific FB-sponsored packages. It feels like it will generate the least surprise in the long run. Thanks for thinking about this. |
Summary: This try to address #17672 and facebook/metro#139. We should probably not include these folders in the released version of React Native, as they are used only for testing—am I incorrect? cc MoOx, t4deu. I ran: ``` npm pack tar -t -f react-native-1000.0.0.tgz | less ``` Then verified that `__fixture__` was not part of the package. #17672 [GENERAL] [BUGFIX] [.npmignore] - Do not publish test-specific files Closes #18019 Differential Revision: D7098211 Pulled By: jeanlauliac fbshipit-source-id: 0748ad8c064450bd2a9f4d6f49675a7f74fb300f
sounds like this will break the nasty hack I'm using to get absolute imports working |
Summary: This try to address #17672 and facebook/metro#139. We should probably not include these folders in the released version of React Native, as they are used only for testing—am I incorrect? cc MoOx, t4deu. I ran: ``` npm pack tar -t -f react-native-1000.0.0.tgz | less ``` Then verified that `__fixture__` was not part of the package. facebook/react-native#17672 [GENERAL] [BUGFIX] [.npmignore] - Do not publish test-specific files Closes facebook/react-native#18019 Differential Revision: D7098211 Pulled By: jeanlauliac fbshipit-source-id: 0748ad8c064450bd2a9f4d6f49675a7f74fb300f
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I have an actual dependency upon
react-native-vector-icons
in my React Native project.(I'm on RN 0.52.0, but I've manually upgraded to metro@0.26.0 and metro-core@0.26.0 using yarn's
resolutions
feature.)React Native includes a
package.json
forreact-native-vector-icons
as a test fixture here: https://github.com/facebook/react-native/blob/master/local-cli/core/__fixtures__/files/package.json(It's been there for a long while.)
In Metro 0.25.1 onwards, the packager will resolve the fixture version of
react-native-vector-icons
, instead of resolving the actual package at the root of mynode_modules
. Because the fixture doesn't contain the full source, the packager spits out this error:What is the expected behavior?
I would expect Metro to resolve to the
node_modules/react-native-vector-icons/package.json
first, and thus silently succeed in bundling.Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
I'm on RN 0.52.0, but I've manually upgraded to metro@0.26.0 and metro-core@0.26.0 using yarn's
resolutions
feature.yarn 1.3.2
Mac OS X 10.12.6 (High Sierra)
The text was updated successfully, but these errors were encountered: