• This repository has been archived on 01/Mar/2022
  • Stars
    star
    98
  • Rank 345,882 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tiny Babel plugin for old React

Note: since there is the new JSX transform, it might make sense to prefer the official plugin.

This plugin transforms ES6-style imports from React that cannot be mangled (because with standard options minifiers don't know if property access is constant or not) to local variables.

Example:

// Original code:
function render() {
  const [v, s] = a.b.useState(0)
  return a.b.createElement('p', null, 'Text', v)
}

// Modified code:
const h = a.b.createElement
const { useState: f } = a.b
function render() {
  const [v, s] = f(0)
  return h('p', null, 'Text', v)
}