Alex Hunt – Metro and React Native DevX in 2023

Software Mansion
6 Jun 202326:20

Summary

TLDRアレックスは、Mata社のReact開発者エクスペリエンスチームのソフトウェアエンジニアとして、React Nativeに組み込まれたJavaScriptビルドツールであるMetroの紹介と、2023年の焦点を話します。Metroは、React Native CLIやExpo CLIがアプリケーションをコンパイルする際に使用され、JavaScriptコードと依存関係を最適化されたバンドルに変換します。MetroはReact Native開発の中心的な役割を果たしており、高速でスケーラブルなアーキテクチャを持っています。また、MetroはReact Nativeのニーズに合わせて設計されており、React Native CLIやExpo Dev Serverに組み込まれています。2022年にチームが拡大し、オープンソースコミュニティにMetroの利点を提供するようになりました。今後の焦点は、npmの互換性やDynamic Importsなどの機能の向上、React Native開発体験全体の改善にあります。また、React Nativeのデバッグ機能の強化も計画中です。

Takeaways

  • 📚 AlexはMataのReact開発者経験チームのソフトウェアエンジニアで、React Nativeに組み込まれているMetroについて話しました。
  • 🚀 MetroはReact NativeのJavaScriptビルドツールで、アプリケーションのJavaScriptコードと依存関係を最適化されたバンドルにコンパイルします。
  • 🔄 Metroは高速でスケーラブルで、エピックな規模でのパフォーマンスを維持し、開発者が即時のフィードバックを得られるように設計されています。
  • 🌟 2022年にReact Native CLIとExpo CLIが使用するようにMetroが成長し、オープンソースコミュニティと協力して機能を強化しました。
  • 🔍 MetroはReact Nativeの開発体験に組み込まれており、React Native CLIとExpo Dev Serverに組み込まれています。
  • 🔗 MetroはReact Nativeと密接に連携し、React Nativeのニーズに焦点を当てた開発ツールです。
  • 🔄 2022年には、Metroは33のリリースと52のバグフィックスを含んでいます。また、`require.context`とシンボリックリンクのサポートが追加されました。
  • 📦 パッケージエクスポートのサポートは、npmパッケージとの互換性を向上させるとともに、React Nativeのパッケージメンテナーが新しい機能を活用できるようになります。
  • 🔍 ラズリバンドルは、開発者が大規模なアプリケーションで作業する際に、コンパイルにかかる時間を短縮し、素早くアプリを開始できるようにします。
  • ⚡️ SWCはBabelの代替として、より高速なコンパイルとバンドルを可能にします。MetroはSWCと統合し、より高速で正確なバンドルを目指しています。
  • 🛠️ MetroはReact Nativeの開発体験を向上させるために、デバッグ、プロジェクト設定、アップグレードなどの他の問題にも取り組んでいます。
  • 🤝 コミュニティへの貢献を歓迎し、初心者向けの問題をリポジトリに追加し、オープンソースで機能を構築する手助けを提供しています。

Q & A

  • アレックスが所属しているチームの主な責任は何ですか?

    -アレックスは、Mata社内のReact開発者体験チームに所属しており、MetroのほかにもReact NativeとReactコンポーネントを担当しています。彼らのチームは、React開発ツールチェーンのエンドツーエンドの体験を担当しており、その中にはMetroやFB Metro(内部機能セットを持つMetroのラッパー)のカバレッジが含まれます。

  • MetroはなぜReact Nativeの開発に不可欠なツールですか?

    -MetroはReact NativeのJavaScriptビルドツールであり、アプリケーションを実行するために必要なJavaScriptコード、依存関係、アセットを準備し、最適化されたJavaScriptバンドルをターゲットプラットフォーム用にコンパイルします。また、開発中の迅速な更新や、デバイス上のJavaScriptエンジンとのインターフェースなど、React Native開発エクスペリエンスの主要な機能を支える役割を果たしています。

  • Metroがスケーラビリティを持つ理由は何ですか?

    -Metroは並列処理を使用し、ワーカーを活用して可能なかぎり不要な作業を避けることによりスケーラビリティを確保しています。また、キャッシュアーティファクトを再利用することで、同じプロジェクトで作業するチームのスピードを上げています。これにより、変更されていないファイルの再ビルドをローカルマシンが行う必要がなくなります。

  • アレックスが言及した「ファストリフレッシュ」とは何ですか?

    -「ファストリフレッシュ」は、開発中に開発者に即時のフィードバックを提供する機能で、コードベースの規模に関係なく動作します。Metroはこの機能をサポートし、開発者がコード変更を行った際に即座にフィードバックを得られるようにしています。

  • Metroが提供する「遅延バンドル」とは何ですか?

    -遅延バンドルは、開発者が作業している画面のコードのみをバンドルする新しい機能です。これにより、アプリが大きくなっても開発が素早く始められます。遅延バンドルは、標準のJavaScriptのDynamic import構文とreact.lazy APIをサポートし、必要になったときにクライアントがMetroから別々のバンドルを取得できるようにしています。

  • アレックスが言及した「パッケージエクスポート」とは何ですか?

    -「パッケージエクスポート」は、npmパッケージがパッケージエントリーポイントを指定するための現代の仕様です。これにより、React Nativeのアプリ開発者は、npmパッケージとの互換性が向上し、プロジェクトですぐに使用できるようになります。また、パッケージのエンカプスレーションや条件付きエクスポートなどの新機能を使用することもできるようになります。

  • Metroで使用されているSWCとは何ですか?

    -SWCは、Babelの強力な代替品であり、多くのWebバンドルツールで使用されています。MetroはSWCと統合することで、JavaScriptコードのコンパイルを高速化し、Reactコードをより簡単に記述できるようにしています。

  • React Nativeのデバッグに対するアレックスのチームの取り組みとは何ですか?

    -アレックスのチームは、React Nativeのデバッグを改善するために、X Google ignorelist Source map拡張機能や、Chrome DevToolsでの1クリックHermesデバッグ、React DevToolsのイントグリッシュを提供することで、デバッグの簡便化を目指しています。また、デバッグワーキンググループを形成し、パートナーと共に取り組みを進めています。

  • アレックスが言及した「ツリーシェイキング」と「バンドル分割」とは何ですか?

    -「ツリーシェイキング」は、コードベースから未使用のコードを削除することで、バンドルサイズを小さくするプロセスです。「バンドル分割」は、大きなアプリケーションを複数の小さなバンドルに分割し、必要なものだけを読み込むことでパフォーマンスを向上させる手法です。これらは、Metroで今後取り上げられる予定の最適化機能の一部です。

  • アレックスが言及した「React Native EU」とは何ですか?

    -「React Native EU」は、React Native開発者のためのカンファレンスであり、アレックスのチームはそのイベントでMetroの機能について議論し、フィードバックを得るために参加しました。これはReact Nativeコミュニティと密接に連絡を取り、共に成長する取り組みの一環です。

  • アレックスが言及した「パブリックRFC」とは何ですか?

    -「パブリックRFC」(Request for Comments)は、提案や機能の変更についてコミュニティにフィードバックを求めるプロセスです。アレックスのチームは、Metroのパッケージエクスポート機能の開発でRFCを使用し、公開してフィードバックを集め、最終的な解決策に至るまで繰り返し議論しました。

