@babel/plugin-transform-runtime
Advanced tools
Comparing version 7.4.0 to 7.4.3
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.hasMinVersion = hasMinVersion; | ||
exports.typeAnnotationToString = typeAnnotationToString; | ||
@@ -19,2 +20,12 @@ function _semver() { | ||
function _core() { | ||
const data = require("@babel/core"); | ||
_core = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,2 +37,15 @@ | ||
return !_semver().default.intersects(`<${minVersion}`, runtimeVersion) && !_semver().default.intersects(`>=8.0.0`, runtimeVersion); | ||
} | ||
function typeAnnotationToString(node) { | ||
switch (node.type) { | ||
case "GenericTypeAnnotation": | ||
if (_core().types.isIdentifier(node.id, { | ||
name: "Array" | ||
})) return "array"; | ||
break; | ||
case "StringTypeAnnotation": | ||
return "string"; | ||
} | ||
} |
@@ -62,2 +62,4 @@ "use strict"; | ||
var _helpers = require("./helpers"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -146,2 +148,10 @@ | ||
function maybeNeedsPolyfill(path, methods, name) { | ||
if (!methods[name].types) return true; | ||
const typeAnnotation = path.get("object").getTypeAnnotation(); | ||
const type = (0, _helpers.typeAnnotationToString)(typeAnnotation); | ||
if (!type) return true; | ||
return methods[name].types.some(name => name === type); | ||
} | ||
if (has(options, "useBuiltIns")) { | ||
@@ -263,3 +273,3 @@ if (options.useBuiltIns) { | ||
if (injectCoreJS3 && !hasStaticMapping(object.name, propertyName)) { | ||
if (hasMapping(InstanceProperties, propertyName)) { | ||
if (hasMapping(InstanceProperties, propertyName) && maybeNeedsPolyfill(path.get("callee"), InstanceProperties, propertyName)) { | ||
let context1, context2; | ||
@@ -325,3 +335,3 @@ | ||
if (path.scope.getBindingIdentifier(objectName) || !hasStaticMapping(objectName, propertyName)) { | ||
if (injectCoreJS3 && hasMapping(InstanceProperties, propertyName)) { | ||
if (injectCoreJS3 && hasMapping(InstanceProperties, propertyName) && maybeNeedsPolyfill(path, InstanceProperties, propertyName)) { | ||
path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${moduleName}/${corejsRoot}/instance/${InstanceProperties[propertyName].path}`, `${propertyName}InstanceProperty`), [object])); | ||
@@ -328,0 +338,0 @@ } |
@@ -559,3 +559,4 @@ "use strict"; | ||
stable: true, | ||
path: "concat" | ||
path: "concat", | ||
types: ["array"] | ||
}, | ||
@@ -562,0 +563,0 @@ copyWithin: { |
{ | ||
"name": "@babel/plugin-transform-runtime", | ||
"version": "7.4.0", | ||
"version": "7.4.3", | ||
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals", | ||
@@ -24,14 +24,12 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime", | ||
"devDependencies": { | ||
"@babel/core": "^7.4.0", | ||
"@babel/core": "^7.4.3", | ||
"@babel/helper-plugin-test-runner": "^7.0.0", | ||
"@babel/helpers": "^7.4.0", | ||
"@babel/plugin-transform-member-expression-literals": "^7.2.0", | ||
"@babel/plugin-transform-property-literals": "^7.2.0", | ||
"@babel/plugin-transform-runtime": "^7.4.0", | ||
"@babel/preset-env": "^7.4.0", | ||
"@babel/runtime": "^7.4.0", | ||
"@babel/helpers": "^7.4.3", | ||
"@babel/plugin-transform-runtime": "^7.4.3", | ||
"@babel/preset-env": "^7.4.3", | ||
"@babel/runtime": "^7.4.3", | ||
"@babel/template": "^7.4.0", | ||
"@babel/types": "7.0.0-beta.53" | ||
}, | ||
"gitHead": "f1328fb913b5a93d54dfc6e3728b1f56c8f4a804" | ||
"gitHead": "508fde4009f31883f318b9e6546459ac1b086a91" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
39231
8
1430
0