feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = rewriteLiveReferences;
var _assert = require("assert");
var _core = require("@babel/core");
var _helperSimpleAccess = require("@babel/helper-simple-access");
function isInType(path) {
do {
switch (path.parent.type) {
@@ -54,10 +52,6 @@ function rewriteLiveReferences(programPath, metadata, wrapReference) {
exported
};
programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState);
const bindingNames = new Set([...Array.from(imported.keys()), ...Array.from(exported.keys())]);
{
(0, _helperSimpleAccess.default)(programPath, bindingNames, false);
}
const rewriteReferencesVisitorState = {
seen: new WeakSet(),
metadata,
@@ -269,14 +263,25 @@ const rewriteReferencesVisitor = {
const exportedNames = exported.get(localName);
const importData = imported.get(localName);
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
_assert(path.node.operator === "=", "Path was not simplified");
const assignment = path.node;
if (importData) {
assignment.left = buildImportReference(importData, left.node);
assignment.right = _core.types.sequenceExpression([assignment.right, buildImportThrow(localName)]);
}
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, assignment, path.scope));
const {
operator
} = assignment;
let newExpr;
if (operator === "=") {
newExpr = assignment;
} else if (operator === "&&=" || operator === "||=" || operator === "??=") {
newExpr = _core.types.assignmentExpression("=", assignment.left, _core.types.logicalExpression(operator.slice(0, -1), _core.types.cloneNode(assignment.left), assignment.right));
} else {
newExpr = _core.types.assignmentExpression("=", assignment.left, _core.types.binaryExpression(operator.slice(0, -1), _core.types.cloneNode(assignment.left), assignment.right));
}
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, newExpr, path.scope));
requeueInParent(path);
path.skip();
}
} else {
const ids = left.getOuterBindingIdentifiers();
@@ -304,7 +309,7 @@ const rewriteReferencesVisitor = {
}
}
},
"ForOfStatement|ForInStatement"(path) {
ForXStatement(path) {
const {
scope,
node

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-module-transforms",
"version": "7.25.2",
"version": "7.26.0",
"description": "Babel helper functions for implementing ES6 module transformations",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-helper-module-transforms",
@@ -15,13 +15,12 @@
},
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-module-imports": "^7.24.7",
"@babel/helper-simple-access": "^7.24.7",
"@babel/helper-validator-identifier": "^7.24.7",
"@babel/traverse": "^7.25.2"
"@babel/helper-module-imports": "^7.25.9",
"@babel/helper-validator-identifier": "^7.25.9",
"@babel/traverse": "^7.25.9"
},
"devDependencies": {
"@babel/core": "^7.25.2"
"@babel/core": "^7.26.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0"