Outlines

00:00

👋 紹介とチームの拡大

アレックスはMataのReact開発者経験チームのソフトウェアエンジニアとして、React NativeとMetroの統合、新機能、2023年の焦点について語ります。彼らは主にロンドンに拠点を置いており、2022年に大幅に成長しました。チームはReact NativeとReactのコンポーネントをサポートし、開発者ツールチェーン全体を担当しています。また、FB Metroと呼ばれる内部機能セットでMetroをラップし、JavaScriptツールチェーン、デバッグ、React DevToolsをカバーしています。

05:05

🚀 Metroの役割と将来の展望

MetroはReact NativeのJavaScriptビルドツールであり、バンドラーとして機能します。Expo CLIやReact Native CLIで使用され、アプリケーションのJavaScriptコードを最適化されたバンドルにコンパイルします。MetroはReact Native開発ループに深く統合されており、開発者が即時のフィードバックを得られるように設計されています。MetroはEpicの規模でパフォーマンスを発揮し、並列処理とキャッシュを活用してスケーラビリティを実現しています。また、オープンソースコミュニティとの連携を強化し、FB MetroからオープンソースのMetroへの機能移行を進めています。

10:07

🔍 Metroの新機能と改善点

MetroはReact Nativeニーズに焦点を当てた開発ツールであり、React NativeがMataで成功するUIフレームワークとなることを支援します。チームは、より幅広い機能を提供し、オープンソースコミュニティと密接に協力して開発を進めています。重要な改善点として、Dynamic Imports、シムリンク、npmの互換性、およびパッケージエクスポートが挙げられます。これらの機能は、React Nativeの開発者により多くの柔軟性とnpmパッケージとの互換性を提供します。

15:09

🛠️ 2022年および2023年のハイライト

2022年から2023年現在までに、Metroは33のリリースと52のバグフィックスを提供しました。注目すべきは、require contextと呼ばれる外部貢献で、これはExpoから貢献され、Metroに組み込まれています。また、シムリンクのサポートが追加され、npmパッケージマネージャーやworkspaces、monoreposのサポートが向上しました。さらに、パッケージエクスポートのサポートが追加され、React Nativeの開発者により多くのnpmパッケージとの互換性を実現しました。

20:10

🔗 開発中の新機能と改善

Metroは、遅延バンドル機能を組み込み、開発者が大規模なアプリケーションを扱いやすくなります。遅延バンドルは、Dynamic import構文とreact.lazy APIをサポートし、必要に応じてコードをバンドルします。また、SWCという高速コンパイラの使用を検討し、Babelの代わりに使用することで、Reactコードをより簡単に記述できるようにしています。さらに、Metroはインクリメンタルビルドシステムを改善し、より正確で高速なビルドを実現しています。

25:12

🔧 デバッグとReact Native開発体験の改善

React Nativeのデバッグ機能の強化が進められており、Chrome DevToolsで見るスタックトレースを改善する機能が追加されました。また、One-click Hermes debug機能を提供し、開発者が簡単にデバッグできるようにしています。さらに、React DevToolsの改善と、デバッグ用のブラウザライクなUIコントロールが計画されています。これらの機能は、React Native開発者の開発体験を向上させることを目指しています。

