@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly
Advanced tools
Comparing version 7.23.3 to 8.0.0-alpha.5
@@ -1,14 +0,10 @@ | ||
'use strict'; | ||
import { types } from '@babel/core'; | ||
import { declare } from '@babel/helper-plugin-utils'; | ||
import { requeueComputedKeyAndDecorators } from '@babel/helper-environment-visitor'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var core = require('@babel/core'); | ||
var helperPluginUtils = require('@babel/helper-plugin-utils'); | ||
var helperEnvironmentVisitor = require('@babel/helper-environment-visitor'); | ||
function isNameOrLength(key) { | ||
if (core.types.isIdentifier(key)) { | ||
if (types.isIdentifier(key)) { | ||
return key.name === "name" || key.name === "length"; | ||
} | ||
if (core.types.isStringLiteral(key)) { | ||
if (types.isStringLiteral(key)) { | ||
return key.value === "name" || key.value === "length"; | ||
@@ -19,3 +15,3 @@ } | ||
function isStaticFieldWithValue(node) { | ||
return (core.types.isClassProperty(node) || core.types.isClassPrivateProperty(node)) && node.static && !!node.value; | ||
return (types.isClassProperty(node) || types.isClassPrivateProperty(node)) && node.static && !!node.value; | ||
} | ||
@@ -38,3 +34,3 @@ const hasReferenceVisitor = { | ||
function isReferenceOrThis(node, name) { | ||
return core.types.isThisExpression(node) || name && core.types.isIdentifier(node, { | ||
return types.isThisExpression(node) || name && types.isIdentifier(node, { | ||
name | ||
@@ -57,3 +53,3 @@ }); | ||
if (path.isMethod()) { | ||
helperEnvironmentVisitor.requeueComputedKeyAndDecorators(path); | ||
requeueComputedKeyAndDecorators(path); | ||
} | ||
@@ -63,6 +59,5 @@ } | ||
function getPotentiallyBuggyFieldsIndexes(path) { | ||
var _path$node$id; | ||
const buggyPublicStaticFieldsIndexes = []; | ||
let classReferenced = false; | ||
const className = (_path$node$id = path.node.id) == null ? void 0 : _path$node$id.name; | ||
const className = path.node.id?.name; | ||
const hasReferenceState = { | ||
@@ -87,3 +82,3 @@ name: className, | ||
if (!nextPotentiallyBuggy) { | ||
if (core.types.isStaticBlock(node)) { | ||
if (types.isStaticBlock(node)) { | ||
classReferenced = true; | ||
@@ -104,3 +99,3 @@ nextPotentiallyBuggy = true; | ||
} | ||
if (core.types.isClassProperty(node, { | ||
if (types.isClassProperty(node, { | ||
static: true | ||
@@ -120,3 +115,3 @@ }) && (nextPotentiallyBuggy || node.computed || isNameOrLength(node.key))) { | ||
const node = body[i]; | ||
if (core.types.isClassProperty(node, { | ||
if (types.isClassProperty(node, { | ||
static: true, | ||
@@ -152,9 +147,9 @@ computed: false | ||
function buildFieldsReplacement(fields, scope, file) { | ||
return core.types.staticBlock(fields.map(field => { | ||
const key = field.computed || !core.types.isIdentifier(field.key) ? field.key : core.types.stringLiteral(field.key.name); | ||
return core.types.expressionStatement(core.types.callExpression(file.addHelper("defineProperty"), [core.types.thisExpression(), key, field.value || scope.buildUndefinedNode()])); | ||
return types.staticBlock(fields.map(field => { | ||
const key = field.computed || !types.isIdentifier(field.key) ? field.key : types.stringLiteral(field.key.name); | ||
return types.expressionStatement(types.callExpression(file.addHelper("defineProperty"), [types.thisExpression(), key, field.value || scope.buildUndefinedNode()])); | ||
})); | ||
} | ||
var index = helperPluginUtils.declare(api => { | ||
api.assertVersion(7); | ||
var index = declare(api => { | ||
api.assertVersion("8.0.0-alpha.5"); | ||
const setPublicClassFields = api.assumption("setPublicClassFields"); | ||
@@ -179,3 +174,3 @@ return { | ||
exports.default = index; | ||
export { index as default }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly", | ||
"version": "7.23.3", | ||
"version": "8.0.0-alpha.5", | ||
"description": "Transform static class fields assignments that are affected by https://crbug.com/v8/12421", | ||
@@ -25,18 +25,18 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-environment-visitor": "^7.22.20", | ||
"@babel/helper-plugin-utils": "^7.22.5" | ||
"@babel/helper-environment-visitor": "^8.0.0-alpha.5", | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.5" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.0.0" | ||
"@babel/core": "^8.0.0-alpha.5" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.23.3", | ||
"@babel/helper-plugin-test-runner": "^7.22.5", | ||
"@babel/traverse": "^7.23.3" | ||
"@babel/core": "^8.0.0-alpha.5", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.5", | ||
"@babel/traverse": "^8.0.0-alpha.5" | ||
}, | ||
"engines": { | ||
"node": ">=6.9.0" | ||
"node": "^16.20.0 || ^18.16.0 || >=20.0.0" | ||
}, | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
"type": "commonjs" | ||
"type": "module" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Yes
24938
164
2
+ Added@babel/code-frame@8.0.0-alpha.13(transitive)
+ Added@babel/compat-data@8.0.0-alpha.13(transitive)
+ Added@babel/core@8.0.0-alpha.13(transitive)
+ Added@babel/generator@8.0.0-alpha.13(transitive)
+ Added@babel/helper-compilation-targets@8.0.0-alpha.13(transitive)
+ Added@babel/helper-environment-visitor@8.0.0-alpha.11(transitive)
+ Added@babel/helper-plugin-utils@8.0.0-alpha.13(transitive)
+ Added@babel/helper-string-parser@8.0.0-alpha.13(transitive)
+ Added@babel/helper-validator-identifier@8.0.0-alpha.13(transitive)
+ Added@babel/helper-validator-option@8.0.0-alpha.13(transitive)
+ Added@babel/helpers@8.0.0-alpha.13(transitive)
+ Added@babel/parser@8.0.0-alpha.13(transitive)
+ Added@babel/template@8.0.0-alpha.13(transitive)
+ Added@babel/traverse@8.0.0-alpha.13(transitive)
+ Added@babel/types@8.0.0-alpha.13(transitive)
+ Addedglobals@15.12.0(transitive)
+ Addedjs-tokens@8.0.3(transitive)
+ Addedlru-cache@7.18.3(transitive)
+ Addedsemver@7.6.3(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/compat-data@7.26.2(transitive)
- Removed@babel/core@7.26.0(transitive)
- Removed@babel/generator@7.26.2(transitive)
- Removed@babel/helper-compilation-targets@7.25.9(transitive)
- Removed@babel/helper-environment-visitor@7.24.7(transitive)
- Removed@babel/helper-module-imports@7.25.9(transitive)
- Removed@babel/helper-module-transforms@7.26.0(transitive)
- Removed@babel/helper-plugin-utils@7.25.9(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/helper-validator-option@7.25.9(transitive)
- Removed@babel/helpers@7.26.0(transitive)
- Removed@babel/parser@7.26.2(transitive)
- Removed@babel/template@7.25.9(transitive)
- Removed@babel/traverse@7.25.9(transitive)
- Removed@babel/types@7.26.0(transitive)
- Removedglobals@11.12.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedsemver@6.3.1(transitive)
- Removedyallist@3.1.1(transitive)