Giter VIP home page Giter VIP logo

bye-react's Introduction

bye-react

Migrate your project from React to Preact with a single command. More specifically, this tool switches the project over to preact-compat, the "compatibility layer that makes React-based modules work with Preact, without any code changes".

Disclaimers

  1. Requires usage of Webpack, Browserify, or the Babel React preset (or any combination thereof). If you don’t use any of these, this won't work. Also you should probably be using one of these.
  2. Not guaranteed to work in all cases. You should be using a version of React that is compatible with the current stable release (@15.6.1). May interact in interesting and unfortunate ways with non-standard build pipelines (e.g. if you dynamically generate .babelrc or package.json, etc).
  3. Will delete comments inside package.json and .babelrc files. These files contain JSON-compliant data. To add the aliases, bye-react reads in the JSON, modifies it, and writes it back to disk. Comments are lost en route. If these are important to you then don't use bye-react.

Usage

Install

npm install -g bye-react

or

yarn global add bye-react

Usage

cd ~/your/react/project

bye-react

Undoing

When you first run bye-react backups are made of all config files modified by this tool. Running these undo commands restores these files to their original state. It also uninstalls preact and reinstalls react and react-dom. bye-react -u

or

bye-react --undo

How It Works

  1. Uninstalls react and react-dom.
  2. Installs preact and preact-compat (obviously) via npm (or yarn, if a Yarn lockfile is detected)
  3. Checks for usage of Webpack. If detected, an alias is added to webpack.config.js. Specifically these lines are appended to the end of the file.
  4. Checks for usage of Babel’s React preset. If detected, babel-plugin-module-resolver is installed and used to create an alias in .babelrc
  5. Checks for usage of Browserify. If detected, aliasify is installed and used to create an alias in package.json.

bye-react's People

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.