Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-classes

Package Overview
Dependencies
Maintainers
5
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-classes - npm Package Compare versions

Comparing version 7.2.2 to 7.3.3

104

lib/transformClass.js

@@ -83,21 +83,2 @@ "use strict";

}
},
ThisExpression(path, state) {
if (!state.isDerived) return;
const {
node,
parentPath
} = path;
if (parentPath.isMemberExpression({
object: node
})) {
return;
}
const assertion = _core().types.callExpression(state.file.addHelper("assertThisInitialized"), [node]);
path.replaceWith(assertion);
path.skip();
}

@@ -129,3 +110,2 @@

body: [],
bareSupers: new Set(),
superThises: [],

@@ -258,30 +238,14 @@ pushedConstructor: false,

replaceSupers.replace();
const state = {
returns: [],
bareSupers: new Set()
};
const superReturns = [];
path.traverse(_core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, {
ReturnStatement(path, state) {
ReturnStatement(path) {
if (!path.getFunctionParent().isArrowFunctionExpression()) {
state.returns.push(path);
superReturns.push(path);
}
},
Super(path, state) {
const {
node,
parentPath
} = path;
if (parentPath.isCallExpression({
callee: node
})) {
state.bareSupers.add(parentPath);
}
}
}]), state);
}]));
if (isConstructor) {
pushConstructor(state, node, path);
pushConstructor(superReturns, node, path);
} else {

@@ -382,3 +346,2 @@ pushMethod(node, path);

path.traverse(findThisesVisitor);
let guaranteedSuperBeforeFinish = !!classState.bareSupers.size;

@@ -393,3 +356,37 @@ let thisRef = function () {

for (const bareSuper of classState.bareSupers) {
for (const thisPath of classState.superThises) {
const {
node,
parentPath
} = thisPath;
if (parentPath.isMemberExpression({
object: node
})) {
thisPath.replaceWith(thisRef());
continue;
}
thisPath.replaceWith(_core().types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()]));
}
const bareSupers = new Set();
path.traverse(_core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, {
Super(path) {
const {
node,
parentPath
} = path;
if (parentPath.isCallExpression({
callee: node
})) {
bareSupers.add(parentPath);
}
}
}]));
let guaranteedSuperBeforeFinish = !!bareSupers.size;
for (const bareSuper of bareSupers) {
wrapSuperCall(bareSuper, classState.superName, thisRef, body);

@@ -411,18 +408,2 @@

for (const thisPath of classState.superThises) {
const {
node,
parentPath
} = thisPath;
if (parentPath.isMemberExpression({
object: node
})) {
thisPath.replaceWith(thisRef());
continue;
}
thisPath.replaceWith(_core().types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()]));
}
let wrapReturn;

@@ -513,3 +494,3 @@

function pushConstructor(replaceSupers, method, path) {
function pushConstructor(superReturns, method, path) {
if (path.scope.hasOwnBinding(classState.classRef.name)) {

@@ -523,4 +504,3 @@ path.scope.rename(classState.classRef.name);

hasConstructor: true,
bareSupers: replaceSupers.bareSupers,
superReturns: replaceSupers.returns
superReturns
});

@@ -527,0 +507,0 @@ const {

{
"name": "@babel/plugin-transform-classes",
"version": "7.2.2",
"version": "7.3.3",
"description": "Compile ES2015 classes to ES5",

@@ -28,5 +28,6 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-classes",

"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/core": "^7.3.3",
"@babel/helper-plugin-test-runner": "^7.0.0"
}
},
"gitHead": "d1fe2d05f4c468640facf40565e30f7110757f2d"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc