forked from daren.hsu/line_push
update
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
> Remove nullish coalescing operator
|
||||
|
||||
See our website [@babel/plugin-proposal-nullish-coalescing-operator](https://babeljs.io/docs/en/next/babel-plugin-proposal-nullish-coalescing-operator.html) for more information.
|
||||
See our website [@babel/plugin-proposal-nullish-coalescing-operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
|
||||
+14
-6
@@ -7,16 +7,17 @@ exports.default = void 0;
|
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
||||
|
||||
var _pluginSyntaxNullishCoalescingOperator = _interopRequireDefault(require("@babel/plugin-syntax-nullish-coalescing-operator"));
|
||||
var _pluginSyntaxNullishCoalescingOperator = require("@babel/plugin-syntax-nullish-coalescing-operator");
|
||||
|
||||
var _core = require("@babel/core");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, {
|
||||
loose = false
|
||||
}) => {
|
||||
var _api$assumption;
|
||||
|
||||
api.assertVersion(7);
|
||||
const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : loose;
|
||||
return {
|
||||
name: "proposal-nullish-coalescing-operator",
|
||||
inherits: _pluginSyntaxNullishCoalescingOperator.default,
|
||||
@@ -31,17 +32,24 @@ var _default = (0, _helperPluginUtils.declare)((api, {
|
||||
return;
|
||||
}
|
||||
|
||||
let ref = scope.maybeGenerateMemoised(node.left);
|
||||
let ref;
|
||||
let assignment;
|
||||
|
||||
if (ref === null) {
|
||||
if (scope.isStatic(node.left)) {
|
||||
ref = node.left;
|
||||
assignment = _core.types.cloneNode(node.left);
|
||||
} else if (scope.path.isPattern()) {
|
||||
path.replaceWith(_core.template.statement.ast`(() => ${path.node})()`);
|
||||
return;
|
||||
} else {
|
||||
ref = scope.generateUidIdentifierBasedOnNode(node.left);
|
||||
scope.push({
|
||||
id: _core.types.cloneNode(ref)
|
||||
});
|
||||
assignment = _core.types.assignmentExpression("=", ref, node.left);
|
||||
}
|
||||
|
||||
path.replaceWith(_core.types.conditionalExpression(loose ? _core.types.binaryExpression("!=", assignment, _core.types.nullLiteral()) : _core.types.logicalExpression("&&", _core.types.binaryExpression("!==", assignment, _core.types.nullLiteral()), _core.types.binaryExpression("!==", _core.types.cloneNode(ref), scope.buildUndefinedNode())), _core.types.cloneNode(ref), node.right));
|
||||
path.replaceWith(_core.types.conditionalExpression(noDocumentAll ? _core.types.binaryExpression("!=", assignment, _core.types.nullLiteral()) : _core.types.logicalExpression("&&", _core.types.binaryExpression("!==", assignment, _core.types.nullLiteral()), _core.types.binaryExpression("!==", _core.types.cloneNode(ref), scope.buildUndefinedNode())), _core.types.cloneNode(ref), node.right));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+28
-20
@@ -1,52 +1,59 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator@7.10.4",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator@7.18.6",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/plugin-proposal-nullish-coalescing-operator@7.10.4",
|
||||
"_id": "@babel/plugin-proposal-nullish-coalescing-operator@7.10.4",
|
||||
"_from": "@babel/plugin-proposal-nullish-coalescing-operator@7.18.6",
|
||||
"_id": "@babel/plugin-proposal-nullish-coalescing-operator@7.18.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-wq5n1M3ZUlHl9sqT2ok1T2/MTt6AXE0e1Lz4WzWBr95LsAZ5qDXe4KnFuauYyEyLiohvXFMdbsOTMyLZs91Zlw==",
|
||||
"_integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
|
||||
"_location": "/@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/plugin-proposal-nullish-coalescing-operator@7.10.4",
|
||||
"raw": "@babel/plugin-proposal-nullish-coalescing-operator@7.18.6",
|
||||
"name": "@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
"escapedName": "@babel%2fplugin-proposal-nullish-coalescing-operator",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "7.10.4",
|
||||
"rawSpec": "7.18.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.10.4"
|
||||
"fetchSpec": "7.18.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/preset-env"
|
||||
"/@babel/preset-env",
|
||||
"/@nuxt/babel-preset-app"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.10.4.tgz",
|
||||
"_spec": "7.10.4",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
|
||||
"_spec": "7.18.6",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.10.4",
|
||||
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0"
|
||||
"@babel/helper-plugin-utils": "^7.18.6",
|
||||
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
|
||||
},
|
||||
"description": "Remove nullish coalescing operator",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.4",
|
||||
"@babel/helper-plugin-test-runner": "^7.10.4"
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6"
|
||||
},
|
||||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
|
||||
"homepage": "https://github.com/babel/babel#readme",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-proposal-nullish-coalescing-operator",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
@@ -59,5 +66,6 @@
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-proposal-nullish-coalescing-operator"
|
||||
},
|
||||
"version": "7.10.4"
|
||||
"type": "commonjs",
|
||||
"version": "7.18.6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user