This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
> Compile ES2015 computed properties to ES5
See our website [@babel/plugin-transform-computed-properties](https://babeljs.io/docs/en/next/babel-plugin-transform-computed-properties.html) for more information.
See our website [@babel/plugin-transform-computed-properties](https://babeljs.io/docs/en/babel-plugin-transform-computed-properties) for more information.
## Install
+17 -18
View File
@@ -10,12 +10,13 @@ var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _core = require("@babel/core");
var _default = (0, _helperPluginUtils.declare)((api, options) => {
var _api$assumption;
api.assertVersion(7);
const {
loose
} = options;
const pushComputedProps = loose ? pushComputedPropsLoose : pushComputedPropsSpec;
const buildMutatorMapAssign = (0, _core.template)(`
const setComputedProperties = (_api$assumption = api.assumption("setComputedProperties")) != null ? _api$assumption : options.loose;
const pushComputedProps = setComputedProperties ? pushComputedPropsLoose : pushComputedPropsSpec;
const buildMutatorMapAssign = _core.template.statements(`
MUTATOR_MAP_REF[KEY] = MUTATOR_MAP_REF[KEY] || {};
MUTATOR_MAP_REF[KEY].KIND = VALUE;
`);
@@ -29,11 +30,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
}
function pushAssign(objId, prop, body) {
if (prop.kind === "get" && prop.kind === "set") {
pushMutatorDefine(objId, prop, body);
} else {
body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.memberExpression(_core.types.cloneNode(objId), prop.key, prop.computed || _core.types.isLiteral(prop.key)), getValue(prop))));
}
body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.memberExpression(_core.types.cloneNode(objId), prop.key, prop.computed || _core.types.isLiteral(prop.key)), getValue(prop))));
}
function pushMutatorDefine({
@@ -59,7 +56,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
function pushComputedPropsLoose(info) {
for (const prop of info.computedProps) {
if (prop.kind === "get" || prop.kind === "set") {
if (_core.types.isObjectMethod(prop) && (prop.kind === "get" || prop.kind === "set")) {
pushMutatorDefine(info, prop);
} else {
pushAssign(_core.types.cloneNode(info.objId), prop, info.body);
@@ -78,17 +75,15 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
for (const prop of computedProps) {
const key = _core.types.toComputedKey(prop);
if (prop.kind === "get" || prop.kind === "set") {
if (_core.types.isObjectMethod(prop) && (prop.kind === "get" || prop.kind === "set")) {
pushMutatorDefine(info, prop);
} else if (_core.types.isStringLiteral(key, {
value: "__proto__"
})) {
pushAssign(objId, prop, body);
} else {
const value = getValue(prop);
if (computedProps.length === 1) {
return _core.types.callExpression(state.addHelper("defineProperty"), [info.initPropExpression, key, getValue(prop)]);
return _core.types.callExpression(state.addHelper("defineProperty"), [info.initPropExpression, key, value]);
} else {
body.push(_core.types.expressionStatement(_core.types.callExpression(state.addHelper("defineProperty"), [_core.types.cloneNode(objId), key, getValue(prop)])));
body.push(_core.types.expressionStatement(_core.types.callExpression(state.addHelper("defineProperty"), [_core.types.cloneNode(objId), key, value])));
}
}
}
@@ -117,6 +112,10 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
let foundComputed = false;
for (const prop of node.properties) {
if (_core.types.isSpreadElement(prop)) {
continue;
}
if (prop.computed) {
foundComputed = true;
}
+25 -18
View File
@@ -1,51 +1,57 @@
{
"_args": [
[
"@babel/plugin-transform-computed-properties@7.10.4",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"@babel/plugin-transform-computed-properties@7.18.6",
"/home/node/nuxt"
]
],
"_from": "@babel/plugin-transform-computed-properties@7.10.4",
"_id": "@babel/plugin-transform-computed-properties@7.10.4",
"_from": "@babel/plugin-transform-computed-properties@7.18.6",
"_id": "@babel/plugin-transform-computed-properties@7.18.6",
"_inBundle": false,
"_integrity": "sha512-JFwVDXcP/hM/TbyzGq3l/XWGut7p46Z3QvqFMXTfk6/09m7xZHJUN9xHfsv7vqqD4YnfI5ueYdSJtXqqBLyjBw==",
"_integrity": "sha512-9repI4BhNrR0KenoR9vm3/cIc1tSBIo+u1WVjKCAynahj25O8zfbiE6JtAtHPGQSs4yZ+bA8mRasRP+qc+2R5A==",
"_location": "/@babel/plugin-transform-computed-properties",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-transform-computed-properties@7.10.4",
"raw": "@babel/plugin-transform-computed-properties@7.18.6",
"name": "@babel/plugin-transform-computed-properties",
"escapedName": "@babel%2fplugin-transform-computed-properties",
"scope": "@babel",
"rawSpec": "7.10.4",
"rawSpec": "7.18.6",
"saveSpec": null,
"fetchSpec": "7.10.4"
"fetchSpec": "7.18.6"
},
"_requiredBy": [
"/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.10.4.tgz",
"_spec": "7.10.4",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-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/helper-plugin-utils": "^7.18.6"
},
"description": "Compile ES2015 computed properties to ES5",
"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-transform-computed-properties",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"main": "./lib/index.js",
"name": "@babel/plugin-transform-computed-properties",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
@@ -58,5 +64,6 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-transform-computed-properties"
},
"version": "7.10.4"
"type": "commonjs",
"version": "7.18.6"
}