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
+3 -3
View File
@@ -2,18 +2,18 @@
> Helper function to hoist variables
See our website [@babel/helper-hoist-variables](https://babeljs.io/docs/en/next/babel-helper-hoist-variables.html) for more information.
See our website [@babel/helper-hoist-variables](https://babeljs.io/docs/en/babel-helper-hoist-variables) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-hoist-variables
npm install --save @babel/helper-hoist-variables
```
or using yarn:
```sh
yarn add @babel/helper-hoist-variables --dev
yarn add @babel/helper-hoist-variables
```
+11 -10
View File
@@ -3,20 +3,21 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.default = hoistVariables;
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _t = require("@babel/types");
const {
assignmentExpression,
expressionStatement,
identifier
} = _t;
const visitor = {
Scope(path, state) {
if (state.kind === "let") path.skip();
},
Function(path) {
FunctionParent(path) {
path.skip();
},
@@ -30,11 +31,11 @@ const visitor = {
firstId = declar.node.id;
if (declar.node.init) {
nodes.push(t.expressionStatement(t.assignmentExpression("=", declar.node.id, declar.node.init)));
nodes.push(expressionStatement(assignmentExpression("=", declar.node.id, declar.node.init)));
}
for (const name of Object.keys(declar.getBindingIdentifiers())) {
state.emit(t.identifier(name), name, declar.node.init !== null);
state.emit(identifier(name), name, declar.node.init !== null);
}
}
@@ -49,7 +50,7 @@ const visitor = {
};
function _default(path, emit, kind = "var") {
function hoistVariables(path, emit, kind = "var") {
path.traverse(visitor, {
kind,
emit
+29 -17
View File
@@ -1,44 +1,55 @@
{
"TODO": "The @babel/traverse dependency is only needed for the NodePath TS type. We can consider exporting it from @babel/core.",
"_args": [
[
"@babel/helper-hoist-variables@7.10.4",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"@babel/helper-hoist-variables@7.18.6",
"/home/node/nuxt"
]
],
"_from": "@babel/helper-hoist-variables@7.10.4",
"_id": "@babel/helper-hoist-variables@7.10.4",
"_from": "@babel/helper-hoist-variables@7.18.6",
"_id": "@babel/helper-hoist-variables@7.18.6",
"_inBundle": false,
"_integrity": "sha512-wljroF5PgCk2juF69kanHVs6vrLwIPNp6DLD+Lrl3hoQ3PpPPikaDRNFA+0t81NOoMt2DL6WW/mdU8k4k6ZzuA==",
"_integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==",
"_location": "/@babel/helper-hoist-variables",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/helper-hoist-variables@7.10.4",
"raw": "@babel/helper-hoist-variables@7.18.6",
"name": "@babel/helper-hoist-variables",
"escapedName": "@babel%2fhelper-hoist-variables",
"scope": "@babel",
"rawSpec": "7.10.4",
"rawSpec": "7.18.6",
"saveSpec": null,
"fetchSpec": "7.10.4"
"fetchSpec": "7.18.6"
},
"_requiredBy": [
"/@babel/plugin-transform-modules-systemjs"
"/@babel/plugin-transform-modules-systemjs",
"/@babel/traverse"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.10.4.tgz",
"_spec": "7.10.4",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-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/types": "^7.10.4"
"@babel/types": "^7.18.6"
},
"description": "Helper function to hoist variables",
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
"homepage": "https://github.com/babel/babel#readme",
"devDependencies": {
"@babel/traverse": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"homepage": "https://babel.dev/docs/en/next/babel-helper-hoist-variables",
"license": "MIT",
"main": "lib/index.js",
"main": "./lib/index.js",
"name": "@babel/helper-hoist-variables",
"publishConfig": {
"access": "public"
@@ -48,5 +59,6 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-helper-hoist-variables"
},
"version": "7.10.4"
"type": "commonjs",
"version": "7.18.6"
}