metro icon indicating copy to clipboard operation
metro copied to clipboard

WIP: Use SWC in Metro transpilation pipeline

Open jacdebug opened this issue 1 year ago • 2 comments

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

jacdebug avatar Mar 21 '23 06:03 jacdebug

Hey any update here?

JoePassanante avatar Feb 02 '24 21:02 JoePassanante

Hey guys, any news about this?

migueldaipre avatar Aug 02 '24 02:08 migueldaipre