什么是 react-native 中的 Metro bundler? [英] What is metro bundler in react-native?

查看:30
本文介绍了什么是 react-native 中的 Metro bundler?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 React Native.

I am learning React Native.

我找不到合适的 Metro bundler 文档.所以,我有几个问题.顾名思义,它创建了一个包.

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.

  1. 但是捆绑文件在哪里?
  2. 这和 webpack 一样吗?
  3. 那个包文件有什么用?

推荐答案

React Native 应用程序是运行一些 Javascript 的已编译应用程序.每当您构建和运行 React Native 项目时,都会启动一个名为 Metro 的打包程序.您之前可能已经在终端中看到过这个输出,让您知道打包程序正在运行.

A React Native app is a compiled app that is running some Javascript. Whenever you build and run your React Native project, a packager starts up called Metro. You’ve probably seen this output in your terminal before, letting your know the packager is running.

打包者做了几件事:

将您所有的 Javascript 代码合并到一个文件中,并翻译您的设备无法理解的任何 Javascript 代码(如 JSX 或一些较新的 JS 语法).

Combines all your Javascript code into a single file, and translates any Javascript code that your device won’t understand (like JSX or some of the newer JS syntax).

将资产(例如 PNG 文件)转换为图像组件可以显示的对象.

Converts assets (e.g. PNG files) into objects that can be displayed by an Image component.

参考:https://hackernoon.com/understanding-expo-for-react-native-7bf23054bbcd

这篇关于什么是 react-native 中的 Metro bundler?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