🤝 貢献者の歓迎とコミュニティへの協力

Metroはオープンソースプロジェクトであり、新しい機能や改善点を歓迎しています。リポジトリには良い最初のissueが作成されており、コミュニティのメンバーが貢献しやすくなっています。また、React Native開発体験全体を改善するために、Metro以外の問題にも取り組む予定です。

Mindmap

Keywords

💡React Native

React Nativeは、Facebookによって開発されたクロスプラットフォームのフレームワークで、JavaScriptを使用してiOSとAndroidのネイティブアプリケーションを開発できます。このビデオでは、React Nativeの開発体験チームがMetroというJavaScriptビルドツールについて話しており、React Nativeの開発プロセスに密接に関与しています。

💡Metro

MetroはReact NativeのJavaScriptビルドツールであり、アプリケーションのJavaScriptコード、依存関係、アセットをReact Nativeで実行するための最適化されたJavaScriptバンドルを作成します。ビデオでは、MetroがReact Nativeの開発ループに深く統合されており、開発者が即時のフィードバックを得られるようにサポートしていると説明されています。

💡Fast Refresh

Fast RefreshはReact Nativeの機能で、開発者がコードの変更を即座にプレビューできるように設計されています。ビデオでは、Metroがこの機能をサポートし、開発者が大規模なコードベースで迅速に作業できるようになるものとされています。

💡SWC

SWCは高速なコンパイラで、Babelの代替として多くのウェブバンドルツールで使用されています。ビデオでは、MetroがSWCと統合することで、Reactコードの書込みを容易にし、バンドルプロセスをさらに高速化する可能性があると触れています。

💡Lazy Bundling

Lazy Bundlingは、開発者が作業している画面のコードだけをバンドルするMetroの機能で、アプリの起動時間を短縮し、開発体験を向上させます。ビデオでは、大きなアプリケーションでの開発プロセスを高速化するためにLazy Bundlingが導入されており、標準のJavaScriptのDynamic import構文とReact.lazy APIをサポートしていると説明されています。

💡Package Exports

Package Exportsは、npmパッケージがパッケージエントリーポイントを指定するための最新の仕様であり、Node.jsランタイムとバンドラーでサポートされています。ビデオでは、MetroがPackage Exportsをサポートすることで、React Nativeのアプリ開発者がnpmパッケージとより互換性のあるプロジェクトを作成できるようになると述べています。

💡Sim Links

Sim Linksは、ディレクトリやファイルへのシンボリックリンクを追跡できるMetroの機能で、開発者がより柔軟なパッケージ管理と依存関係のオーバーライドができるようになります。ビデオでは、Sim LinksがMetroに追加され、開発者がシンボリックリンクを含むプロジェクトをより効率的に扱えるようになると紹介されています。

💡Incremental Build System

Incremental Build Systemは、変更された部分だけを再ビルドすることで、ビルド時間を短縮するシステムです。ビデオでは、Metroがインクリメンタルビルドシステムを改善し、より正確で高速な開発体験を提供する取り組みを行っていると説明されています。

💡Debugging

デバッグは、ソフトウェア開発者がアプリケーションのバグを特定し修正するプロセスです。ビデオでは、React Nativeのデバッグ体験の向上が重要な領域として挙げられており、Metroチームがデバッグ機能を改善し、開発者がより効率的に作業できるように取り組んでいると述べています。

💡Open Source Community

オープンソースコミュニティは、ソフトウェアの開発と配布を通じて協力し合う人々で構成されています。ビデオでは、Metroチームがオープンソースコミュニティと密接に連携し、Metroの機能を共有し、コミュニティからのフィードバックに基づいて改善を進めていると語っています。

💡Epic Scale

Epic Scaleは、非常に大規模なプロジェクトを扱うことを意味し、ビデオではMetroがFacebookのモバイルコードベースをサポートしていると触れています。これは約30万以上のJavaScriptソースファイルと175以上のReact Nativeアプリエントリーポイントを1つのMetro設定で実行していることを示しています。

Highlights

Alex is a software engineer on the React Developer Experience team at Meta, focusing on Metro and its integration with React Native.

The React Developer Experience team is based in London and has grown significantly in 2022.

Metro is a JavaScript build tool for React Native, acting as a bundler and preparing code for the target platform.

Metro is deeply integrated into the React Native development loop, supporting features like fast refresh and JavaScript debugging.

Metro's architecture allows for parallel work and efficient caching, enabling scalability at Epic's scale.

The team has been focusing on improving npm compatibility and addressing issues like dynamic imports and symbolic links.

Metro is transitioning features from FB Metro to open source and engaging more with the community.

The team has formed a bundler working group and hosted a Core Contributors Summit to gather feedback on Metro features.

Microsoft has been a significant partner, contributing feedback and use cases for improving Metro's behavior on Windows.

Expo has collaborated with the team on performance optimizations and new features like CSS support and server-side rendering.

The vision for Metro is to be a modern, fully web-compatible build system for truly universal apps.

The team shipped 33 releases of Metro from 2022 to now, including bug fixes and features like require context and simlink support.

