Befor generating
This commit is contained in:
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
# @babel/plugin-bugfix-safari-rest-destructuring-rhs-array
|
||||
|
||||
> Workaround a Safari bug where rest destructuring with an array literal on the rhs can yield incorrect results
|
||||
|
||||
See our website [@babel/plugin-bugfix-safari-rest-destructuring-rhs-array](https://babeljs.io/docs/babel-plugin-bugfix-safari-rest-destructuring-rhs-array) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-bugfix-safari-rest-destructuring-rhs-array
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-bugfix-safari-rest-destructuring-rhs-array --dev
|
||||
```
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
||||
var _util = require("./util.js");
|
||||
var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
|
||||
const {
|
||||
types: t,
|
||||
assertVersion
|
||||
} = api;
|
||||
assertVersion(7);
|
||||
return {
|
||||
name: "plugin-bugfix-safari-rest-destructuring-rhs-array",
|
||||
visitor: {
|
||||
ArrayPattern(path) {
|
||||
const rhs = (0, _util.shouldTransform)(path);
|
||||
if (rhs) {
|
||||
path.replaceWith(t.arrayPattern([path.node]));
|
||||
rhs.replaceWith(t.arrayExpression([rhs.node]));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_helperPluginUtils","require","_util","_default","exports","default","declare","api","types","t","assertVersion","name","visitor","ArrayPattern","path","rhs","shouldTransform","replaceWith","arrayPattern","node","arrayExpression"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { shouldTransform } from \"./util.ts\";\n\nexport default declare(api => {\n const { types: t, assertVersion } = api;\n assertVersion(REQUIRED_VERSION(7));\n\n return {\n name: \"plugin-bugfix-safari-rest-destructuring-rhs-array\",\n\n visitor: {\n ArrayPattern(path) {\n const rhs = shouldTransform(path);\n if (rhs) {\n // The most minimal approach is to add a trailing comma to the rhs array,\n // but that would be easily reverted by minifiers, so instead we wrap both sides\n // in an array\n path.replaceWith(t.arrayPattern([path.node]));\n rhs.replaceWith(t.arrayExpression([rhs.node]));\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAA4C,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE7B,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5B,MAAM;IAAEC,KAAK,EAAEC,CAAC;IAAEC;EAAc,CAAC,GAAGH,GAAG;EACvCG,aAAa,CAAkB,CAAE,CAAC;EAElC,OAAO;IACLC,IAAI,EAAE,mDAAmD;IAEzDC,OAAO,EAAE;MACPC,YAAYA,CAACC,IAAI,EAAE;QACjB,MAAMC,GAAG,GAAG,IAAAC,qBAAe,EAACF,IAAI,CAAC;QACjC,IAAIC,GAAG,EAAE;UAIPD,IAAI,CAACG,WAAW,CAACR,CAAC,CAACS,YAAY,CAAC,CAACJ,IAAI,CAACK,IAAI,CAAC,CAAC,CAAC;UAC7CJ,GAAG,CAACE,WAAW,CAACR,CAAC,CAACW,eAAe,CAAC,CAACL,GAAG,CAACI,IAAI,CAAC,CAAC,CAAC;QAChD;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
||||
Generated
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isPathSimpleArrayWithLength = isPathSimpleArrayWithLength;
|
||||
exports.shouldTransform = shouldTransform;
|
||||
var _helperSkipTransparentExpressionWrappers = require("@babel/helper-skip-transparent-expression-wrappers");
|
||||
function isPathSimpleArrayWithLength(path, N) {
|
||||
var _path$node$extra;
|
||||
if (!path.isArrayExpression()) {
|
||||
return false;
|
||||
}
|
||||
const elementPaths = path.get("elements");
|
||||
return elementPaths.length === N && elementPaths.every(elementPath => elementPath.node && !elementPath.isSpreadElement()) && !((_path$node$extra = path.node.extra) != null && _path$node$extra.trailingComma);
|
||||
}
|
||||
function shouldTransform(path) {
|
||||
const elementPaths = path.get("elements");
|
||||
const elementPathsLength = elementPaths.length;
|
||||
if (elementPaths[elementPathsLength - 1].isRestElement()) {
|
||||
const {
|
||||
parentPath
|
||||
} = path;
|
||||
const rhsPath = parentPath.isVariableDeclarator() ? parentPath.get("init") : parentPath.isAssignmentExpression() ? parentPath.get("right") : null;
|
||||
if (rhsPath != null && rhsPath.node && isPathSimpleArrayWithLength((0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(rhsPath), elementPathsLength)) {
|
||||
return rhsPath;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=util.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_helperSkipTransparentExpressionWrappers","require","isPathSimpleArrayWithLength","path","N","_path$node$extra","isArrayExpression","elementPaths","get","length","every","elementPath","node","isSpreadElement","extra","trailingComma","shouldTransform","elementPathsLength","isRestElement","parentPath","rhsPath","isVariableDeclarator","isAssignmentExpression","skipTransparentExprWrappers"],"sources":["../src/util.ts"],"sourcesContent":["import type { NodePath, types as t } from \"@babel/core\";\nimport { skipTransparentExprWrappers } from \"@babel/helper-skip-transparent-expression-wrappers\";\n\n/**\n * Check whether a path is an ArrayExpression with exactly N non-spread & non-hole elements and no trailing comma\n * @param path\n * @param N\n * @returns\n */\nexport function isPathSimpleArrayWithLength(\n path: NodePath,\n N: number,\n): path is NodePath<t.ArrayExpression> {\n if (!path.isArrayExpression()) {\n return false;\n }\n const elementPaths = path.get(\"elements\");\n return (\n elementPaths.length === N &&\n elementPaths.every(\n elementPath => elementPath.node && !elementPath.isSpreadElement(),\n ) &&\n !path.node.extra?.trailingComma\n );\n}\n\n/**\n * Check whether an array pattern may be affected by\n * https://github.com/babel/babel/issues/17773#issuecomment-3842765704\n * @param path The array pattern NodePath\n * @returns The RHS NodePath if the pattern should be transformed, or false if it can be left as-is.\n */\nexport function shouldTransform(\n path: NodePath<t.ArrayPattern>,\n): NodePath<t.Expression> | false {\n const elementPaths = path.get(\"elements\");\n const elementPathsLength = elementPaths.length;\n if (elementPaths[elementPathsLength - 1].isRestElement()) {\n const { parentPath } = path;\n const rhsPath = parentPath.isVariableDeclarator()\n ? parentPath.get(\"init\")\n : parentPath.isAssignmentExpression()\n ? parentPath.get(\"right\")\n : null;\n if (\n rhsPath?.node &&\n isPathSimpleArrayWithLength(\n skipTransparentExprWrappers(rhsPath),\n elementPathsLength,\n )\n ) {\n return rhsPath;\n }\n }\n return false;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,wCAAA,GAAAC,OAAA;AAQO,SAASC,2BAA2BA,CACzCC,IAAc,EACdC,CAAS,EAC4B;EAAA,IAAAC,gBAAA;EACrC,IAAI,CAACF,IAAI,CAACG,iBAAiB,CAAC,CAAC,EAAE;IAC7B,OAAO,KAAK;EACd;EACA,MAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAG,CAAC,UAAU,CAAC;EACzC,OACED,YAAY,CAACE,MAAM,KAAKL,CAAC,IACzBG,YAAY,CAACG,KAAK,CAChBC,WAAW,IAAIA,WAAW,CAACC,IAAI,IAAI,CAACD,WAAW,CAACE,eAAe,CAAC,CAClE,CAAC,IACD,GAAAR,gBAAA,GAACF,IAAI,CAACS,IAAI,CAACE,KAAK,aAAfT,gBAAA,CAAiBU,aAAa;AAEnC;AAQO,SAASC,eAAeA,CAC7Bb,IAA8B,EACE;EAChC,MAAMI,YAAY,GAAGJ,IAAI,CAACK,GAAG,CAAC,UAAU,CAAC;EACzC,MAAMS,kBAAkB,GAAGV,YAAY,CAACE,MAAM;EAC9C,IAAIF,YAAY,CAACU,kBAAkB,GAAG,CAAC,CAAC,CAACC,aAAa,CAAC,CAAC,EAAE;IACxD,MAAM;MAAEC;IAAW,CAAC,GAAGhB,IAAI;IAC3B,MAAMiB,OAAO,GAAGD,UAAU,CAACE,oBAAoB,CAAC,CAAC,GAC7CF,UAAU,CAACX,GAAG,CAAC,MAAM,CAAC,GACtBW,UAAU,CAACG,sBAAsB,CAAC,CAAC,GACjCH,UAAU,CAACX,GAAG,CAAC,OAAO,CAAC,GACvB,IAAI;IACV,IACEY,OAAO,YAAPA,OAAO,CAAER,IAAI,IACbV,2BAA2B,CACzB,IAAAqB,oEAA2B,EAACH,OAAO,CAAC,EACpCH,kBACF,CAAC,EACD;MACA,OAAOG,OAAO;IAChB;EACF;EACA,OAAO,KAAK;AACd","ignoreList":[]}
|
||||
Generated
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@babel/plugin-bugfix-safari-rest-destructuring-rhs-array",
|
||||
"version": "7.29.7",
|
||||
"description": "Workaround a Safari bug where rest destructuring with an array literal on the rhs can yield incorrect results",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-bugfix-safari-rest-destructuring-rhs-array"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-bugfix-safari-rest-destructuring-rhs-array",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"keywords": [
|
||||
"babel-plugin",
|
||||
"bugfix"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.29.7",
|
||||
"@babel/helper-skip-transparent-expression-wrappers": "^7.29.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.29.7",
|
||||
"@babel/helper-plugin-test-runner": "^7.29.7",
|
||||
"@babel/traverse": "^7.29.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
Reference in New Issue
Block a user