@babel/plugin-transform-object-super
Advanced tools
Comparing version 8.0.0-alpha.4 to 8.0.0-alpha.5
@@ -14,6 +14,22 @@ import { declare } from '@babel/helper-plugin-utils'; | ||
var index = declare(api => { | ||
api.assertVersion(7); | ||
api.assertVersion("8.0.0-alpha.5"); | ||
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) { | ||
@@ -27,5 +43,15 @@ let objectRef; | ||
if (objectRef) { | ||
path.scope.push({ | ||
id: types.cloneNode(objectRef) | ||
}); | ||
const scopePath = path.findParent(p => p.isFunction() || p.isProgram() || p.isLoop()); | ||
const useLet = scopePath.isLoop(); | ||
if (useLet) { | ||
newLets.add({ | ||
scopePath, | ||
id: types.cloneNode(objectRef) | ||
}); | ||
} else { | ||
path.scope.push({ | ||
id: types.cloneNode(objectRef), | ||
kind: "var" | ||
}); | ||
} | ||
path.replaceWith(types.assignmentExpression("=", types.cloneNode(objectRef), path.node)); | ||
@@ -32,0 +58,0 @@ } |
{ | ||
"name": "@babel/plugin-transform-object-super", | ||
"version": "8.0.0-alpha.4", | ||
"version": "8.0.0-alpha.5", | ||
"description": "Compile ES2015 object super to ES5", | ||
@@ -20,11 +20,11 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.4", | ||
"@babel/helper-replace-supers": "^8.0.0-alpha.4" | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.5", | ||
"@babel/helper-replace-supers": "^8.0.0-alpha.5" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^8.0.0-alpha.4" | ||
"@babel/core": "^8.0.0-alpha.5" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^8.0.0-alpha.4", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.4" | ||
"@babel/core": "^8.0.0-alpha.5", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.5" | ||
}, | ||
@@ -31,0 +31,0 @@ "engines": { |
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
9322
61