Package exports, a modern spec for npm packages, is now supported in Metro, improving compatibility and ecosystem capacity.

Lazy bundling is being developed to allow Metro to bundle only the screen being worked on, improving startup times for large apps.

The team is exploring the use of SWC, a fast compiler, to potentially improve cold start times and build speeds.

Improvements to Metro's incremental build system aim to make it more resilient and maintainable.

The team is committed to enhancing debugging tools and experiences for React Native developers.

New features like the X Google ignorelist Source map extension and one-click Hermes debug aim to simplify the debugging process.

The team welcomes contributions and is creating 'good first issues' on the repository for community involvement.

Transcripts

play00:00

hi everyone my name is Alex and I'm a

play00:02

software engineer on the react developer

play00:04

experience team at Mata

play00:06

today I'd like to talk to you about

play00:07

Metro how it fits into react native

play00:10

recent new features in Metro and what

play00:13

we're focusing on in 2023

play00:16

so we're the react developer experience

play00:18

team

play00:19

we look after Metro and other react

play00:21

native and react components and we're

play00:23

predominantly based in London

play00:26

some good news we grew significantly in

play00:29

2022

play00:32

as a long time react native user getting

play00:34

to join this team really is an honor I'm

play00:36

delighted to get to work alongside such

play00:38

wonderful and talented people on this

play00:40

amazing technology

play00:42

in fact many of the team are present in

play00:43

the audience today

play00:45

please say hi if you see us and we'll be

play00:46

around for the community Lounge later

play00:48

today

play00:50

it might be useful to explain what

play00:52

develop experience is in a couple of

play00:53

ways

play00:54

this is how our team sits in the react

play00:56

team supporting products at Mata

play00:59

we're right between runtime capabilities

play01:01

I.E react natives native components the

play01:03

native framework and release functions

play01:06

which supports how we test and ship

play01:07

releases at Mata

play01:12

for developer experience we handle the

play01:14

end-to-end experience when using the

play01:15

react development tool chain this

play01:18

encompasses Metro and FB Metro which

play01:20

wraps Metro with an internal feature set

play01:23

this covers the JavaScript tool chain

play01:25

debugging and react Dev tools

play01:28

in addition we look after internal

play01:31

infrawork and supporting our product

play01:32

teams that matter

play01:35

and this is roughly a 50 50 time split

play01:38

this pie chart is a useful view just to

play01:40

understand that you won't be seeing work

play01:42

from all of the team members all of the

play01:44

time

play01:45

again supporting internal tooling at

play01:47

Mata for our product teams

play01:49

then for roughly the other half the time

play01:50

building and supporting our open source

play01:52

tools

play01:55

with a bigger team focused on developer

play01:56

experience let's put in context the

play01:58

value of Metro today and the principles

play02:01

will follow investing in its future

play02:04

so Metro is the JavaScript build tool

play02:07

for react native

play02:09

at its core Metro is a bundler

play02:12

it's the tool used by Expo CLI and react

play02:15

native CLI when compiling your

play02:16

application

play02:18

It prepares your JavaScript code

play02:19

dependencies and assets to run in react

play02:21

native resolving Imports between your

play02:24

JavaScript modules to compile an

play02:26

optimized JavaScript bundle for the

play02:27

Target platform

play02:29

as well as statically bundling Metro is

play02:32

deeply integrated into the react native

play02:33

development Loop

play02:36

Metro's runtime component supports fast

play02:38

refresh during development giving

play02:40

developers instant feedback independent

play02:42

of the scale of the code base

play02:45

Metro incrementally serves Source Maps

play02:47

so developers can instantly understand

play02:48

stack traces and where they appeared in

play02:50

source code

play02:52

Metro also interfaces with the

play02:53

JavaScript engine on the device to

play02:55

support JavaScript debugging

play02:57

so it Powers these core features of the

play03:00

react native development experience

play03:01

built into react native CLI and the Expo

play03:04

Dev server

play03:06

Metro is designed to be fast scalable

play03:08

and integrated

play03:11

Metro is built for performance at Epic

play03:13

scale

play03:14

in addition to incremental and error

play03:17

resistant fast refresh one of the key

play03:19

reasons Metro scales is because of its

play03:21

architecture

play03:22

Metro does work in parallel using

play03:24

workers and avoids where possible doing

play03:27

unnecessary work

play03:28

transformation is one of the most

play03:30

expensive operations which we run in

play03:32

parallel

play03:33

Metro transforms files individually and

play03:36

leaves the simplest work to the end this

play03:38

happens hand in hand with module

play03:39

resolution before the very fast

play03:41

operation of serialization

play03:44

because module Transformations happen

play03:46

per file they're individually cachable

play03:49

the security is important to enable

play03:51

scale

play03:53

at Mata we speed up teams working on the

play03:55

same project by reusing cache artifacts

play03:58

this uses a remote cache meaning local

play04:00

machines don't have to rebuild files

play04:02

that haven't changed relative to the

play04:04

main branch

play04:06

what do we mean by epic scale

play04:09

meta's mobile code base has roughly or

play04:12

greater than 300 000 JavaScript source

play04:14

files and 175 or more react native app

play04:18

entry points running off the same Metro

play04:20

config

play04:22

with our remote transform cache we're

play04:24

