Giter Club home page Giter Club logo

tgv's Introduction

TGV - an experimental faster bundler and dev server for React Native, built on top of esbuild

โš ๏ธ This is experimental, you probably don't want to use it for anything serious right now

Known limitations:

  • You'll need a recent React Native version
  • The compatibility between esbuild's output and React Native's JS runtimes is not clear yet, some JS features may break everything
  • Some very useful features like stack trace symbolication are not yet implemented

Goals

  • A dev server that runs all day long without getting in your way. It should handle things like branch switches, yarn install smoothly and you should never wait for it
  • Fast bundling (a few seconds) so that JS deploys (codepush, expo...) are fast
  • Smaller and faster prod bundles thanks to tree-shaking and ES modules scope-hoisting

Installation

Node >= 16 is required.

This package is not yet published to npm.

git clone [email protected]:matthieugicquel/tgv.git
cd tgv
yarn
yarn link

cd <the RN repo you want to test it with>

Add to package.json:

"devDependencies": {
  "tgv": "file:<path-to-tgv>"
}

Add .tgv-cache to .gitignore

cd <the RN repo you want to test it with>

yarn link tgv
yarn

Then add to react-native.config.js: (or create it)

module.exports = {
  commands: require('tgv/commands')({
    async plugins() {
      const {flow} = await import('tgv/plugins/flow');
      const {reanimated} = await import('tgv/plugins/reanimated');

      return [flow(), reanimated()];
    },
  }),
};

Note: This looks a bit complicated. The reason is that tgv is written and published as esm, while react-native cli is not yet. You have to use await import for the plugins to load

Usage

Dev server

# This starts a dev server that replaces metro, do it before `run-x` so that metro doesn't start automatically
yarn react-native tgv-start

yarn react-native run-(ios|android)

Using as the production bundler

๐Ÿ iOS

Add export BUNDLE_COMMAND=tgv-bundle to the "Bundle react native code and images" script in Xcode for the app target:

Add an export BUNDLE_COMMAND=tgv-bundle line to the bundle react native code and images script in Xcode

๐Ÿค– Android

// android/app/build.gradle

project.ext.react = [
    // ...
    bundleCommand: 'tgv-bundle'
]

Docs

Only this README for now yet, but some research is here:

tgv's People

Contributors

matthieugicquel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.