@babel/helper-create-class-features-plugin
Advanced tools
Comparing version 7.22.15 to 7.23.5
@@ -127,3 +127,5 @@ "use strict"; | ||
return { | ||
instanceNodes: [_core.template.statement.ast`${_core.types.cloneNode(initializeId)}(this)`], | ||
instanceNodes: [_core.template.statement.ast` | ||
${_core.types.cloneNode(initializeId)}(this) | ||
`], | ||
wrapClass(path) { | ||
@@ -130,0 +132,0 @@ path.replaceWith(replacement); |
@@ -11,3 +11,3 @@ "use strict"; | ||
var _decorators = require("./decorators.js"); | ||
const FEATURES = Object.freeze({ | ||
const FEATURES = exports.FEATURES = Object.freeze({ | ||
fields: 1 << 1, | ||
@@ -19,3 +19,2 @@ privateMethods: 1 << 2, | ||
}); | ||
exports.FEATURES = FEATURES; | ||
const featuresSameLoose = new Map([[FEATURES.fields, "@babel/plugin-transform-class-properties"], [FEATURES.privateMethods, "@babel/plugin-transform-private-methods"], [FEATURES.privateIn, "@babel/plugin-transform-private-property-in-object"]]); | ||
@@ -22,0 +21,0 @@ const featuresKey = "@babel/plugin-class-features/featuresKey"; |
@@ -702,2 +702,3 @@ "use strict"; | ||
const instanceNodes = []; | ||
let lastInstanceNodeReturnsThis = false; | ||
const pureStaticNodes = []; | ||
@@ -743,2 +744,3 @@ let classBindingNode = null; | ||
} | ||
lastInstanceNodeReturnsThis = false; | ||
switch (true) { | ||
@@ -795,2 +797,3 @@ case isStaticBlock: | ||
case isInstance && isPublic && isField && !setPublicClassFields: | ||
lastInstanceNodeReturnsThis = true; | ||
instanceNodes.push(buildPublicFieldInitSpec(_core.types.thisExpression(), prop, file)); | ||
@@ -808,2 +811,3 @@ break; | ||
instanceNodes: instanceNodes.filter(Boolean), | ||
lastInstanceNodeReturnsThis, | ||
pureStaticNodes: pureStaticNodes.filter(Boolean), | ||
@@ -810,0 +814,0 @@ classBindingNode, |
@@ -87,8 +87,8 @@ "use strict"; | ||
if (typeof file.get(versionKey) === "number") { | ||
file.set(versionKey, "7.22.15"); | ||
file.set(versionKey, "7.23.5"); | ||
return; | ||
} | ||
} | ||
if (!file.get(versionKey) || _semver.lt(file.get(versionKey), "7.22.15")) { | ||
file.set(versionKey, "7.22.15"); | ||
if (!file.get(versionKey) || _semver.lt(file.get(versionKey), "7.23.5")) { | ||
file.set(versionKey, "7.23.5"); | ||
} | ||
@@ -101,3 +101,3 @@ }, | ||
var _ref; | ||
if (file.get(versionKey) !== "7.22.15") return; | ||
if (file.get(versionKey) !== "7.23.5") return; | ||
if (!(0, _features.shouldTransform)(path, file)) return; | ||
@@ -171,3 +171,3 @@ const pathIsClassDeclaration = path.isClassDeclaration(); | ||
}, file); | ||
let keysNodes, staticNodes, instanceNodes, pureStaticNodes, classBindingNode, wrapClass; | ||
let keysNodes, staticNodes, instanceNodes, lastInstanceNodeReturnsThis, pureStaticNodes, classBindingNode, wrapClass; | ||
{ | ||
@@ -186,2 +186,3 @@ if (isDecorated) { | ||
instanceNodes, | ||
lastInstanceNodeReturnsThis, | ||
classBindingNode, | ||
@@ -201,3 +202,3 @@ wrapClass | ||
} | ||
}); | ||
}, lastInstanceNodeReturnsThis); | ||
} | ||
@@ -220,3 +221,3 @@ const wrappedPath = wrapClass(path); | ||
{ | ||
if (file.get(versionKey) !== "7.22.15") return; | ||
if (file.get(versionKey) !== "7.23.5") return; | ||
const decl = path.get("declaration"); | ||
@@ -223,0 +224,0 @@ if (decl.isClassDeclaration() && (0, _decorators.hasDecorators)(decl.node)) { |
@@ -47,3 +47,3 @@ "use strict"; | ||
}; | ||
function injectInitialization(path, constructor, nodes, renamer) { | ||
function injectInitialization(path, constructor, nodes, renamer, lastReturnsThis) { | ||
if (!nodes.length) return; | ||
@@ -70,7 +70,13 @@ const isDerived = !!path.node.superClass; | ||
if (isFirst) { | ||
bareSuper.insertAfter(nodes); | ||
isFirst = false; | ||
} else { | ||
bareSuper.insertAfter(nodes.map(n => _core.types.cloneNode(n))); | ||
nodes = nodes.map(n => _core.types.cloneNode(n)); | ||
} | ||
if (!bareSuper.parentPath.isExpressionStatement()) { | ||
const allNodes = [bareSuper.node, ...nodes.map(n => _core.types.toExpression(n))]; | ||
if (!lastReturnsThis) allNodes.push(_core.types.thisExpression()); | ||
bareSuper.replaceWith(_core.types.sequenceExpression(allNodes)); | ||
} else { | ||
bareSuper.insertAfter(nodes); | ||
} | ||
} | ||
@@ -77,0 +83,0 @@ } else { |
{ | ||
"name": "@babel/helper-create-class-features-plugin", | ||
"version": "7.22.15", | ||
"version": "7.23.5", | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
@@ -22,7 +22,7 @@ "license": "MIT", | ||
"@babel/helper-annotate-as-pure": "^7.22.5", | ||
"@babel/helper-environment-visitor": "^7.22.5", | ||
"@babel/helper-function-name": "^7.22.5", | ||
"@babel/helper-member-expression-to-functions": "^7.22.15", | ||
"@babel/helper-environment-visitor": "^7.22.20", | ||
"@babel/helper-function-name": "^7.23.0", | ||
"@babel/helper-member-expression-to-functions": "^7.23.0", | ||
"@babel/helper-optimise-call-expression": "^7.22.5", | ||
"@babel/helper-replace-supers": "^7.22.9", | ||
"@babel/helper-replace-supers": "^7.22.20", | ||
"@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", | ||
@@ -36,5 +36,5 @@ "@babel/helper-split-export-declaration": "^7.22.6", | ||
"devDependencies": { | ||
"@babel/core": "^7.22.15", | ||
"@babel/core": "^7.23.5", | ||
"@babel/helper-plugin-test-runner": "^7.22.5", | ||
"@babel/preset-env": "^7.22.15" | ||
"@babel/preset-env": "^7.23.5" | ||
}, | ||
@@ -41,0 +41,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194768
1455