aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-proposal-class-properties
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/plugin-proposal-class-properties')
-rw-r--r--node_modules/@babel/plugin-proposal-class-properties/README.md149
-rw-r--r--node_modules/@babel/plugin-proposal-class-properties/lib/index.js265
-rw-r--r--node_modules/@babel/plugin-proposal-class-properties/package.json24
3 files changed, 0 insertions, 438 deletions
diff --git a/node_modules/@babel/plugin-proposal-class-properties/README.md b/node_modules/@babel/plugin-proposal-class-properties/README.md
deleted file mode 100644
index dee62c85..00000000
--- a/node_modules/@babel/plugin-proposal-class-properties/README.md
+++ /dev/null
@@ -1,149 +0,0 @@
-# @babel/plugin-proposal-class-properties
-
-> This plugin transforms class properties
-
-## Example
-
-Below is a class with four class properties which will be transformed.
-
-```js
- class Bork {
- //Property initializer syntax
- instanceProperty = "bork";
- boundFunction = () => {
- return this.instanceProperty;
- };
-
- //Static class properties
- static staticProperty = "babelIsCool";
- static staticFunction = function() {
- return Bork.staticProperty;
- };
- }
-
- let myBork = new Bork;
-
- //Property initializers are not on the prototype.
- console.log(myBork.__proto__.boundFunction); // > undefined
-
- //Bound functions are bound to the class instance.
- console.log(myBork.boundFunction.call(undefined)); // > "bork"
-
- //Static function exists on the class.
- console.log(Bork.staticFunction()); // > "babelIsCool"
-```
-
-
-## Installation
-
-```sh
-npm install --save-dev @babel/plugin-proposal-class-properties
-```
-
-## Usage
-
-### Via `.babelrc` (Recommended)
-
-**.babelrc**
-
-Without options:
-
-```json
-{
- "plugins": ["@babel/plugin-proposal-class-properties"]
-}
-```
-
-With options:
-
-```json
-{
- "plugins": [
- ["@babel/plugin-proposal-class-properties", { "loose": true }]
- ]
-}
-```
-
-### Via CLI
-
-```sh
-babel --plugins @babel/plugin-proposal-class-properties script.js
-```
-
-### Via Node API
-
-```javascript
-require("@babel/core").transform("code", {
- plugins: ["@babel/plugin-proposal-class-properties"]
-});
-```
-
-## Options
-
-### `loose`
-
-`boolean`, defaults to `false`.
-
-When `true`, class properties are compiled to use an assignment expression instead of `Object.defineProperty`.
-
-#### Example
-
-```js
- class Bork {
- static a = 'foo';
- static b;
-
- x = 'bar';
- y;
- }
-```
-
-Without `{ "loose": true }`, the above code will compile to the following, using `Object.defineProperty`:
-
-```js
-var Bork = function Bork() {
- babelHelpers.classCallCheck(this, Bork);
- Object.defineProperty(this, "x", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: 'bar'
- });
- Object.defineProperty(this, "y", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
- });
-};
-
-Object.defineProperty(Bork, "a", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: 'foo'
-});
-Object.defineProperty(Bork, "b", {
- configurable: true,
- enumerable: true,
- writable: true,
- value: void 0
-});
-```
-
-However, with `{ "loose": true }`, it will compile using assignment expressions:
-
-```js
-var Bork = function Bork() {
- babelHelpers.classCallCheck(this, Bork);
- this.x = 'bar';
- this.y = void 0;
-};
-
-Bork.a = 'foo';
-Bork.b = void 0;
-```
-
-## References
-
-* [Proposal: ES Class Fields & Static Properties](https://github.com/jeffmo/es-class-static-properties-and-fields)
diff --git a/node_modules/@babel/plugin-proposal-class-properties/lib/index.js b/node_modules/@babel/plugin-proposal-class-properties/lib/index.js
deleted file mode 100644
index 8ca749dd..00000000
--- a/node_modules/@babel/plugin-proposal-class-properties/lib/index.js
+++ /dev/null
@@ -1,265 +0,0 @@
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.default = void 0;
-
-function _helperPluginUtils() {
- const data = require("@babel/helper-plugin-utils");
-
- _helperPluginUtils = function _helperPluginUtils() {
- return data;
- };
-
- return data;
-}
-
-function _helperFunctionName() {
- const data = _interopRequireDefault(require("@babel/helper-function-name"));
-
- _helperFunctionName = function _helperFunctionName() {
- return data;
- };
-
- return data;
-}
-
-function _pluginSyntaxClassProperties() {
- const data = _interopRequireDefault(require("@babel/plugin-syntax-class-properties"));
-
- _pluginSyntaxClassProperties = function _pluginSyntaxClassProperties() {
- return data;
- };
-
- return data;
-}
-
-function _core() {
- const data = require("@babel/core");
-
- _core = function _core() {
- return data;
- };
-
- return data;
-}
-
-function _helperReplaceSupers() {
- const data = require("@babel/helper-replace-supers");
-
- _helperReplaceSupers = function _helperReplaceSupers() {
- return data;
- };
-
- return data;
-}
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-var _default = (0, _helperPluginUtils().declare)((api, options) => {
- api.assertVersion(7);
- const loose = options.loose;
-
- const findBareSupers = _core().traverse.visitors.merge([{
- Super(path) {
- const node = path.node,
- parentPath = path.parentPath;
-
- if (parentPath.isCallExpression({
- callee: node
- })) {
- this.push(parentPath);
- }
- }
-
- }, _helperReplaceSupers().environmentVisitor]);
-
- const referenceVisitor = {
- "TSTypeAnnotation|TypeAnnotation"(path) {
- path.skip();
- },
-
- ReferencedIdentifier(path) {
- if (this.scope.hasOwnBinding(path.node.name)) {
- this.scope.rename(path.node.name);
- path.skip();
- }
- }
-
- };
-
- const classFieldDefinitionEvaluationTDZVisitor = _core().traverse.visitors.merge([{
- ReferencedIdentifier(path) {
- if (this.classRef === path.scope.getBinding(path.node.name)) {
- const classNameTDZError = this.file.addHelper("classNameTDZError");
-
- const throwNode = _core().types.callExpression(classNameTDZError, [_core().types.stringLiteral(path.node.name)]);
-
- path.replaceWith(_core().types.sequenceExpression([throwNode, path.node]));
- path.skip();
- }
- }
-
- }, _helperReplaceSupers().environmentVisitor]);
-
- const buildClassPropertySpec = (ref, {
- key,
- value,
- computed
- }, scope, state) => {
- return _core().types.expressionStatement(_core().types.callExpression(state.addHelper("defineProperty"), [ref, _core().types.isIdentifier(key) && !computed ? _core().types.stringLiteral(key.name) : key, value || scope.buildUndefinedNode()]));
- };
-
- const buildClassPropertyLoose = (ref, {
- key,
- value,
- computed
- }, scope) => {
- return _core().template.statement`MEMBER = VALUE`({
- MEMBER: _core().types.memberExpression(_core().types.cloneNode(ref), key, computed || _core().types.isLiteral(key)),
- VALUE: value || scope.buildUndefinedNode()
- });
- };
-
- const buildClassProperty = loose ? buildClassPropertyLoose : buildClassPropertySpec;
- return {
- inherits: _pluginSyntaxClassProperties().default,
- visitor: {
- Class(path, state) {
- const isDerived = !!path.node.superClass;
- let constructor;
- const props = [];
- const computedPaths = [];
- const body = path.get("body");
-
- for (var _iterator = body.get("body"), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
- var _ref;
-
- if (_isArray) {
- if (_i >= _iterator.length) break;
- _ref = _iterator[_i++];
- } else {
- _i = _iterator.next();
- if (_i.done) break;
- _ref = _i.value;
- }
-
- const path = _ref;
-
- if (path.node.computed) {
- computedPaths.push(path);
- }
-
- if (path.isClassProperty()) {
- props.push(path);
- } else if (path.isClassMethod({
- kind: "constructor"
- })) {
- constructor = path;
- }
- }
-
- if (!props.length) return;
- let ref;
-
- if (path.isClassExpression() || !path.node.id) {
- (0, _helperFunctionName().default)(path);
- ref = path.scope.generateUidIdentifier("class");
- } else {
- ref = path.node.id;
- }
-
- const computedNodes = [];
- const staticNodes = [];
- const instanceBody = [];
-
- for (var _i2 = 0; _i2 < computedPaths.length; _i2++) {
- const computedPath = computedPaths[_i2];
- const computedNode = computedPath.node;
-
- if (!computedPath.get("key").isConstantExpression()) {
- computedPath.traverse(classFieldDefinitionEvaluationTDZVisitor, {
- classRef: path.scope.getBinding(ref.name),
- file: this.file
- });
- const ident = path.scope.generateUidIdentifierBasedOnNode(computedNode.key);
- computedNodes.push(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(ident, computedNode.key)]));
- computedNode.key = _core().types.cloneNode(ident);
- }
- }
-
- for (var _i3 = 0; _i3 < props.length; _i3++) {
- const prop = props[_i3];
- const propNode = prop.node;
- if (propNode.decorators && propNode.decorators.length > 0) continue;
-
- if (propNode.static) {
- staticNodes.push(buildClassProperty(ref, propNode, path.scope, state));
- } else {
- instanceBody.push(buildClassProperty(_core().types.thisExpression(), propNode, path.scope, state));
- }
- }
-
- if (instanceBody.length) {
- if (!constructor) {
- const newConstructor = _core().types.classMethod("constructor", _core().types.identifier("constructor"), [], _core().types.blockStatement([]));
-
- if (isDerived) {
- newConstructor.params = [_core().types.restElement(_core().types.identifier("args"))];
- newConstructor.body.body.push(_core().types.returnStatement(_core().types.callExpression(_core().types.super(), [_core().types.spreadElement(_core().types.identifier("args"))])));
- }
-
- var _body$unshiftContaine = body.unshiftContainer("body", newConstructor);
-
- constructor = _body$unshiftContaine[0];
- }
-
- const state = {
- scope: constructor.scope
- };
-
- for (var _i4 = 0; _i4 < props.length; _i4++) {
- const prop = props[_i4];
- if (prop.node.static) continue;
- prop.traverse(referenceVisitor, state);
- }
-
- if (isDerived) {
- const bareSupers = [];
- constructor.traverse(findBareSupers, bareSupers);
-
- for (var _i5 = 0; _i5 < bareSupers.length; _i5++) {
- const bareSuper = bareSupers[_i5];
- bareSuper.insertAfter(instanceBody);
- }
- } else {
- constructor.get("body").unshiftContainer("body", instanceBody);
- }
- }
-
- for (var _i6 = 0; _i6 < props.length; _i6++) {
- const prop = props[_i6];
- prop.remove();
- }
-
- if (computedNodes.length === 0 && staticNodes.length === 0) return;
-
- if (path.isClassExpression()) {
- path.scope.push({
- id: ref
- });
- path.replaceWith(_core().types.assignmentExpression("=", _core().types.cloneNode(ref), path.node));
- } else if (!path.node.id) {
- path.node.id = ref;
- }
-
- path.insertBefore(computedNodes);
- path.insertAfter(staticNodes);
- }
-
- }
- };
-});
-
-exports.default = _default; \ No newline at end of file
diff --git a/node_modules/@babel/plugin-proposal-class-properties/package.json b/node_modules/@babel/plugin-proposal-class-properties/package.json
deleted file mode 100644
index 7dc7ffff..00000000
--- a/node_modules/@babel/plugin-proposal-class-properties/package.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "@babel/plugin-proposal-class-properties",
- "version": "7.0.0-beta.47",
- "description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
- "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties",
- "license": "MIT",
- "main": "lib/index.js",
- "keywords": [
- "babel-plugin"
- ],
- "dependencies": {
- "@babel/helper-function-name": "7.0.0-beta.47",
- "@babel/helper-plugin-utils": "7.0.0-beta.47",
- "@babel/helper-replace-supers": "7.0.0-beta.47",
- "@babel/plugin-syntax-class-properties": "7.0.0-beta.47"
- },
- "peerDependencies": {
- "@babel/core": "7.0.0-beta.47"
- },
- "devDependencies": {
- "@babel/core": "7.0.0-beta.47",
- "@babel/helper-plugin-test-runner": "7.0.0-beta.47"
- }
-}