able to achieve a roughly four second

play04:26

typical bundle request and 220

play04:29

milliseconds typical fast refresh

play04:31

updates

play04:33

with our architecture

play04:37

the speed that Developers

play04:39

receive scales with

play04:42

changes and not with the size of the

play04:44

code base

play04:46

and we've also seen similar success

play04:49

stories in open source

play04:51

Airbnb were able to achieve a roughly 55

play04:53

reduction in average build time using

play04:56

Metro's layer transform cache

play04:58

over webpack

play05:04

Metro isn't just a bundler it's from the

play05:06

react team

play05:07

it's a development tool that's focused

play05:09

on react native needs and this will be

play05:11

an ongoing design goal

play05:13

a case study here is far to refresh this

play05:16

is a feature that rolled out first on

play05:18

react native before it existed on react

play05:20

web internally

play05:21

Metro was the in-house bundler where

play05:23

this feature could be built end to end

play05:25

and proven at scale before being rolled

play05:28

out to users with a complete ux picture

play05:31

we'll see another example of this later

play05:33

today with lazy bundling

play05:36

we want Metro to continue doing all

play05:38

these things well Metro is a vital

play05:40

component of every react native app and

play05:42

serves some of the biggest react native

play05:44

products out there as well as our own

play05:45

apps that matter

play05:47

in the past our team's Focus was on

play05:49

internal use cases for Metro and

play05:51

ensuring that react native was a

play05:52

successful UI framework at Mata was our

play05:55

top priority

play05:58

since 2022 the Metro team at meta grew

play06:00

and this now allows us to focus more

play06:02

heavily on sharing the full benefits of

play06:04

Metro with the open source community

play06:06

we absolutely recognize that there are

play06:08

open source features many of you have

play06:10

been waiting to see in Metro which we

play06:12

couldn't prioritize when the team was

play06:13

smaller

play06:16

in particular around npm compatibility

play06:18

features because we weren't using these

play06:20

internally it's taken time to prioritize

play06:22

these features with the smaller team we

play06:23

had before

play06:25

for example Dynamic Imports was

play06:27

something we already had a custom

play06:28

internal solution for but was tied

play06:30

closely to meta's tooling

play06:34

and of course not forgetting issue

play06:37

number one sim links more on this later

play06:42

so in the last year we've been working

play06:44

to make this better

play06:46

we want to build Metro in the open and

play06:48

with the react native community

play06:50

we've moved to fortnightly release

play06:52

schedule we are shipping improved docks

play06:54

with four new guides deep Dives in 2022

play06:58

and 2023

play07:00

we're moving the features from FB metro

play07:02

into open source Metro and we're

play07:04

engaging with the community more

play07:06

um and Publishing public rfcs when we do

play07:09

so

play07:12

in 2022 we've also been building up our

play07:14

relationships with existing Partners we

play07:16

formed a bundler working group to

play07:18

restore participation by us and partners

play07:20

in developing Metro

play07:21

understanding partner and Community

play07:23

needs and coordinating work

play07:27

along with building this relationship in

play07:29

the bundler working group

play07:30

the core contributors Summit was a

play07:32

second turning point for re-engaging

play07:33

with the community

play07:34

this event was hosted over two days by

play07:36

our friends at coolstack last September

play07:38

at react native EU

play07:40

we decided to run two sessions for the

play07:42

Metro team to put ideas out in the open

play07:44

and get design feedback on features we

play07:46

were considering for Metro and the

play07:48

ecosystem

play07:49

and we're extremely grateful for the

play07:51

conversations we had in the open that

play07:53

day

play07:56

in particular with Microsoft it's great

play07:58

to see another company using metro with

play07:59

react native at a similar scale

play08:03

Microsoft have gone all in on react

play08:05

native across several products

play08:06

specifically for our team a huge win

play08:09

here is Microsoft's been bringing back

play08:10

the use of Metro across the projects

play08:13

Microsoft's use cases on Windows have

play08:15

brought useful feedback and

play08:16

contributions for improving mattress

play08:18

behavior on this platform

play08:22

our next kit is a community project that

play08:24

has used extension points in metro to

play08:26

deliver functionality for Microsoft and

play08:28

the community

play08:29

when we've historically lacked the

play08:31

bandwidth

play08:32

this has validated Concepts such as Sim

play08:34

links validating the real needs of users

play08:37

were there

play08:38

and we can later pull these ideas into

play08:40

Metro

play08:42

next Expo

play08:45

we're happy to fill a very active

play08:46

collaboration with Expo in particular

play08:48

motivated around performance Universal

play08:51

apps and Expo router

play08:55

together we've worked on the design of

play08:57

new features and have supported Expo in

play08:59

becoming core contributors to the Metro

play09:00

code base

play09:01

shipping features like require context

play09:03

web performance optimizations and

play09:06

typescript import aliases

play09:14

Metro is becoming the default bundler

play09:16

for Universal Expo app development on

play09:18

all platforms and we're committed to

play09:19

improving the bundling tool chain

play09:21

together

play09:30

we also have new experimental features

play09:32

in coming contributed by Expo

play09:36

such as CSS support

play09:38

and the use of Metro on the server for

play09:41

static rendering of websites

play09:53

before going into the new features we've

