Remove modules from source
This commit is contained in:
22
node_modules/babel-plugin-minify-guarded-expressions/LICENSE
generated
vendored
22
node_modules/babel-plugin-minify-guarded-expressions/LICENSE
generated
vendored
@@ -1,22 +0,0 @@
|
||||
Copyright (c) 2015-2016 Amjad Masad <amjad.masad@gmail.com>
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
49
node_modules/babel-plugin-minify-guarded-expressions/README.md
generated
vendored
49
node_modules/babel-plugin-minify-guarded-expressions/README.md
generated
vendored
@@ -1,49 +0,0 @@
|
||||
# babel-plugin-minify-guarded-expressions
|
||||
|
||||
## Example
|
||||
|
||||
**In**
|
||||
|
||||
```javascript
|
||||
!x && foo();
|
||||
alert(0 && new Foo());
|
||||
```
|
||||
|
||||
**Out**
|
||||
|
||||
```javascript
|
||||
x || foo();
|
||||
alert(0);
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install babel-plugin-minify-guarded-expressions --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Via `.babelrc` (Recommended)
|
||||
|
||||
**.babelrc**
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": ["minify-guarded-expressions"]
|
||||
}
|
||||
```
|
||||
|
||||
### Via CLI
|
||||
|
||||
```sh
|
||||
babel --plugins minify-guarded-expressions script.js
|
||||
```
|
||||
|
||||
### Via Node API
|
||||
|
||||
```javascript
|
||||
require("@babel/core").transform("code", {
|
||||
plugins: ["minify-guarded-expressions"]
|
||||
});
|
||||
```
|
||||
80
node_modules/babel-plugin-minify-guarded-expressions/lib/index.js
generated
vendored
80
node_modules/babel-plugin-minify-guarded-expressions/lib/index.js
generated
vendored
@@ -1,80 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const evaluate = require("babel-helper-evaluate-path");
|
||||
|
||||
function evaluateTruthy(path) {
|
||||
const res = evaluate(path);
|
||||
if (res.confident) return !!res.value;
|
||||
}
|
||||
|
||||
module.exports = function ({
|
||||
types: t
|
||||
}) {
|
||||
const flipExpressions = require("babel-helper-flip-expressions")(t);
|
||||
|
||||
return {
|
||||
name: "minify-guarded-expressions",
|
||||
visitor: {
|
||||
// Convert guarded expressions
|
||||
// !a && b() --> a || b();
|
||||
// This could change the return result of the expression so we only do it
|
||||
// on things where the result is ignored.
|
||||
LogicalExpression: {
|
||||
enter: [function (path) {
|
||||
const node = path.node;
|
||||
const left = path.get("left");
|
||||
const right = path.get("right"); // issues - 171, 174, 176
|
||||
// we assume that it is returned/assigned/part of a bigger expression
|
||||
// or utilized somehow
|
||||
// we check if we shouldBail only when evaluating
|
||||
// the rightside of the expression;
|
||||
// if the left side is evaluated to be deterministic,
|
||||
// we can safely replace the entire expression
|
||||
|
||||
const shouldBail = !path.parentPath.isExpressionStatement();
|
||||
|
||||
if (node.operator === "&&") {
|
||||
const leftTruthy = evaluateTruthy(left);
|
||||
|
||||
if (leftTruthy === false) {
|
||||
// Short-circuit
|
||||
path.replaceWith(node.left);
|
||||
} else if (leftTruthy === true && left.isPure()) {
|
||||
path.replaceWith(node.right);
|
||||
} else if (evaluateTruthy(right) === false && right.isPure() && !shouldBail) {
|
||||
path.replaceWith(node.left);
|
||||
}
|
||||
} else if (node.operator === "||") {
|
||||
const leftTruthy = evaluateTruthy(left);
|
||||
|
||||
if (leftTruthy === false && left.isPure()) {
|
||||
path.replaceWith(node.right);
|
||||
} else if (leftTruthy === true) {
|
||||
// Short-circuit
|
||||
path.replaceWith(node.left);
|
||||
} else if (evaluateTruthy(right) === false && right.isPure() && !shouldBail) {
|
||||
path.replaceWith(node.left);
|
||||
}
|
||||
}
|
||||
}, function (path) {
|
||||
const node = path.node;
|
||||
|
||||
if (flipExpressions.hasSeen(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!path.parentPath.isExpressionStatement() && !(path.parentPath.isSequenceExpression() && path.parentPath.parentPath.isExpressionStatement())) {
|
||||
return;
|
||||
} // Start counting savings from one since we can ignore the last
|
||||
// expression.
|
||||
|
||||
|
||||
if (flipExpressions.shouldFlip(node, 1)) {
|
||||
const newNode = flipExpressions.flip(node, true);
|
||||
path.replaceWith(newNode);
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
55
node_modules/babel-plugin-minify-guarded-expressions/package.json
generated
vendored
55
node_modules/babel-plugin-minify-guarded-expressions/package.json
generated
vendored
@@ -1,55 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"babel-plugin-minify-guarded-expressions@0.4.4",
|
||||
"/home/runner/work/add-and-commit/add-and-commit"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "babel-plugin-minify-guarded-expressions@0.4.4",
|
||||
"_id": "babel-plugin-minify-guarded-expressions@0.4.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-RMv0tM72YuPPfLT9QLr3ix9nwUIq+sHT6z8Iu3sLbqldzC1Dls8DPCywzUIzkTx9Zh1hWX4q/m9BPoPed9GOfA==",
|
||||
"_location": "/babel-plugin-minify-guarded-expressions",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "babel-plugin-minify-guarded-expressions@0.4.4",
|
||||
"name": "babel-plugin-minify-guarded-expressions",
|
||||
"escapedName": "babel-plugin-minify-guarded-expressions",
|
||||
"rawSpec": "0.4.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.4.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/babel-preset-minify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/babel-plugin-minify-guarded-expressions/-/babel-plugin-minify-guarded-expressions-0.4.4.tgz",
|
||||
"_spec": "0.4.4",
|
||||
"_where": "/home/runner/work/add-and-commit/add-and-commit",
|
||||
"author": {
|
||||
"name": "amasad"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/minify/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-helper-evaluate-path": "^0.5.0",
|
||||
"babel-helper-flip-expressions": "^0.4.3"
|
||||
},
|
||||
"description": "## Example",
|
||||
"gitHead": "e1d0c52f5b501f5849741be6db56f968094854eb",
|
||||
"homepage": "https://github.com/babel/minify#readme",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "babel-plugin-minify-guarded-expressions",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-guarded-expressions"
|
||||
},
|
||||
"version": "0.4.4"
|
||||
}
|
||||
Reference in New Issue
Block a user