What is metro bundler in react-native?

前端 未结 3 2097
醉酒成梦
醉酒成梦 2020-12-15 03:24

I am learning React Native.

I can\'t find a proper documentation for metro bundler. So, I have few questions on it. As the name suggest it creates a bundle.

3条回答
  •  天涯浪人
    2020-12-15 03:39

    Metro is a JavaScript bundler which takes in options, an entry file, and gives you a JavaScript file including all JavaScript files back. Every time you run a react native project, a compilation of many javascript files are done into a single file. This compilation is done by a bundler which is called Metro.

    Answers to your questions:

    1> Bundled file is located on the device itself on which you are building your app and is stored in different formats like in case of Android Plain bundling in which .bundle is created. Another format is of Indexed RAM bundle in which file is stored as binary file.

    2> Webpack is also a similar type of module bundler which does bundling to ReactJS web platform and its modules are accessible through browser. Bundling process is while similar to metro.

    3> These bundled files are indexed and stored in a particular numerical format and thus its easy at the run time to arrange JS files in order.

    There are multiple functions of Metro bundler and you can read about the role of Metro in React Native here : https://medium.com/@rishabh0297/role-of-metro-bundler-in-react-native-24d178c7117e

    Hope it helps.

提交回复
热议问题