0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -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.

View file

@ -0,0 +1,19 @@
# @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
> Transform optional chaining operators to workaround a [v8 bug](https://crbug.com/v8/11558).
See our website [@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining](https://babeljs.io/docs/en/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
```
or using yarn:
```sh
yarn add @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining --dev
```

View file

@ -0,0 +1,74 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helperPluginUtils = require('@babel/helper-plugin-utils');
var pluginProposalOptionalChaining = require('@babel/plugin-proposal-optional-chaining');
var helperSkipTransparentExpressionWrappers = require('@babel/helper-skip-transparent-expression-wrappers');
var core = require('@babel/core');
function matchAffectedArguments(argumentNodes) {
const spreadIndex = argumentNodes.findIndex(node => core.types.isSpreadElement(node));
return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;
}
function shouldTransform(path) {
let optionalPath = path;
const chains = [];
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
const {
node
} = optionalPath;
chains.push(node);
if (optionalPath.isOptionalMemberExpression()) {
optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("object"));
} else if (optionalPath.isOptionalCallExpression()) {
optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("callee"));
}
}
for (let i = 0; i < chains.length; i++) {
const node = chains[i];
if (core.types.isOptionalCallExpression(node) && matchAffectedArguments(node.arguments)) {
if (node.optional) {
return true;
}
const callee = chains[i + 1];
if (core.types.isOptionalMemberExpression(callee, {
optional: true
})) {
return true;
}
}
}
return false;
}
var index = helperPluginUtils.declare(api => {
api.assertVersion(7);
const noDocumentAll = api.assumption("noDocumentAll");
const pureGetters = api.assumption("pureGetters");
return {
name: "bugfix-v8-spread-parameters-in-optional-chaining",
visitor: {
"OptionalCallExpression|OptionalMemberExpression"(path) {
if (shouldTransform(path)) {
pluginProposalOptionalChaining.transform(path, {
noDocumentAll,
pureGetters
});
}
}
}
};
});
exports.default = index;
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import { skipTransparentExprWrappers } from \"@babel/helper-skip-transparent-expression-wrappers\";\nimport type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\n// https://crbug.com/v8/11558\n\n// check if there is a spread element followed by another argument.\n// (...[], 0) or (...[], ...[])\n\nfunction matchAffectedArguments(argumentNodes) {\n const spreadIndex = argumentNodes.findIndex(node => t.isSpreadElement(node));\n return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;\n}\n\n/**\n * Check whether the optional chain is affected by https://crbug.com/v8/11558.\n * This routine MUST not manipulate NodePath\n *\n * @export\n * @param {(NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>)} path\n * @returns {boolean}\n */\nexport function shouldTransform(\n path: NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>,\n): boolean {\n let optionalPath = path;\n const chains = [];\n while (\n optionalPath.isOptionalMemberExpression() ||\n optionalPath.isOptionalCallExpression()\n ) {\n const { node } = optionalPath;\n chains.push(node);\n\n if (optionalPath.isOptionalMemberExpression()) {\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"object\"));\n } else if (optionalPath.isOptionalCallExpression()) {\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"callee\"));\n }\n }\n for (let i = 0; i < chains.length; i++) {\n const node = chains[i];\n if (\n t.isOptionalCallExpression(node) &&\n matchAffectedArguments(node.arguments)\n ) {\n // f?.(...[], 0)\n if (node.optional) {\n return true;\n }\n // o?.m(...[], 0)\n // when node.optional is false, chains[i + 1] is always well defined\n const callee = chains[i + 1];\n if (t.isOptionalMemberExpression(callee, { optional: true })) {\n return true;\n }\n }\n }\n return false;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport { transform } from \"@babel/plugin-proposal-optional-chaining\";\nimport { shouldTransform } from \"./util\";\n\nexport default declare(api => {\n api.assertVersion(7);\n\n const noDocumentAll = api.assumption(\"noDocumentAll\");\n const pureGetters = api.assumption(\"pureGetters\");\n\n return {\n name: \"bugfix-v8-spread-parameters-in-optional-chaining\",\n\n visitor: {\n \"OptionalCallExpression|OptionalMemberExpression\"(path) {\n if (shouldTransform(path)) {\n transform(path, { noDocumentAll, pureGetters });\n }\n },\n },\n };\n});\n"],"names":["matchAffectedArguments","argumentNodes","spreadIndex","findIndex","node","t","isSpreadElement","length","shouldTransform","path","optionalPath","chains","isOptionalMemberExpression","isOptionalCallExpression","push","skipTransparentExprWrappers","get","i","arguments","optional","callee","declare","api","assertVersion","noDocumentAll","assumption","pureGetters","name","visitor","transform"],"mappings":";;;;;;;;;AAQA,SAASA,sBAAT,CAAgCC,aAAhC,EAA+C;AAC7C,QAAMC,WAAW,GAAGD,aAAa,CAACE,SAAd,CAAwBC,IAAI,IAAIC,UAAC,CAACC,eAAF,CAAkBF,IAAlB,CAAhC,CAApB;AACA,SAAOF,WAAW,IAAI,CAAf,IAAoBA,WAAW,KAAKD,aAAa,CAACM,MAAd,GAAuB,CAAlE;AACD;;AAUM,SAASC,eAAT,CACLC,IADK,EAEI;AACT,MAAIC,YAAY,GAAGD,IAAnB;AACA,QAAME,MAAM,GAAG,EAAf;;AACA,SACED,YAAY,CAACE,0BAAb,MACAF,YAAY,CAACG,wBAAb,EAFF,EAGE;AACA,UAAM;AAAET,MAAAA;AAAF,QAAWM,YAAjB;AACAC,IAAAA,MAAM,CAACG,IAAP,CAAYV,IAAZ;;AAEA,QAAIM,YAAY,CAACE,0BAAb,EAAJ,EAA+C;AAC7CF,MAAAA,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C;AACD,KAFD,MAEO,IAAIN,YAAY,CAACG,wBAAb,EAAJ,EAA6C;AAClDH,MAAAA,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C;AACD;AACF;;AACD,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,MAAM,CAACJ,MAA3B,EAAmCU,CAAC,EAApC,EAAwC;AACtC,UAAMb,IAAI,GAAGO,MAAM,CAACM,CAAD,CAAnB;;AACA,QACEZ,UAAC,CAACQ,wBAAF,CAA2BT,IAA3B,KACAJ,sBAAsB,CAACI,IAAI,CAACc,SAAN,CAFxB,EAGE;AAEA,UAAId,IAAI,CAACe,QAAT,EAAmB;AACjB,eAAO,IAAP;AACD;;AAGD,YAAMC,MAAM,GAAGT,MAAM,CAACM,CAAC,GAAG,CAAL,CAArB;;AACA,UAAIZ,UAAC,CAACO,0BAAF,CAA6BQ,MAA7B,EAAqC;AAAED,QAAAA,QAAQ,EAAE;AAAZ,OAArC,CAAJ,EAA8D;AAC5D,eAAO,IAAP;AACD;AACF;AACF;;AACD,SAAO,KAAP;AACD;;ACtDD,YAAeE,yBAAO,CAACC,GAAG,IAAI;AAC5BA,EAAAA,GAAG,CAACC,aAAJ,CAAkB,CAAlB;AAEA,QAAMC,aAAa,GAAGF,GAAG,CAACG,UAAJ,CAAe,eAAf,CAAtB;AACA,QAAMC,WAAW,GAAGJ,GAAG,CAACG,UAAJ,CAAe,aAAf,CAApB;AAEA,SAAO;AACLE,IAAAA,IAAI,EAAE,kDADD;AAGLC,IAAAA,OAAO,EAAE;AACP,wDAAkDnB,IAAlD,EAAwD;AACtD,YAAID,eAAe,CAACC,IAAD,CAAnB,EAA2B;AACzBoB,UAAAA,wCAAS,CAACpB,IAAD,EAAO;AAAEe,YAAAA,aAAF;AAAiBE,YAAAA;AAAjB,WAAP,CAAT;AACD;AACF;;AALM;AAHJ,GAAP;AAWD,CAjBqB,CAAtB;;;;"}

View file

@ -0,0 +1,42 @@
{
"name": "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining",
"version": "7.14.5",
"description": "Transform optional chaining operators to workaround https://crbug.com/v8/11558",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"exports": {
".": [
"./lib/index.js"
]
},
"keywords": [
"babel-plugin",
"bugfix"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.14.5",
"@babel/helper-skip-transparent-expression-wrappers": "^7.14.5",
"@babel/plugin-proposal-optional-chaining": "^7.14.5"
},
"peerDependencies": {
"@babel/core": "^7.13.0"
},
"devDependencies": {
"@babel/core": "7.14.5",
"@babel/helper-plugin-test-runner": "7.14.5",
"@babel/traverse": "7.14.5"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
}