Skip to content

Conversation

@jacdebug
Copy link
Contributor

@jacdebug jacdebug commented Mar 21, 2023

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

  • Import the original POC.
  • Setup the new npm package metro-swc-transformer.
  • Use napi.rs to create a native Node.js addon.
  • Add typescript support.
  • Algin Module Configuration with Metro Preset
  • Add lazy imports with SWC config
  • 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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 21, 2023
@jacdebug jacdebug changed the title WIP: Use SWC instead of babel for transpilation WIP: Use SWC in Metro transpilation pipeline Mar 21, 2023
@jacdebug jacdebug force-pushed the feat/swc-integration-dev branch from 8f1af4a to 9a38605 Compare March 27, 2023 13:53
tido64 added a commit to microsoft/rnx-kit that referenced this pull request Apr 18, 2023
Metro is experimenting with [SWC](https://swc.rs/) here:
facebook/metro#948
tido64 added a commit to microsoft/rnx-kit that referenced this pull request Apr 18, 2023
Metro is experimenting with [SWC](https://swc.rs/) here:
facebook/metro#948
tido64 added a commit to microsoft/rnx-kit that referenced this pull request Apr 18, 2023
@JoePassanante
Copy link

Hey any update here?

@migueldaipre
Copy link

Hey guys, any news about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants