This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
@@ -0,0 +1,4 @@
node_modules
*.log
src
test
@@ -0,0 +1,35 @@
# babel-plugin-transform-es2015-block-scoped-functions
> Babel plugin to ensure function declarations at the block level are block scoped.
## Installation
```sh
npm install --save-dev babel-plugin-transform-es2015-block-scoped-functions
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["transform-es2015-block-scoped-functions"]
}
```
### Via CLI
```sh
babel --plugins transform-es2015-block-scoped-functions script.js
```
### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["transform-es2015-block-scoped-functions"]
});
```
@@ -0,0 +1,63 @@
"use strict";
exports.__esModule = true;
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.default = function (_ref) {
var t = _ref.types;
function statementList(key, path) {
var paths = path.get(key);
for (var _iterator = paths, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref2;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
}
var _path = _ref2;
var func = _path.node;
if (!_path.isFunctionDeclaration()) continue;
var declar = t.variableDeclaration("let", [t.variableDeclarator(func.id, t.toExpression(func))]);
declar._blockHoist = 2;
func.id = null;
_path.replaceWith(declar);
}
}
return {
visitor: {
BlockStatement: function BlockStatement(path) {
var node = path.node,
parent = path.parent;
if (t.isFunction(parent, { body: node }) || t.isExportDeclaration(parent)) {
return;
}
statementList("body", path);
},
SwitchCase: function SwitchCase(path) {
statementList("consequent", path);
}
}
};
};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = exports["default"];
@@ -0,0 +1,100 @@
{
"_args": [
[
{
"raw": "babel-plugin-transform-es2015-block-scoped-functions@^6.22.0",
"scope": null,
"escapedName": "babel-plugin-transform-es2015-block-scoped-functions",
"name": "babel-plugin-transform-es2015-block-scoped-functions",
"rawSpec": "^6.22.0",
"spec": ">=6.22.0 <7.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\babel-preset-env"
]
],
"_from": "babel-plugin-transform-es2015-block-scoped-functions@>=6.22.0 <7.0.0",
"_id": "babel-plugin-transform-es2015-block-scoped-functions@6.22.0",
"_inCache": true,
"_location": "/babel-plugin-transform-es2015-block-scoped-functions",
"_nodeVersion": "6.9.0",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz_1484872427609_0.37350659677758813"
},
"_npmUser": {
"name": "hzoo",
"email": "hi@henryzoo.com"
},
"_npmVersion": "3.10.10",
"_phantomChildren": {},
"_requested": {
"raw": "babel-plugin-transform-es2015-block-scoped-functions@^6.22.0",
"scope": null,
"escapedName": "babel-plugin-transform-es2015-block-scoped-functions",
"name": "babel-plugin-transform-es2015-block-scoped-functions",
"rawSpec": "^6.22.0",
"spec": ">=6.22.0 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-preset-env"
],
"_resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz",
"_shasum": "bbc51b49f964d70cb8d8e0b94e820246ce3a6141",
"_shrinkwrap": null,
"_spec": "babel-plugin-transform-es2015-block-scoped-functions@^6.22.0",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\babel-preset-env",
"dependencies": {
"babel-runtime": "^6.22.0"
},
"description": "Babel plugin to ensure function declarations at the block level are block scoped",
"devDependencies": {
"babel-helper-plugin-test-runner": "^6.22.0"
},
"directories": {},
"dist": {
"shasum": "bbc51b49f964d70cb8d8e0b94e820246ce3a6141",
"tarball": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz"
},
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "amasad",
"email": "amjad.masad@gmail.com"
},
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "jmm",
"email": "npm-public@jessemccarthy.net"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
},
{
"name": "sebmck",
"email": "sebmck@gmail.com"
},
{
"name": "thejameskyle",
"email": "me@thejameskyle.com"
}
],
"name": "babel-plugin-transform-es2015-block-scoped-functions",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-block-scoped-functions"
},
"scripts": {},
"version": "6.22.0"
}