@babel/plugin-transform-object-super
Advanced tools
Comparing version 7.22.5 to 7.23.3
@@ -18,7 +18,23 @@ "use strict"; | ||
} | ||
var _default = (0, _helperPluginUtils.declare)(api => { | ||
var _default = exports.default = (0, _helperPluginUtils.declare)(api => { | ||
api.assertVersion(7); | ||
const newLets = new Set(); | ||
return { | ||
name: "transform-object-super", | ||
visitor: { | ||
Loop: { | ||
exit(path) { | ||
newLets.forEach(v => { | ||
if (v.scopePath === path) { | ||
path.scope.push({ | ||
id: v.id, | ||
kind: "let" | ||
}); | ||
path.scope.crawl(); | ||
path.requeue(); | ||
newLets.delete(v); | ||
} | ||
}); | ||
} | ||
}, | ||
ObjectExpression(path, state) { | ||
@@ -32,5 +48,15 @@ let objectRef; | ||
if (objectRef) { | ||
path.scope.push({ | ||
id: _core.types.cloneNode(objectRef) | ||
}); | ||
const scopePath = path.findParent(p => p.isFunction() || p.isProgram() || p.isLoop()); | ||
const useLet = scopePath.isLoop(); | ||
if (useLet) { | ||
newLets.add({ | ||
scopePath, | ||
id: _core.types.cloneNode(objectRef) | ||
}); | ||
} else { | ||
path.scope.push({ | ||
id: _core.types.cloneNode(objectRef), | ||
kind: "var" | ||
}); | ||
} | ||
path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(objectRef), path.node)); | ||
@@ -42,4 +68,3 @@ } | ||
}); | ||
exports.default = _default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/plugin-transform-object-super", | ||
"version": "7.22.5", | ||
"version": "7.23.3", | ||
"description": "Compile ES2015 object super to ES5", | ||
@@ -21,3 +21,3 @@ "repository": { | ||
"@babel/helper-plugin-utils": "^7.22.5", | ||
"@babel/helper-replace-supers": "^7.22.5" | ||
"@babel/helper-replace-supers": "^7.22.20" | ||
}, | ||
@@ -28,3 +28,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "^7.22.5", | ||
"@babel/core": "^7.23.3", | ||
"@babel/helper-plugin-test-runner": "^7.22.5" | ||
@@ -31,0 +31,0 @@ }, |
@@ -5,3 +5,3 @@ # @babel/plugin-transform-object-super | ||
See our website [@babel/plugin-transform-object-super](https://babeljs.io/docs/en/babel-plugin-transform-object-super) for more information. | ||
See our website [@babel/plugin-transform-object-super](https://babeljs.io/docs/babel-plugin-transform-object-super) for more information. | ||
@@ -8,0 +8,0 @@ ## Install |
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
9297
65