play09:55

shipped and what we're planning for the

play09:56

future I want to take a moment to talk

play09:58

about our overall vision for Metro and

play09:59

what we want Metro to be

play10:02

Metro is the build system for Yak native

play10:04

we want to make it modern and fully web

play10:07

compatible so that you can write use it

play10:09

to write truly Universal apps

play10:11

Metro is a scalable build system it's

play10:14

fast and reliable and it stays that way

play10:15

as your project grows and your team

play10:17

grows

play10:19

we design Metro specifically to work

play10:21

well with react native and Frameworks

play10:23

like Expo router out of the box

play10:25

the ability to deeply integrate with

play10:27

react native gizmetro superpowers and

play10:29

we'll see another example of this later

play10:32

we're always looking to share more of

play10:34

what we've built around Metro at meta

play10:35

with open source users our goal is to

play10:38

run the exact same version of Metro

play10:39

internally

play10:42

we're building Metro to be ready for the

play10:44

future of react as react continues to

play10:46

innovate on ways to build great user

play10:48

experiences we'll continue to innovate

play10:50

on developer experience and in

play10:51

supporting the latest react features

play10:55

let's move into the Highlight Reel of

play10:57

some of the features we've shipped in

play10:58

2022 and 2023 so far

play11:02

from 2022 to now

play11:04

we've brought back activity in the code

play11:06

base we've shipped 33 releases of Metro

play11:09

which have included 52 distinct bug

play11:12

fixes along with some features

play11:15

[Applause]

play11:22

the very first big feature from one of

play11:25

strengthened Partnerships is required

play11:27

context

play11:28

and is the single largest external

play11:30

contribution in metro to date

play11:32

required context is a feature originally

play11:35

available in webpack which Expos

play11:36

contributed to Metro

play11:38

this is an advanced feature typically

play11:40

used by Frameworks where you can require

play11:42

directory of modules with an optional

play11:44

search pattern

play11:45

and of course it Powers the new file

play11:47

based routing in Expo router

play11:50

require contacts fully supports Metro's

play11:52

incremental file system independency

play11:54

graph

play11:55

meaning added and roof files can update

play11:57

Expo router using fast refresh

play12:01

simlink supports

play12:06

yes

play12:11

we really appreciate Microsoft for

play12:13

kicking off the conversation of this in

play12:15

our in RX kit and providing a first

play12:17

implementation that solved the most

play12:18

common simlink workflow for users

play12:21

trust us we're very happy to finally

play12:23

tackle this issue directly in Metro

play12:26

with Sim link support metro is now able

play12:29

to follow and track symbolic links to

play12:30

directories and files

play12:33

what does this enable support for

play12:35

signaling based node modules layouts

play12:37

which means we can now support newer

play12:39

package managers such as pmpm

play12:42

support for workspaces and monorepa

play12:44

setups for the time being for react

play12:46

native template projects this will still

play12:48

need corresponding changes for Native

play12:51

dependencies but we're working on this

play12:53

finally support for Linked packages such

play12:55

as to temporarily override a dependency

play12:57

during development

play13:01

we've worked hard to make the first

play13:03

party support for Sim links and Metro

play13:04

fast and correct

play13:07

Metro will follow multiple SIM link hops

play13:09

so long as they're inside the Project's

play13:10

watch folders

play13:12

Sim links are fully represented in

play13:14

Metro's in-memory Farm app and

play13:16

dependency graph

play13:18

this means we have fast Refresh on

play13:20

signaling changes

play13:22

these changes are fully cachable and we

play13:24

have file existence checks that greater

play13:26

than 1 million Ops per second

play13:29

and with and siblings on the Metro is a

play13:31

feature we universally support on all

play13:33

desktop platforms with or without

play13:35

Watchmen

play13:38

so the speech is currently experimental

play13:41

because we've yet to fully roll it out

play13:43

internally at Mata

play13:44

once we do it will become stable

play13:47

and also today watch folders containing

play13:49

Sim links will still need to be

play13:50

specified

play13:53

this is out really soon in react native

play13:55

zero Sims 2 and will be enabled by

play13:57

default targeting react native 073

play14:05

next fixture is package exports

play14:13

package exports is the modern spec for

play14:15

npm packages to specify package entry

play14:18

points

play14:18

it's supported in the node.js runtime

play14:20

and by bundlers when resolving package

play14:22

parts

play14:23

by supporting exports and react natives

play14:25

app developers should gain more

play14:27

compatibility with npm packages out of

play14:29

the box in their projects

play14:31

and this enables react native package

play14:33

maintainers to make use of this format

play14:35

and its new capabilities

play14:37

this is part of our commitment to

play14:38

improve the correctness and ecosystem

play14:40

capacity of Metro

play14:43

let's quickly cover a couple of these

play14:44

new capabilities

play14:46

the basic idea behind package exports is

play14:49

that packages can specify explicit

play14:51

mapping of subpaths

play14:54

this enables package encapsulation

play14:56

a module matched by export subparts can

play14:58

be imported externally I.E within your

play15:01

app but anything not exported is not

play15:04

accessible outside the package

play15:06

this format also allows aliases which

play15:09

point to an underlying file at a

play15:10

different path

play15:12

meaning you can export Alias subparts

