Update with working working version (#12)

* Fix workflow

* Trigger

* [auto] Update compiled version

* [auto] Commit modules

* Push Windows changes

* Fix

* [auto] Update compiled version

* Try removing cwd

* [auto] Update compiled version

* Try with path module

* [auto] Update compiled version

* Fix path

* [auto] Update compiled version

* Use raw path

* [auto] Update compiled version

* Other path

* [auto] Update compiled version

* Avoid @action/exec

* [auto] Update compiled version

* test

* [auto] Update compiled version

* test

* [auto] Update compiled version

* test

* [auto] Update compiled version

* test

* [auto] Update compiled version

* Try with shelljs

* [auto] Update compiled version

* Fix my stupidity

* Copy scripts to local dir

* [auto] Update compiled version

* Still use path

* [auto] Update compiled version

* Delete entrypoint.sh

* [auto] Update compiled version

* Make file executable

* [auto] Update compiled version

* Try using bash

* [auto] Update compiled version
This commit is contained in:
Federico Grandi
2019-12-14 21:47:13 +01:00
committed by GitHub
parent d81e04e96c
commit f118062594
4276 changed files with 1075004 additions and 40 deletions

View File

@@ -0,0 +1,55 @@
# babel-plugin-minify-flip-comparisons
**Note:** while this plugin doesnt shorten the output in any way, it does optimize it for repetition-based compression algorithms such as gzip.
## Example
**In**
```javascript
const foo = a === 1;
if (bar !== null) {
var baz = 0;
}
```
**Out**
```javascript
const foo = 1 === a;
if (null !== bar) {
var baz = 0;
}
```
## Installation
```sh
npm install babel-plugin-minify-flip-comparisons --save-dev
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["minify-flip-comparisons"]
}
```
### Via CLI
```sh
babel --plugins minify-flip-comparisons script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["minify-flip-comparisons"]
});
```

View File

@@ -0,0 +1,61 @@
"use strict";
module.exports = function ({
types: t
}) {
const isVoid0 = require("babel-helper-is-void-0")(t);
return {
name: "minify-flip-comparisons",
visitor: {
// flip comparisons with a pure right hand value, this ensures
// consistency with comparisons and increases the length of
// strings that gzip can match
// typeof blah === 'function' -> 'function' === typeof blah
BinaryExpression(path) {
const node = path.node;
const right = node.right,
left = node.left; // Make sure we have a constant on the right.
if (!t.isLiteral(right) && !isVoid0(right) && !(t.isUnaryExpression(right) && t.isLiteral(right.argument)) && !t.isObjectExpression(right) && !t.isArrayExpression(right)) {
return;
} // Commutative operators.
if (t.EQUALITY_BINARY_OPERATORS.indexOf(node.operator) >= 0 || ["*", "^", "&", "|"].indexOf(node.operator) >= 0) {
node.left = right;
node.right = left;
return;
}
if (t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(node.operator) >= 0) {
node.left = right;
node.right = left;
let operator;
switch (node.operator) {
case ">":
operator = "<";
break;
case "<":
operator = ">";
break;
case ">=":
operator = "<=";
break;
case "<=":
operator = ">=";
break;
}
node.operator = operator;
return;
}
}
}
};
};

View File

@@ -0,0 +1,53 @@
{
"_args": [
[
"babel-plugin-minify-flip-comparisons@0.4.3",
"/home/runner/work/add-and-commit/add-and-commit"
]
],
"_development": true,
"_from": "babel-plugin-minify-flip-comparisons@0.4.3",
"_id": "babel-plugin-minify-flip-comparisons@0.4.3",
"_inBundle": false,
"_integrity": "sha1-AMqHDLjxO0XAOLPB68DyJyk8llo=",
"_location": "/babel-plugin-minify-flip-comparisons",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "babel-plugin-minify-flip-comparisons@0.4.3",
"name": "babel-plugin-minify-flip-comparisons",
"escapedName": "babel-plugin-minify-flip-comparisons",
"rawSpec": "0.4.3",
"saveSpec": null,
"fetchSpec": "0.4.3"
},
"_requiredBy": [
"/babel-preset-minify"
],
"_resolved": "https://registry.npmjs.org/babel-plugin-minify-flip-comparisons/-/babel-plugin-minify-flip-comparisons-0.4.3.tgz",
"_spec": "0.4.3",
"_where": "/home/runner/work/add-and-commit/add-and-commit",
"author": {
"name": "amasad"
},
"bugs": {
"url": "https://github.com/babel/minify/issues"
},
"dependencies": {
"babel-helper-is-void-0": "^0.4.3"
},
"description": "**Note:** while this plugin doesnt shorten the output in any way, it does optimize it for repetition-based compression algorithms such as gzip.",
"homepage": "https://github.com/babel/minify#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "babel-plugin-minify-flip-comparisons",
"repository": {
"type": "git",
"url": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-flip-comparisons"
},
"version": "0.4.3"
}