-
Notifications
You must be signed in to change notification settings - Fork 904
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
Move all metro logic and commands into a metro package #1447
Move all metro logic and commands into a metro package #1447
Conversation
…making them available to external users.
I love this! It's something I wanted to do for a really really long time! Can you do one more thing, rename The idea is that one should be able too completely replace Metro with e.g. Webpack or other bundler by removing CC: @tido64 |
Happy to help! This turned into a big PR, so you have a lot of reading to do :). The I had to move a few "tools" from |
No worries, that's something I've been waiting for quite some time to see, so I am more than happy to review it! |
In the future release of React Native, I would like to discuss an opportunity of moving Metro dependency to a user project, so that they can define bundler and complementary CLI plugin for it. |
That sounds good. We should sync up on what you have in mind, and how I can help. Sent you a friend request on Discord to work out the details in DMs. |
I'm sure @grabbou will prioritize this the next time he works on this lib |
Yes, I am working on this this week. Will be reviewed on Wednesday. |
Update: I am still in progress with this one, expected update tomorrow |
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.
Conceptually, everything looks fine. I have left some comments, but I believe this is going to be the final round.
TL;DR:
- Let's not export "all" (via
export * from 'foo.ts'
) and avoid creatingindex.ts
in folders - Prefer
export default
instead of single named exports per file (sticks consistent with the rest of the codebase, happy to revisit later in a separate PR) - Export explicitly the public interface via
src/index.ts
(instead of*
) - Do not change current exported/private functions beyond the
loadMetroConfig.ts
that is subject to this PR (unless there's a need for an additional function - then, it's welcome)
I am happy to hop on a Discord/Hangouts call to discuss this in a bit more details if necessary. Thank you for working on that!
I think I've addressed all these points in my latest push. Use default exports. And all public API exports are now explicit, and only what @react-native-community/cli needs to consume (the |
Looks like an e2e test failed. I can't log into circleci to find out details. It wants too much access to my Microsoft github account, so I can't sign in. When I run 'yarn test' and 'yarn test:ci:e2e' (the command circleci runs), I get success. If I broke something, I'll need help diagnosing. In the meantime, I tried merging the upstream master, to kick off another build to see if it fails with the latest commits. |
packages/cli/src/commands/index.ts
Outdated
startCommand as start, | ||
bundleCommand as bundle, | ||
ramBundleCommand as ramBundle, | ||
} from '@react-native-community/cli-plugin-metro'; |
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.
In the future, we can remove this when this plugin becomes direct React Native dependency.
Here's a snippet:
https://github.com/facebook/react-native/blob/main/react-native.config.js#L16
I believe it should simply say metro.commands
, but this is to be decided on the planning meeting.
I updated your PR with some further naming changes. The primary change was to group commands into Please let me know if you're happy with how it looks and whether the public API satisfies your use case. |
export { | ||
bundleCommand, | ||
ramBundleCommand, | ||
buildBundleWithConfig, |
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.
I need buildBundleWithConfig to be publicly exported.
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.
Added (along with CommandLineArgs type) in my latest push
Everything looks ok to me. One function export and a type were removed during the shuffle, so I added them back in. I need to be able to call |
LGTM. |
The CI failure looks unrelated. I will move forward and merge this PR. |
Summary:
I am working on a project where I need to do Metro bundling using the Metro APIs. The CLI has really useful Metro config and Metro bundling logic that I want to use, but it's tied up and not accessible.
This PR move the Metro configuration and bundling logic into separate packages, making them available for my project and to other external users.
Test Plan:
Code is moving, with minimal changes, including tests. Verify that the build passes and that all tests pass.
Manually verify that bundling works on a sample app. Diffed bundles using existing release of CLI vs this PR. Bundle size and md5 hashes were identical.