play15:15

and change the underlying file

play15:15

implementation later

play15:18

today we've implemented package

play15:19

encapsulation as a warning to reduce

play15:21

friction in react native projects but do

play15:24

strongly recommend actioning all

play15:25

warnings if you encounter them

play15:29

second feature is conditional exports

play15:31

this replaces what we've done in the

play15:33

past with the browser and react native

play15:34

root fields

play15:36

and moves to a standardized approach

play15:37

where

play15:39

modules can be conditionally selected

play15:40

for the entry point or

play15:43

per subath

play15:45

for instance Metro will now dynamically

play15:47

match the browser condition when the

play15:49

platform is web

play15:52

as part of using the standardized spec

play15:54

we sent a PR to node to introduce the

play15:56

react native Community condition

play15:58

this is available today and will enable

play16:00

all npm packages to precisely Target

play16:02

react native apps under Metro and react

play16:05

native 073

play16:13

the development of package exports is a

play16:16

great example of reaching out for

play16:17

Community input as it's a feature that

play16:19

posed interesting design questions that

play16:21

would affect the whole react native

play16:22

package ecosystem

play16:23

so at last Autumn's core contributors

play16:26

Summit AT coolstack that's where we

play16:27

first pitched this feature

play16:29

and we published a public RFC that had

play16:32

multiple feedbackgrounds as we iterated

play16:33

towards the solution we wanted

play16:36

for more information on breaking changes

play16:38

and our migration guide for factory

play16:39

maintainers check out the new guide in

play16:41

the Metro Docs

play16:44

now let's take a look at what we're

play16:46

working on next

play16:48

again this is a highlight reel of

play16:49

projects that we're working on and that

play16:51

we're happy to share publicly

play16:54

Metro

play17:02

we're building lazy bundling into Metro

play17:04

currently in preview this is another

play17:07

feature that we've been building in the

play17:08

open and brings an internal FB Metro

play17:10

feature to open source

play17:14

in development before your app can run

play17:16

Metro has to compile your JavaScript

play17:18

code and deliver it to the device

play17:20

when you have a large app with lots of

play17:22

screens this means that you have more

play17:23

code so it takes longer to compile all

play17:25

of it as a result you need to wait

play17:27

longer before you can actually work on

play17:28

your app

play17:30

lazy bundling is a new feature that lets

play17:32

Metro bundle just the screen you're

play17:33

working on so no matter how big your app

play17:35

gets it always starts up super fast in

play17:38

development

play17:40

behind the scenes lazy bundling works by

play17:42

supporting the standard JavaScript

play17:43

Dynamic import syntax and the react.lazy

play17:46

API which now both work in react native

play17:49

the same way they do in web

play17:51

when Metro encounters an import call for

play17:53

example inside react.lazy it will stop

play17:56

bundling and generate a link to a

play17:58

separate bundle

play17:59

but the client can fetch lazily from

play18:00

Metro when the code is needed

play18:03

Expo router V2 supports lazy bundling

play18:05

out of the box with async routes

play18:08

from react native 073

play18:12

lazy bundling will work out of the box

play18:13

for all apps all you need to do is use

play18:16

the navigation framework that uses

play18:18

standard Imports and react lazy to tell

play18:20

Metro where the entry point to each

play18:22

screen is

play18:27

whoa

play18:34

swc

play18:37

as shed so far Metro is already Fast By

play18:39

Design particularly because we run the

play18:41

transformer in parallel and heavily used

play18:43

caching to avoid recompiling modules

play18:45

that haven't changed

play18:47

this doesn't mean there isn't room for

play18:48

improvement and we're open for

play18:50

integrating with other tools even ones

play18:52

written in other languages where the

play18:54

trade-offs fit

play18:55

this project is around speeding up the

play18:57

Transformer itself so we're exploring

play18:59

the potential use of a fast compiler

play19:01

which in particular could improve cold

play19:03

start times and build speeds in CI

play19:05

environments

play19:08

swc has been established as a strong

play19:11

alternative to Babel and is used in many

play19:13

web bundling tools we want to align

play19:15

Metro with the shift in the industry to

play19:17

make it even easier to write react code

play19:19

that runs on all platforms

play19:21

we're still in the research phase on

play19:23

this but for most apps We Believe swc

play19:25

should be a drop-in replacement

play19:27

you'll always have the option to run

play19:28

your own custom Babel plugins and

play19:30

presets alongside swc

play19:32

but we believe most apps will end up not

play19:34

needing to run Babel at all

play19:40

we believe that fast refresh or

play19:41

incremental bundling is one of Metro's

play19:43

most important features for developers

play19:45

to work fast in huge code bases

play19:47

Metro Joe's inspiration from Modern

play19:49

large-scale build systems like bug and

play19:52

was one of the first bundlers to bring

play19:53

these ideas into the JavaScript world

play19:55

this gives us confidence that it's

play19:57

possible to create an incremental build

play19:58

system that's both fully correct and

play20:00

Incredibly fast

play20:02

therefore we've invested in getting the

play20:04

infra in the bundler that powers fast

play20:05

refresh to be correct and even faster in

play20:08

some cases

play20:10

here's two big changes we're making

play20:11

towards the skull

play20:13

