-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Leave out .js so Metro can resolve native variant #7675
Conversation
We can also try using react-native field instead as suggested here: facebook/metro#59 (comment). For some reasons they usually add an extension in the path provided in the main field. I’m not sure why. We probably should to contact npm support to confirm it. |
Thanks for the research @gziolo ! I hated to have the I will test out the |
This reverts commit e2de6d2.
And let it point to the extension-less index module so Metro can decide which module to resolve to, as normal.
Reverted the previous change and implemented the solution based on the I opted for a "extension-less" entrypoint for RN to allow Metro use its resolve policy as normal. Let me know if you have other thoughts on this. I tested the solution against this PR over at the RN app repo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, you can use build/index.native.js
as we don't have other overrides. It's colocated with the code, so you know upfront what options are there. If you prefer it, we can leave it as is 👍
Do we need to add react-native
fields to other packages that use RN overrides? I'd prefer to include them all in this PR.
True, we can also point to the full filename. I'm not yet 100% which approach is best for the RN case; we should keep an open eye on this. Let's leave it extension-free for now since it feels more Metro-native (but not as much npm-native) and we can revise in the future if new info comes up.
Currently, there is no other package in the Edit: over DM, @gziolo gave a 👍 to merge as is so, will do that now. |
@gziolo , I just found out that the An idea is to try is to leave Edit: here's the error occurring in Travis for the RN app: https://travis-ci.org/wordpress-mobile/gutenberg-mobile/jobs/399907186#L523 |
I see, I wrote to one of the maintainers of Jest, let's see if they have any solution ready. I couldn't find anything like that in their repository. |
Another false negative @gziolo 😢 . I've updated the RN app (see wordpress-mobile/gutenberg-mobile#61 (comment)) to consume packages directly from I think we can probably lower the priority of fixing this. We'll still want to remove the highly undocumented |
Description
This PR drops the
.js
extension from@wordpress/element
'spackage.json
entrypoint definitions so when used in the mobile RN app the correct module (index.native.js
) can be resolved by Metro.The same treatment should probably be performed in all packages, or at least the ones that have native mobile specializations but, let's do that step by step starting with the
element
package that currently is breaking the RN app (at the time of writing, commit hash).How has this been tested?
Ran
npm run dev
successfully.Types of changes
Bug fix: Modify the
@wordpress/element
package entrypoint definitions (main
,module
).Checklist: