metro
metro copied to clipboard
WIP: Use SWC in Metro transpilation pipeline
Summary
This draft is a work in progress on exploring the integration of SWC in the Metro traspilation pipeline along with Babel to help OSS users with a faster overall bundling speeds.
Goal
- Improve bundling speed for OSS users
- SWC is faster than Babel in benchmarks, and hypothesis is transpiling the majority of code using SWC will improves overall bundling speed in Metro.Â
Non-Goal
- Remove Babal
- There are many community packages that come with Babel transforms, and we need to support that for the foreseeable future.
Tasks
- [x] Import the original POC.
- [x] Setup the new npm package
metro-swc-transformer
. - [x] Use napi.rs to create a native Node.js addon.
- [x] Add typescript support.
- [x] Algin Module Configuration with Metro Preset
- [x] Add lazy imports with SWC config
- [x] Add support for require optional packages.Â
- [ ] Create SWC opt-in transformer config to use SWC in
metro-transform-worker
. - [ ] Create a minimal Babel pass to strip flow types before SWC.
- This should be config driven so we don't have to do this first pass for all files.
- [ ] ~~Create config for fallback to current full Babel pipeline for selected files.~~
- [ ] Check for missing transforms that can cause compatibility issues.
- This will be a breaking change, as we are not aiming for 1:1 mapping but documenting what has changed. Ideally, we need to use the same presets as SWC Web. But we still need to align on React Native specific transforms.
- Risk of adoption gets harder for exiting apps.
- Risk of apps using different transpilation pipeline which is not compatible with each other.
- [ ] Add Sourcemap support and check regressions in debugging experience.
- [ ] Add HMR support.
- [ ] Test and dogfood new SWC pipeline and bug fixes.
- [ ] NPM release with different packages for different architecture approach number 3 explained in Napi docs.
Test plan
TODO
Hey any update here?
Hey guys, any news about this?