Git Product home page Git Product logo

babel-plugin-transform-destructuring's Introduction

==================

This is a (hopefully temporary) fork of @babel/plugin-transform-destructuring that optimises array destructuring of useState and useReducer React Hooks.

It only includes these two changes:

@@ -1,6 +1,10 @@
 import { declare } from '@babel/helper-plugin-utils';
 import { types as t } from '@babel/core';

+const forcedLoose = ['useReducer', 'useState'].map(
+  name => new RegExp(`^_(?:React\\$)?${name}\\d*$`)
+);
+
 export default declare((api, options) => {
   api.assertVersion(7);
@@ -129,7 +133,11 @@ export default declare((api, options) => {
     }

     toArray(node, count) {
-      if (this.arrayOnlySpread || (t.isIdentifier(node) && this.arrays[node.name])) {
+      if (
+        this.arrayOnlySpread ||
+        (t.isIdentifier(node) &&
+          (this.arrays[node.name] || forcedLoose.some(regex => regex.test(node.name))))
+      ) {

==================

@babel/plugin-transform-destructuring

Compile ES2015 destructuring to ES5

See our website @babel/plugin-transform-destructuring for more information.

Install

Using npm:

npm install --save-dev @babel/plugin-transform-destructuring

or using yarn:

yarn add @babel/plugin-transform-destructuring --dev

babel-plugin-transform-destructuring's People

Contributors

andarist avatar apapirovski avatar danez avatar devenbansod avatar existentialism avatar hulkish avatar hzoo avatar loganfsmyth avatar mmantel avatar motiz88 avatar nicolo-ribaudo avatar nminhnguyen avatar oliviertassinari avatar rajasekarm avatar rubenverborgh avatar tanhauhau avatar techmexdev avatar xtuc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.