last year we shipped a new cycle

play20:15

collection algorithm

play20:17

we fixed the call Bug affecting how we

play20:19

handle changes to modules that have

play20:20

circular dependencies and we use the

play20:23

opportunity to rewrite the incremental

play20:24

build algorithm to be more resilient and

play20:27

easier to maintain

play20:30

we now have arise set on absolute

play20:32

reliability for incremental bundling

play20:34

this is powered by Metro's incremental

play20:36

file system where in most cases today

play20:38

fast refresh works really well

play20:40

however we've seen cases where it might

play20:42

not work completely

play20:44

for example on an npm reinstall that

play20:46

brings wide code base changes

play20:49

the aim with this project is to close

play20:51

the gap on tracking classes of change

play20:53

event that we haven't before

play20:55

example

play20:56

modeling the set of potential files when

play20:59

you add or remove files of platform

play21:01

Civic extensions

play21:04

all modular resolutions which are

play21:06

dependent on package.json rules such as

play21:08

package exports

play21:13

with this ongoing effort we want to get

play21:15

into a place where you never have to

play21:16

restart Metro and never have to clear

play21:18

the cache

play21:29

and excitingly this could even enable us

play21:31

to Cache the dependency graph as well

play21:33

for faster Metro starts

play21:35

we believe that this level of

play21:37

incremental bonding correctness is an

play21:39

area where Metro is leading the way in

play21:40

the bundling ecosystem

play21:44

we hear your input there are many more

play21:46

features raised by users that we'd love

play21:47

to and we'll begin working on next

play21:50

in particular optimization features such

play21:53

as tree shaking and bundle splitting

play21:55

and features for web such as webpack

play21:57

style externals

play22:01

so in addition to Metro our larger

play22:04

developer experience team is beginning

play22:05

to tackle other problem spaces for

play22:07

reactive users

play22:11

from the state of react native survey

play22:12

we've heard that users have identified

play22:14

react native debugging as a key area of

play22:16

improvement and we absolutely agree

play22:19

the first small feature we've been able

play22:21

to ship towards this is the X Google

play22:23

ignorelist Source map extension

play22:26

this allows stack traces when viewed in

play22:28

Chrome devtools to

play22:31

ignore files from frames that likely

play22:33

have no useful information

play22:35

the Chrome Dev tools team presented this

play22:37

feature in February this year

play22:39

and we're glad to have been able to come

play22:41

back and implement it so soon

play22:43

by default we're going to hide

play22:46

stack Tracer smaller model sources so

play22:48

collapsed by default but can be expanded

play22:50

this is going to help you see denser

play22:52

output and more useful output in your

play22:54

console logs

play22:58

one click Hermes debug is a feature to

play23:00

make debugging simple and delightful

play23:03

now you'll be able to click on one

play23:04

button to open Hermes in debugging in

play23:07

Chrome Dev tools straight from the dev

play23:08

menu

play23:10

we believe the Chrome expector to be an

play23:12

all-in-one solution for 90 of use cases

play23:14

and we'll be working with our partners

play23:16

to improve its feature set as a react

play23:18

native debugger

play23:19

you'll be hearing more about this from

play23:21

Cedric later today

play23:24

and will simply be enabling instant

play23:26

launch for react Dev tools

play23:30

one more feature is

play23:33

pause breakpoint overlay

play23:35

right now when you create a breakpoint

play23:37

and pause it in the debugger the app

play23:39

will freeze without much indication of

play23:41

if the app is Frozen

play23:45

we plan to implement a very browser-like

play23:48

UI control above react native apps to

play23:51

indicate that it's paused and debugger

play23:55

[Applause]

play24:03

so debugging is a common theme and

play24:05

something we're committed to investing

play24:06

in throughout 2023

play24:08

again we're reaching out to multiple

play24:10

partners to form a debugging working

play24:12

group to make sure we're aligned on

play24:13

efforts approaches and standards going

play24:15

forward and investing in this area

play24:17

together

play24:20

so in summary

play24:22

we're back

play24:32

our new team investment from 2022

play24:34

enables us to work on long-standing

play24:36

issues in Metro where we didn't have

play24:38

capacity before

play24:40

we want Metro to provide the best

play24:41

end-to-end developer experience for Yak

play24:43

native

play24:44

addressing feature gaps always focused

play24:46

on Epic scale and we will keep

play24:48

innovating and we're going to make that

play24:50

innovation in the open source code base

play24:52

and with our partners

play24:55

finally we're looking at features Beyond

play24:57

Metro to improve debugging project setup

play25:00

upgrading and other areas of the react

play25:02

native development experience

play25:06

oops

play25:11

sorry

play25:14

finally we welcome contributors

play25:17

we've started creating some good first

play25:19

issues on the repository and we'd love

play25:20

you to get in touch if you want to help

play25:22

us build these features in the open

play25:25

most of the London team is here today to

play25:27

chat both about Metro and wider devx

play25:29

features

play25:31

thank you

play25:33

[Applause]

play25:37

[Music]

play25:56

foreign

play25:57

[Music]

play26:15

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
React NativeMetroバンドラー開発体験新機能2023オープンソースコミュニティスケーラビリティバンドルJavaScriptFast Refresh
Do you need a summary in English?