Commit 0ae470fd authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

Merge branch 'MLAB-670' into 'testing'

Update required modules

See merge request !162
parents cad730bf d27c335f
Pipeline #6650 passed with stage
in 4 seconds
# @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
> Transform optional chaining operators to workaround 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
```
'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 => {
var _api$assumption, _api$assumption2;
api.assertVersion(7);
const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : false;
const pureGetters = (_api$assumption2 = api.assumption("pureGetters")) != null ? _api$assumption2 : false;
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
{"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: t.CallExpression[\"arguments\"]) {\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: NodePath<t.Expression> = 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\";\nimport type { NodePath } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\nexport default declare(api => {\n api.assertVersion(7);\n\n const noDocumentAll = (api.assumption(\"noDocumentAll\") ?? false) as boolean;\n const pureGetters = (api.assumption(\"pureGetters\") ?? false) as boolean;\n\n return {\n name: \"bugfix-v8-spread-parameters-in-optional-chaining\",\n\n visitor: {\n \"OptionalCallExpression|OptionalMemberExpression\"(\n path: NodePath<t.OptionalCallExpression | t.OptionalMemberExpression>,\n ) {\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,EAA8E;AAC5E,EAAA,MAAMC,WAAW,GAAGD,aAAa,CAACE,SAAd,CAAwBC,IAAI,IAAIC,UAAC,CAACC,eAAF,CAAkBF,IAAlB,CAAhC,CAApB,CAAA;EACA,OAAOF,WAAW,IAAI,CAAf,IAAoBA,WAAW,KAAKD,aAAa,CAACM,MAAd,GAAuB,CAAlE,CAAA;AACD,CAAA;;AAUM,SAASC,eAAT,CACLC,IADK,EAEI;EACT,IAAIC,YAAoC,GAAGD,IAA3C,CAAA;EACA,MAAME,MAAM,GAAG,EAAf,CAAA;;EACA,OACED,YAAY,CAACE,0BAAb,EAAA,IACAF,YAAY,CAACG,wBAAb,EAFF,EAGE;IACA,MAAM;AAAET,MAAAA,IAAAA;AAAF,KAAA,GAAWM,YAAjB,CAAA;IACAC,MAAM,CAACG,IAAP,CAAYV,IAAZ,CAAA,CAAA;;AAEA,IAAA,IAAIM,YAAY,CAACE,0BAAb,EAAJ,EAA+C;MAC7CF,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C,CAAA;AACD,KAFD,MAEO,IAAIN,YAAY,CAACG,wBAAb,EAAJ,EAA6C;MAClDH,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C,CAAA;AACD,KAAA;AACF,GAAA;;AACD,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,MAAM,CAACJ,MAA3B,EAAmCU,CAAC,EAApC,EAAwC;AACtC,IAAA,MAAMb,IAAI,GAAGO,MAAM,CAACM,CAAD,CAAnB,CAAA;;AACA,IAAA,IACEZ,UAAC,CAACQ,wBAAF,CAA2BT,IAA3B,CAAA,IACAJ,sBAAsB,CAACI,IAAI,CAACc,SAAN,CAFxB,EAGE;MAEA,IAAId,IAAI,CAACe,QAAT,EAAmB;AACjB,QAAA,OAAO,IAAP,CAAA;AACD,OAAA;;AAGD,MAAA,MAAMC,MAAM,GAAGT,MAAM,CAACM,CAAC,GAAG,CAAL,CAArB,CAAA;;AACA,MAAA,IAAIZ,UAAC,CAACO,0BAAF,CAA6BQ,MAA7B,EAAqC;AAAED,QAAAA,QAAQ,EAAE,IAAA;AAAZ,OAArC,CAAJ,EAA8D;AAC5D,QAAA,OAAO,IAAP,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;;AACD,EAAA,OAAO,KAAP,CAAA;AACD;;ACpDD,YAAeE,yBAAO,CAACC,GAAG,IAAI;AAAA,EAAA,IAAA,eAAA,EAAA,gBAAA,CAAA;;EAC5BA,GAAG,CAACC,aAAJ,CAAkB,CAAlB,CAAA,CAAA;EAEA,MAAMC,aAAa,sBAAIF,GAAG,CAACG,UAAJ,CAAe,eAAf,CAAJ,KAAA,IAAA,GAAA,eAAA,GAAuC,KAA1D,CAAA;EACA,MAAMC,WAAW,uBAAIJ,GAAG,CAACG,UAAJ,CAAe,aAAf,CAAJ,KAAA,IAAA,GAAA,gBAAA,GAAqC,KAAtD,CAAA;EAEA,OAAO;AACLE,IAAAA,IAAI,EAAE,kDADD;AAGLC,IAAAA,OAAO,EAAE;AACP,MAAA,iDAAA,CACEnB,IADF,EAEE;AACA,QAAA,IAAID,eAAe,CAACC,IAAD,CAAnB,EAA2B;UACzBoB,wCAAS,CAACpB,IAAD,EAAO;YAAEe,aAAF;AAAiBE,YAAAA,WAAAA;AAAjB,WAAP,CAAT,CAAA;AACD,SAAA;AACF,OAAA;;AAPM,KAAA;GAHX,CAAA;AAaD,CAnBqB,CAAtB;;;;"}
\ No newline at end of file
{
"name": "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining",
"version": "7.18.6",
"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",
"./package.json": "./package.json"
},
"keywords": [
"babel-plugin",
"bugfix"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.18.6",
"@babel/helper-skip-transparent-expression-wrappers": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.18.6"
},
"peerDependencies": {
"@babel/core": "^7.13.0"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6",
"@babel/traverse": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-proposal-async-generator-functions
> Turn async generator functions into ES2015 generators
See our website [@babel/plugin-proposal-async-generator-functions](https://babeljs.io/docs/en/babel-plugin-proposal-async-generator-functions) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-async-generator-functions
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-async-generator-functions --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _core = require("@babel/core");
const buildForAwait = (0, _core.template)(`
async function wrapper() {
var ITERATOR_ABRUPT_COMPLETION = false;
var ITERATOR_HAD_ERROR_KEY = false;
var ITERATOR_ERROR_KEY;
try {
for (
var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY;
ITERATOR_ABRUPT_COMPLETION = !(STEP_KEY = await ITERATOR_KEY.next()).done;
ITERATOR_ABRUPT_COMPLETION = false
) {
}
} catch (err) {
ITERATOR_HAD_ERROR_KEY = true;
ITERATOR_ERROR_KEY = err;
} finally {
try {
if (ITERATOR_ABRUPT_COMPLETION && ITERATOR_KEY.return != null) {
await ITERATOR_KEY.return();
}
} finally {
if (ITERATOR_HAD_ERROR_KEY) {
throw ITERATOR_ERROR_KEY;
}
}
}
}
`);
function _default(path, {
getAsyncIterator
}) {
const {
node,
scope,
parent
} = path;
const stepKey = scope.generateUidIdentifier("step");
const stepValue = _core.types.memberExpression(stepKey, _core.types.identifier("value"));
const left = node.left;
let declar;
if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) {
declar = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, stepValue));
} else if (_core.types.isVariableDeclaration(left)) {
declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, stepValue)]);
}
let template = buildForAwait({
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
ITERATOR_ABRUPT_COMPLETION: scope.generateUidIdentifier("iteratorAbruptCompletion"),
ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
ITERATOR_KEY: scope.generateUidIdentifier("iterator"),
GET_ITERATOR: getAsyncIterator,
OBJECT: node.right,
STEP_KEY: _core.types.cloneNode(stepKey)
});
template = template.body.body;
const isLabeledParent = _core.types.isLabeledStatement(parent);
const tryBody = template[3].block.body;
const loop = tryBody[0];
if (isLabeledParent) {
tryBody[0] = _core.types.labeledStatement(parent.label, loop);
}
return {
replaceParent: isLabeledParent,
node: template,
declar,
loop
};
}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperRemapAsyncToGenerator = require("@babel/helper-remap-async-to-generator");
var _pluginSyntaxAsyncGenerators = require("@babel/plugin-syntax-async-generators");
var _core = require("@babel/core");
var _forAwait = require("./for-await");
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
const yieldStarVisitor = _core.traverse.visitors.merge([{
ArrowFunctionExpression(path) {
path.skip();
},
YieldExpression({
node
}, state) {
if (!node.delegate) return;
const callee = state.addHelper("asyncGeneratorDelegate");
node.argument = _core.types.callExpression(callee, [_core.types.callExpression(state.addHelper("asyncIterator"), [node.argument]), state.addHelper("awaitAsyncGenerator")]);
}
}, _helperEnvironmentVisitor.default]);
const forAwaitVisitor = _core.traverse.visitors.merge([{
ArrowFunctionExpression(path) {
path.skip();
},
ForOfStatement(path, {
file
}) {
const {
node
} = path;
if (!node.await) return;
const build = (0, _forAwait.default)(path, {
getAsyncIterator: file.addHelper("asyncIterator")
});
const {
declar,
loop
} = build;
const block = loop.body;
path.ensureBlock();
if (declar) {
block.body.push(declar);
}
block.body.push(...path.node.body.body);
_core.types.inherits(loop, node);
_core.types.inherits(loop.body, node.body);
if (build.replaceParent) {
path.parentPath.replaceWithMultiple(build.node);
} else {
path.replaceWithMultiple(build.node);
}
}
}, _helperEnvironmentVisitor.default]);
const visitor = {
Function(path, state) {
if (!path.node.async) return;
path.traverse(forAwaitVisitor, state);
if (!path.node.generator) return;
path.traverse(yieldStarVisitor, state);
(0, _helperRemapAsyncToGenerator.default)(path, {
wrapAsync: state.addHelper("wrapAsyncGenerator"),
wrapAwait: state.addHelper("awaitAsyncGenerator")
});
}
};
return {
name: "proposal-async-generator-functions",
inherits: _pluginSyntaxAsyncGenerators.default,
visitor: {
Program(path, state) {
path.traverse(visitor, state);
}
}
};
});
exports.default = _default;
\ No newline at end of file
{
"name": "@babel/plugin-proposal-async-generator-functions",
"version": "7.18.6",
"description": "Turn async generator functions into ES2015 generators",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-async-generator-functions"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-proposal-async-generator-functions",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-environment-visitor": "^7.18.6",
"@babel/helper-plugin-utils": "^7.18.6",
"@babel/helper-remap-async-to-generator": "^7.18.6",
"@babel/plugin-syntax-async-generators": "^7.8.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6",
"babel-plugin-polyfill-corejs3": "^0.5.2",
"core-js-pure": "^3.20.2"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-proposal-class-properties
> This plugin transforms static class properties as well as properties declared with the property initializer syntax
See our website [@babel/plugin-proposal-class-properties](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-class-properties
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-class-properties --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperCreateClassFeaturesPlugin = require("@babel/helper-create-class-features-plugin");
var _default = (0, _helperPluginUtils.declare)((api, options) => {
api.assertVersion(7);
return (0, _helperCreateClassFeaturesPlugin.createClassFeaturePlugin)({
name: "proposal-class-properties",
api,
feature: _helperCreateClassFeaturesPlugin.FEATURES.fields,
loose: options.loose,
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("classProperties", "classPrivateProperties");
}
});
});
exports.default = _default;
\ No newline at end of file
{
"name": "@babel/plugin-proposal-class-properties",
"version": "7.18.6",
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-class-properties"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-proposal-class-properties",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-create-class-features-plugin": "^7.18.6",
"@babel/helper-plugin-utils": "^7.18.6"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-proposal-class-static-block
> Allow parsing of class static blocks
See our website [@babel/plugin-proposal-class-static-block](https://babeljs.io/docs/en/babel-plugin-proposal-class-static-block) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-class-static-block
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-class-static-block --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxClassStaticBlock = require("@babel/plugin-syntax-class-static-block");
var _helperCreateClassFeaturesPlugin = require("@babel/helper-create-class-features-plugin");
function generateUid(scope, denyList) {
const name = "";
let uid;
let i = 1;
do {
uid = scope._generateUid(name, i);
i++;
} while (denyList.has(uid));
return uid;
}
var _default = (0, _helperPluginUtils.declare)(({
types: t,
template,
assertVersion
}) => {
assertVersion("^7.12.0");
return {
name: "proposal-class-static-block",
inherits: _pluginSyntaxClassStaticBlock.default,
pre() {
(0, _helperCreateClassFeaturesPlugin.enableFeature)(this.file, _helperCreateClassFeaturesPlugin.FEATURES.staticBlocks, false);
},
visitor: {
ClassBody(classBody) {
const {
scope
} = classBody;
const privateNames = new Set();
const body = classBody.get("body");
for (const path of body) {
if (path.isPrivate()) {
privateNames.add(path.get("key.id").node.name);
}
}
for (const path of body) {
if (!path.isStaticBlock()) continue;
const staticBlockPrivateId = generateUid(scope, privateNames);
privateNames.add(staticBlockPrivateId);
const staticBlockRef = t.privateName(t.identifier(staticBlockPrivateId));
let replacement;
const blockBody = path.node.body;
if (blockBody.length === 1 && t.isExpressionStatement(blockBody[0])) {
replacement = blockBody[0].expression;
} else {
replacement = template.expression.ast`(() => { ${blockBody} })()`;
}
path.replaceWith(t.classPrivateProperty(staticBlockRef, replacement, [], true));
}
}
}
};
});
exports.default = _default;
\ No newline at end of file
{
"name": "@babel/plugin-proposal-class-static-block",
"version": "7.18.6",
"description": "Transform class static blocks",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-class-static-block"
},
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
},
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-create-class-features-plugin": "^7.18.6",
"@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-class-static-block": "^7.14.5"
},
"peerDependencies": {
"@babel/core": "^7.12.0"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6",
"@babel/traverse": "^7.18.6",
"@babel/types": "^7.18.6"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-proposal-class-static-block",
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-proposal-dynamic-import
> Transform import() expressions
See our website [@babel/plugin-proposal-dynamic-import](https://babeljs.io/docs/en/babel-plugin-proposal-dynamic-import) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-dynamic-import
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-dynamic-import --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxDynamicImport = require("@babel/plugin-syntax-dynamic-import");
const SUPPORTED_MODULES = ["commonjs", "amd", "systemjs"];
const MODULES_NOT_FOUND = `\
@babel/plugin-proposal-dynamic-import depends on a modules
transform plugin. Supported plugins are:
- @babel/plugin-transform-modules-commonjs ^7.4.0
- @babel/plugin-transform-modules-amd ^7.4.0
- @babel/plugin-transform-modules-systemjs ^7.4.0
If you are using Webpack or Rollup and thus don't want
Babel to transpile your imports and exports, you can use
the @babel/plugin-syntax-dynamic-import plugin and let your
bundler handle dynamic imports.
`;
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
return {
name: "proposal-dynamic-import",
inherits: _pluginSyntaxDynamicImport.default,
pre() {
this.file.set("@babel/plugin-proposal-dynamic-import", "7.18.6");
},
visitor: {
Program() {
const modules = this.file.get("@babel/plugin-transform-modules-*");
if (!SUPPORTED_MODULES.includes(modules)) {
throw new Error(MODULES_NOT_FOUND);
}
}
}
};
});
exports.default = _default;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment